Browse Source

player input is invalid

remotes/origin/SchereSteinPapier
Aimee Reincke 2 years ago
parent
commit
4bc6f7965f
  1. 5
      src/c/rockPaperScissors.c
  2. 18
      test/c/test_rockPaperScissors.c

5
src/c/rockPaperScissors.c

@ -44,8 +44,11 @@ int wasGameWon(roundsToWin, playerWins, computerWins){
bool validatePlayerInput(int playerInput){
bool inputValid;
if (playerInput == ROCK || PAPER || SCISSORS){
if (playerInput == ROCK || playerInput == PAPER || playerInput == SCISSORS){
inputValid = true;
}
else {
inputValid = false;
}
return inputValid;
}

18
test/c/test_rockPaperScissors.c

@ -187,7 +187,7 @@ void test_rockPaperScissors_validPlayerInput(void)
/* arrange */
//Hier die Werte eingeben
bool result;
int playerInput = 1;
int playerInput = 2;
/* act */
//Die Funktion wird ausgeführt
@ -198,6 +198,22 @@ void test_rockPaperScissors_validPlayerInput(void)
TEST_ASSERT_EQUAL_INT(true, result);
}
void test_rockPaperScissors_invalidPlayerInput(void)
{
/* arrange */
//Hier die Werte eingeben
bool result;
int playerInput = 5;
/* act */
//Die Funktion wird ausgeführt
result = validatePlayerInput(playerInput);
/* assert */
//Vergleichen
TEST_ASSERT_EQUAL_INT(false, result);
}
#endif // TEST
/*Testcases:

Loading…
Cancel
Save