lab4-testing

EECS 183 Lab 4: Testing and Functions

Lab attendance Due at your scheduled lab time and day, Thursday or Friday, February 11th or 12th

Lab assignment Due Monday, February 15, 2021, 11:59 pm Eastern

In this lab, you are writing code and solving practice exam questions to master the use of conditionals and prepare for the first exam. The main focus of of the lab exercise is how to use (call) and test functions. You will have a lot of practice writing the definitions for functions in Project 2. While completing this lab, you will learn the testing tools necessary to master Project 2.

By completing this lab assignment, you will learn:

Prerequisite

Attend the discussion with your lab instructor at your assigned lab time. Check here for the lab section Zoom link

You will complete this lab in small groups of about 4 students. For all labs in EECS 183, to receive a grade, every student must individually submit the lab assingment.

Starter Files

You can download the starter files using this link.

The IDE setup tutorials for Visual Studio and XCode include a video about how to set up a project using the starter files. You can access the tutorials here:

Lab Assignment

NOTE: The test cases you create in this lab can and should be used for your Project 2 RPS tests. Specifically, the tests you create in this lab should be added to your test.cpp for Project 2 Rock Paper Scissors. While Project 2 is an individual assignment, the test cases you create with your lab team can be submitted for credit.

isMoveGood()

IMPORTANT: Note that for this project you can assume user input will always be of the data type expected (which is char for moves). In other words, as the programmer, you only need to check that values entered are valid moves - you do not need to worry about users entering integers, doubles, strings,bools or any combination of these. Those are bad input and prohibited by the REQUIRES clause.

/**
 * Requires: nothing
 * Modifies: nothing
 * Effects:  Returns true if and only if move represents a valid move character:
 *           one of 'R', 'r', 'P', 'p', 'S', 's'. Returns false otherwise.
 */
bool isMoveGood(char move);

test_isMoveGood()

IMPORTANT: Since isMoveGood() returns a value of type bool, this will print a 0 for false and a 1 for true.

void test_isMoveGood() {
    cout << "Now testing function isMoveGood()\n";
    cout << "'r': Expected: 1, Actual: " << isMoveGood('r') << endl;

    // TODO: implement more test cases here

    return;
}
void test_isMoveGood() {
    cout << "Now testing function isMoveGood()\n";

    if (!isMoveGood('r')) {
        cout << "FAILED: isMoveGood('r') should have returned 'true'" << endl;
    }

    // etc.

    return;
}

annouceRoundWinner()

/**
 * Requires: winnerName is the name of the player who won the round.
 * Modifies: cout
 * Effects:  If winnerName is empty, prints a message indicating the round
 *           is a draw. Otherwise, prints a congratulatory message to the
 *           winner.
 * Prompt:   This round is a draw!
 *           ------------- OR -------------
 *           [winner_name] wins the round!
 */
void announceRoundWinner(string winnerName);

test_annouceRoundWinner()

IMPORTANT: Since announceRoundWinner() has a return type of void, you cannot print the non-existent return value from calling the function!.

Bugs To Expose

There are a total of 4 unique bugs to find in our implementations of isMoveGood() and announceRoundWinner(). Your tests will need to expose all of the bugs to receive full points for the lab. The autograder will tell you the names of the bugs that you have exposed, from the following set:

How to Submit

Note: If you’re using Xcode and don’t know how where exactly lab4.cpp is located on your disk, right-click (or click while holding down the Control key) on the file in the Navigator area on the left side of the Xcode window and choose Show in Finder.

If you’re using Visual Studio and would like to know where lab4.cpp is on your disk, right-click on lab4.cpp in the tab above the Code pane and choose Open Containing Folder.

IMPORTANT: For all labs in EECS 183, to receive a grade, every student must individually submit the Lab Submission. Late submission for Labs will not be accepted for credit. For this lab, you will receive twenty submissions per day with feedback.