Browse Source

player loses round

remotes/origin/SchereSteinPapier
Aimee Reincke 2 years ago
parent
commit
96183ac115
  1. 9
      src/c/rockPaperScissors.c
  2. 43
      test/c/test_rockPaperScissors.c

9
src/c/rockPaperScissors.c

@ -13,15 +13,24 @@ char findWinner(int inputPlayer, int inputComputer){
if (inputComputer == SCISSORS){
return 'p';
}
else if (inputComputer == PAPER){
return 'c';
}
}
else if (inputPlayer == PAPER){
if (inputComputer == ROCK){
return 'p';
}
else if (inputComputer == SCISSORS){
return 'c';
}
}
else if (inputPlayer == SCISSORS){
if (inputComputer == PAPER){
return 'p';
}
else if (inputComputer == ROCK){
return 'c';
}
}
}

43
test/c/test_rockPaperScissors.c

@ -73,6 +73,48 @@ void test_rockPaperScissors_differentResultsPlayerWins(void)
TEST_ASSERT_EQUAL_INT('p', result);
}
void test_rockPaperScissors_differentResultsPlayerLoses(void)
{
/* arrange */
//Hier die Werte eingeben
char result; //p=player, c=computer, n=none
int inputPlayer = ROCK;
int inputComputer = PAPER;
/* act */
//Die Funktion wird ausgeführt
result = findWinner(inputPlayer, inputComputer);
/* assert */
//Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
/* arrange */
//Hier die Werte eingeben
inputPlayer = PAPER;
inputComputer = SCISSORS;
/* act */
//Die Funktion wird ausgeführt
result = findWinner(inputPlayer, inputComputer);
/* assert */
//Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
/* arrange */
//Hier die Werte eingeben
inputPlayer = SCISSORS;
inputComputer = ROCK;
/* act */
//Die Funktion wird ausgeführt
result = findWinner(inputPlayer, inputComputer);
/* assert */
//Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
}
#endif // TEST
@ -83,4 +125,5 @@ rockPaperScissors_differentResultsPlayerLoses
rockPaperScissors_playerGetsBestOutOf3
rockPaperScissors_computerGetsBestOutOf3
rockPaperScissors_outputResult
rockPaperScissors_invalidInput
*/
Loading…
Cancel
Save