Browse Source

Hinzufügen der Tests für noTrysLeft() + Anpassung im Produktivcode

remotes/origin/tim
fdai7727 11 months ago
parent
commit
3b7e8d1484
  1. 2
      src/main/c/Tim/hangman.c
  2. 27
      src/test/c/Tim/test_hangman.c

2
src/main/c/Tim/hangman.c

@ -233,7 +233,7 @@ void drawHangman(int x)
bool noTrysLeft(int x, char y[])
{
if(x == POSSIBLE_TRYS)
if(x >= POSSIBLE_TRYS)
{
printf("Du hast verloren!\n\nDas gesuchte Wort war \"%s\"\n\nHier hast du ein neues Wort zum erraten.\n\n",y);
return true;

27
src/test/c/Tim/test_hangman.c

@ -119,3 +119,30 @@ void test_letterGuessed_sameCaps_big()
TEST_ASSERT_TRUE(letterGuessed(x,y,length));
}
void test_noTrysLeft_x_equals_POSSIBLE_TRYS()
{
//arrange
char x = POSSIBLE_TRYS;
char y[] ="Kartoffel";
//assert
TEST_ASSERT_TRUE(noTrysLeft(x, y));
}
void test_noTrysLeft_x_lower_POSSIBLE_TRYS()
{
//arrange
char x = POSSIBLE_TRYS-2;
char y[] ="Kartoffel";
//assert
TEST_ASSERT_FALSE(noTrysLeft(x, y));
}
void test_noTrysLeft_x_higher_POSSIBLE_TRYS()
{
//arrange
char x = POSSIBLE_TRYS+2;
char y[] ="Kartoffel";
//assert
TEST_ASSERT_TRUE(noTrysLeft(x, y));
}
Loading…
Cancel
Save