@ -12,136 +12,134 @@ void tearDown(void)
}
void test_rockPaperScissors_sameResul t ( void )
void test_rockPaperScissors_validPlayerInpu t ( void )
{
/* arrange */
int result ;
int inputPlayer = ROCK ;
int inputComputer = inputPlayer ;
bool result ;
int playerInput = 2 ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = validatePlayerInput ( playerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( NOWINNER , result ) ;
TEST_ASSERT_EQUAL_INT ( true , result ) ;
}
void test_rockPaperScissors_playerWinsRound ( void )
void test_rockPaperScissors_invalidPlayerInput ( void )
{
/* arrange */
int result ;
int inputPlayer = ROCK ;
int inputComputer = SCISSORS ;
bool result ;
int playerInput = 5 ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = validatePlayerInput ( playerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( PLAYERWINSROUND , result ) ;
TEST_ASSERT_EQUAL_INT ( false , result ) ;
}
void test_rockPaperScissors_generateComputerInput ( void )
{
/* arrange */
inputPlayer = PAPER ;
inputComputer = ROCK ;
int result ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = getComputerInput ( ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( PLAYERWINSROUND , result ) ;
TEST_ASSERT_INT_WITHIN ( 1 , 1 , result ) ;
}
void test_rockPaperScissors_sameResult ( void )
{
/* arrange */
inputPlayer = SCISSORS ;
inputComputer = PAPER ;
int result ;
int playerInput = ROCK ;
int computerInput = playerInput ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( PLAYERWINSROUND , result ) ;
TEST_ASSERT_EQUAL_INT ( NOWINNER , result ) ;
}
void test_rockPaperScissors_comput erWinsRound ( void )
void test_rockPaperScissors_play erWinsRound ( void )
{
/* arrange */
int result ;
int inputPlayer = ROCK ;
int inputComputer = PAPER ;
int playerInput = ROCK ;
int computerInput = SCISSORS ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSROUND , result ) ;
TEST_ASSERT_EQUAL_INT ( PLAYERWINSROUND , result ) ;
/* arrange */
in putP layer = PAPER ;
inputComputer = SCISSORS ;
playerInput = PAPER ;
computerInput = ROCK ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( COMPUT ERWINSROUND, result ) ;
TEST_ASSERT_EQUAL_INT ( PLAY ERWINSROUND, result ) ;
/* arrange */
in putP layer = SCISSORS ;
inputComputer = ROCK ;
playerInput = SCISSORS ;
computerInput = PAPER ;
/* act */
result = findWinner ( inputPlayer , inputComputer ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( COMPUT ERWINSROUND, result ) ;
TEST_ASSERT_EQUAL_INT ( PLAY ERWINSROUND, result ) ;
}
void test_rockPaperScissors_generateComputerInput ( void )
void test_rockPaperScissors_computerWinsRound ( void )
{
/* arrange */
int result ;
int playerInput = ROCK ;
int computerInput = PAPER ;
/* act */
result = getComputerInput ( ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_INT_WITHIN ( 1 , 1 , result ) ;
}
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSROUND , result ) ;
void test_rockPaperScissors_playerWinsGame ( void )
{
/* arrange */
int result ;
int roundsToWin = 2 ;
int playerWins = 2 , computerWins = 1 ;
playerInput = PAPER ;
computerInput = SCISSORS ;
/* act */
result = wasGameWon ( roundsToWin , playerWins , computerWins ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( PLAYERWINSGAME , result ) ;
}
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSROUND , result ) ;
void test_rockPaperScissors_computerWinsGame ( void )
{
/* arrange */
int result ;
int roundsToWin = 2 ;
int playerWins = 1 , computerWins = 2 ;
playerInput = SCISSORS ;
computerInput = ROCK ;
/* act */
result = wasGameWon ( roundsToWin , playerWins , computerWins ) ;
result = findWinner ( playerInput , computerInput ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSGAME , result ) ;
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSROUND , result ) ;
}
@ -160,31 +158,33 @@ void test_rockPaperScissors_gameWasNotWon(void)
}
void test_rockPaperScissors_validPlayerInput ( void )
void test_rockPaperScissors_playerWinsGame ( void )
{
/* arrange */
bool result ;
int playerInput = 2 ;
int result ;
int roundsToWin = 2 ;
int playerWins = 2 , computerWins = 1 ;
/* act */
result = validatePlayerInput ( playerInput ) ;
result = wasGameWon ( roundsToWin , playerWins , computerWins ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( true , result ) ;
TEST_ASSERT_EQUAL_INT ( PLAYERWINSGAME , result ) ;
}
void test_rockPaperScissors_invalidPlayerInput ( void )
void test_rockPaperScissors_computerWinsGame ( void )
{
/* arrange */
bool result ;
int playerInput = 5 ;
int result ;
int roundsToWin = 2 ;
int playerWins = 1 , computerWins = 2 ;
/* act */
result = validatePlayerInput ( playerInput ) ;
result = wasGameWon ( roundsToWin , playerWins , computerWins ) ;
/* assert */
TEST_ASSERT_EQUAL_INT ( false , result ) ;
TEST_ASSERT_EQUAL_INT ( COMPUTERWINSGAME , result ) ;
}
# endif / / TEST