From 47f81726d718d79365f49b5f78c88e7ea41fe0d5 Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Tue, 24 Jan 2023 12:42:20 +0100 Subject: [PATCH] =?UTF-8?q?if=20schleife=20spieler=20gewonnen=20unter=2021?= =?UTF-8?q?=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/raetselronja.c | 4 ++++ test/c/test_raetselronja.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/c/raetselronja.c b/src/c/raetselronja.c index 3ff71b8..03b8fdd 100644 --- a/src/c/raetselronja.c +++ b/src/c/raetselronja.c @@ -151,6 +151,10 @@ int blackjack(int spieler, int geber, int janein){ printf("Unentschienden."); return 0; } + if (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 fb91a82..967ee97 100644 --- a/test/c/test_raetselronja.c +++ b/test/c/test_raetselronja.c @@ -98,7 +98,7 @@ void test_runRaetselTestBJ(void){ randnum_ExpectAndReturn(10); userInput_ExpectAndReturn(1); - + printf("-----------------------------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(1, result); @@ -115,6 +115,7 @@ void test_runRaetselTestBJif(void){ randnum_ExpectAndReturn(8); userInput_ExpectAndReturn(2); + printf("-----------------------------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(1, result); @@ -135,6 +136,7 @@ void test_runRaetselTestBJifende(void){ randnum_ExpectAndReturn(7); userInput_ExpectAndReturn(1); + printf("-----------------------------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(1, result); @@ -155,6 +157,7 @@ void test_runRaetselTestBJifende1(void){ randnum_ExpectAndReturn(7); userInput_ExpectAndReturn(1); + printf("-----------------------1------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(1, result); @@ -175,6 +178,7 @@ void test_runRaetselTestBJifende2(void){ randnum_ExpectAndReturn(9); userInput_ExpectAndReturn(1); + printf("-----------------------2------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(2, result); @@ -195,6 +199,7 @@ void test_runRaetselTestBJifende3(void){ randnum_ExpectAndReturn(10); userInput_ExpectAndReturn(1); + printf("-----------------------3------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(0, result); @@ -215,11 +220,33 @@ void test_runRaetselTestBJifende4(void){ randnum_ExpectAndReturn(9); userInput_ExpectAndReturn(1); + printf("-----------------------4------------------------\n"); int result = blackjack(spieler, geber, janein); TEST_ASSERT_EQUAL_INT(0, result); } +void test_runRaetselTestBJifende5(void){ + + int spieler = 0; + int geber = 0; + int janein = 0; + + userInput_ExpectAndReturn(1); + randnum_ExpectAndReturn(10); + randnum_ExpectAndReturn(10); + userInput_ExpectAndReturn(1); + randnum_ExpectAndReturn(7); + randnum_ExpectAndReturn(10); + userInput_ExpectAndReturn(1); + + printf("-----------------------5------------------------\n"); + + int result = blackjack(spieler, geber, janein); + TEST_ASSERT_EQUAL_INT(1, result); + +} + #endif // TEST \ No newline at end of file