diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index 0171e87..240f0ec 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -4,9 +4,12 @@ #include "rockPaperScissors.h" +char getComputerInput(){ + int input = rand() % 3; + return input; +} char findWinner(int inputPlayer, int inputComputer){ - if (inputPlayer == inputComputer){ return NOWINNER; } @@ -22,4 +25,4 @@ char findWinner(int inputPlayer, int inputComputer){ else { return COMPUTERWINSROUND; } -} \ No newline at end of file +} diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index 73dd319..e31dbcd 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -13,7 +13,13 @@ enum roundWinner{ NOWINNER }; +enum gameWinner{ + PLAYERWINSGAME, + COMPUTERWINSGAME +}; + char findWinner(int inputPlayer, int inputComputer); +char getComputerInput(); #endif \ No newline at end of file diff --git a/test/c/test_rockPaperScissors.c b/test/c/test_rockPaperScissors.c index dea8ee4..141ebb8 100644 --- a/test/c/test_rockPaperScissors.c +++ b/test/c/test_rockPaperScissors.c @@ -116,12 +116,24 @@ void test_rockPaperScissors_differentResultsPlayerLoses(void) TEST_ASSERT_EQUAL_INT(COMPUTERWINSROUND, result); } +void test_rockPaperScissors_generateComputerInput(void) +{ + /* arrange */ + //Hier die Werte eingeben + char result; + + /* act */ + //Die Funktion wird ausgeführt + result = getComputerInput(); + + /* assert */ + //Vergleichen + TEST_ASSERT_EQUAL_INT(ROCK || PAPER || SCISSORS, result); +} + #endif // TEST /*Testcases: -rockPaperScissors_sameResult -rockPaperScissors_differentResultsPlayerWins -rockPaperScissors_differentResultsPlayerLoses rockPaperScissors_playerGetsBestOutOf3 rockPaperScissors_computerGetsBestOutOf3 rockPaperScissors_outputResult