Browse Source

refactoring: unittests naming improved

remotes/origin/SchereSteinPapier
Aimee Reincke 2 years ago
parent
commit
b5af819bb7
  1. 6
      src/c/rockPaperScissors.h
  2. 20
      test/c/test_rockPaperScissors.c

6
src/c/rockPaperScissors.h

@ -8,9 +8,9 @@ enum inputOptions{
}; };
enum roundWinner{ enum roundWinner{
PLAYERWINSROUND = 'p',
COMPUTERWINSROUND = 'c',
NOWINNER = 'n'
PLAYERWINSROUND,
COMPUTERWINSROUND,
NOWINNER
}; };

20
test/c/test_rockPaperScissors.c

@ -17,7 +17,7 @@ void test_rockPaperScissors_sameResult(void)
{ {
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
char result; //p=player, c=computer, n=none
char result;
int inputPlayer = ROCK; int inputPlayer = ROCK;
int inputComputer = inputPlayer; int inputComputer = inputPlayer;
@ -27,14 +27,14 @@ void test_rockPaperScissors_sameResult(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('n', result);
TEST_ASSERT_EQUAL_INT(NOWINNER, result);
} }
void test_rockPaperScissors_differentResultsPlayerWins(void) void test_rockPaperScissors_differentResultsPlayerWins(void)
{ {
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
char result; //p=player, c=computer, n=none
char result;
int inputPlayer = ROCK; int inputPlayer = ROCK;
int inputComputer = SCISSORS; int inputComputer = SCISSORS;
@ -44,7 +44,7 @@ void test_rockPaperScissors_differentResultsPlayerWins(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('p', result);
TEST_ASSERT_EQUAL_INT(PLAYERWINSROUND, result);
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
@ -57,7 +57,7 @@ void test_rockPaperScissors_differentResultsPlayerWins(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('p', result);
TEST_ASSERT_EQUAL_INT(PLAYERWINSROUND, result);
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
@ -70,14 +70,14 @@ void test_rockPaperScissors_differentResultsPlayerWins(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('p', result);
TEST_ASSERT_EQUAL_INT(PLAYERWINSROUND, result);
} }
void test_rockPaperScissors_differentResultsPlayerLoses(void) void test_rockPaperScissors_differentResultsPlayerLoses(void)
{ {
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
char result; //p=player, c=computer, n=none
char result;
int inputPlayer = ROCK; int inputPlayer = ROCK;
int inputComputer = PAPER; int inputComputer = PAPER;
@ -87,7 +87,7 @@ void test_rockPaperScissors_differentResultsPlayerLoses(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
TEST_ASSERT_EQUAL_INT(COMPUTERWINSROUND, result);
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
@ -100,7 +100,7 @@ void test_rockPaperScissors_differentResultsPlayerLoses(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
TEST_ASSERT_EQUAL_INT(COMPUTERWINSROUND, result);
/* arrange */ /* arrange */
//Hier die Werte eingeben //Hier die Werte eingeben
@ -113,7 +113,7 @@ void test_rockPaperScissors_differentResultsPlayerLoses(void)
/* assert */ /* assert */
//Vergleichen //Vergleichen
TEST_ASSERT_EQUAL_INT('c', result);
TEST_ASSERT_EQUAL_INT(COMPUTERWINSROUND, result);
} }
#endif // TEST #endif // TEST

Loading…
Cancel
Save