diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index 4f482e4..a8477e6 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "rockPaperScissors.h" @@ -41,3 +42,10 @@ int wasGameWon(roundsToWin, playerWins, computerWins){ return winner; } +bool validatePlayerInput(int playerInput){ + bool inputValid; + if (playerInput == ROCK || PAPER || SCISSORS){ + inputValid = true; + } + return inputValid; +} \ No newline at end of file diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index e3eb73f..d6df3ec 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -1,6 +1,8 @@ #ifndef ROCKPAPERSCISSORS_H #define ROCKPAPERSCISSORS_H +#include + enum inputOptions{ ROCK, PAPER, @@ -22,6 +24,7 @@ enum gameWinner{ int findWinner(int inputPlayer, int inputComputer); int getComputerInput(); -int wasGameWon(roundsToWin, playerWins, computerWins); +int wasGameWon(int roundsToWin, int playerWins, int computerWins); +bool validatePlayerInput(int playerInput); #endif \ No newline at end of file diff --git a/test/c/test_rockPaperScissors.c b/test/c/test_rockPaperScissors.c index 49a6b99..69d6761 100644 --- a/test/c/test_rockPaperScissors.c +++ b/test/c/test_rockPaperScissors.c @@ -182,11 +182,25 @@ void test_rockPaperScissors_gameWasNotWon(void) TEST_ASSERT_EQUAL_INT(NOTWONYET, result); } +void test_rockPaperScissors_validPlayerInput(void) +{ + /* arrange */ + //Hier die Werte eingeben + bool result; + int playerInput = 1; + + /* act */ + //Die Funktion wird ausgeführt + result = validatePlayerInput(playerInput); + + /* assert */ + //Vergleichen + TEST_ASSERT_EQUAL_INT(true, result); +} + #endif // TEST /*Testcases: -rockPaperScissors_playerGetsBestOutOf3 -rockPaperScissors_computerGetsBestOutOf3 rockPaperScissors_outputResult rockPaperScissors_invalidInput */ \ No newline at end of file