diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 85050d1..2c534e3 100644 --- a/src/main/c/Tim/hangman.c +++ b/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; diff --git a/src/test/c/Tim/test_hangman.c b/src/test/c/Tim/test_hangman.c index 0ddb407..a3c54c6 100644 --- a/src/test/c/Tim/test_hangman.c +++ b/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)); +} +