diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index a8477e6..7a98a97 100644 --- a/src/c/rockPaperScissors.c +++ b/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; } \ No newline at end of file diff --git a/test/c/test_rockPaperScissors.c b/test/c/test_rockPaperScissors.c index 69d6761..5b492e4 100644 --- a/test/c/test_rockPaperScissors.c +++ b/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: