From 3b7e8d14844447cbd84ace35f2e139e995cca184 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 21:04:48 +0100 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20Tests=20f=C3=BCr=20noTr?= =?UTF-8?q?ysLeft()=20+=20Anpassung=20im=20Produktivcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 2 +- src/test/c/Tim/test_hangman.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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)); +} +