previous | index | next

Testing the GameStateInfo Class

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";
}


previous | index | next