From 62d297e5eb7c243fac9b26578fae6e331e0a29ba Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Mon, 23 Jan 2023 19:15:57 +0100 Subject: [PATCH] =?UTF-8?q?if=20schleife=20spieler=20gewinnt=20eingef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/raetselronja.c | 5 ++++- test/c/test_raetselronja.c | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/c/raetselronja.c b/src/c/raetselronja.c index 518e6e2..1033cff 100644 --- a/src/c/raetselronja.c +++ b/src/c/raetselronja.c @@ -135,7 +135,10 @@ int blackjack(int spieler, int geber, int janein){ } if (janein == 1 && (spieler >= 21 || geber >= 21)) { - return 0; + if ((geber > 21 || geber < 21) && spieler == 21) { + printf("Spieler hat gewonnen."); + return 1; + } } } diff --git a/test/c/test_raetselronja.c b/test/c/test_raetselronja.c index 202d565..01144d5 100644 --- a/test/c/test_raetselronja.c +++ b/test/c/test_raetselronja.c @@ -101,7 +101,7 @@ void test_runRaetselTestBJ(void){ int result = blackjack(spieler, geber, janein); - TEST_ASSERT_EQUAL_INT(0, result); + TEST_ASSERT_EQUAL_INT(1, result); } void test_runRaetselTestBJif(void){ @@ -137,7 +137,27 @@ void test_runRaetselTestBJifende(void){ int result = blackjack(spieler, geber, janein); - TEST_ASSERT_EQUAL_INT(0, result); + TEST_ASSERT_EQUAL_INT(1, result); + +} + +void test_runRaetselTestBJifende1(void){ + + int spieler = 0; + int geber = 0; + int janein = 0; + + userInput_ExpectAndReturn(1); + randnum_ExpectAndReturn(10); + randnum_ExpectAndReturn(8); + userInput_ExpectAndReturn(1); + randnum_ExpectAndReturn(9); + randnum_ExpectAndReturn(7); + userInput_ExpectAndReturn(1); + + + int result = blackjack(spieler, geber, janein); + TEST_ASSERT_EQUAL_INT(1, result); }