Here is how the client code would look:
void testGameState() {
GameState state = new GameStateInfo(3, 4, 5);
string stateDisplay = state->toString();
cout << stateDisplay << endl;
string output = " Pile 1: 3\n Pile 2: 4\n Pile 3: 5";
assert(stateDisplay == output);
Move move = new MoveInfo(5, 3);
GameState newState = state->nextState(move);
assert(newState->getPile1() == 3 && newState->getPile2() == 4 &&
newState->getPile3() == 0);
cout << "testGameState succeeded.\n";
}
|
|
Here is the extended main procedure:
int main(int argc, char** argv) {
testMove();
testGameState();
cout << "All tests succeeded.\n";
return (EXIT_SUCCESS);
}
|
|