From d418ea5135094b38345c3afc4cbbb82881fc65ba Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Wed, 7 Feb 2024 13:53:55 +0100 Subject: [PATCH] Test, falls Wetteinsatz > guthaben ist --- src/main/c/Stefan/blackjack.c | 3 +++ src/test/c/Stefan/test_blackjack.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index 96687c6..397eea0 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -32,6 +32,9 @@ int blackjack(){ } int subtractBetFromBalanceBJ(int bet, int balance){ + if(balance - bet < 0){ + return 0; + } return balance - bet; } diff --git a/src/test/c/Stefan/test_blackjack.c b/src/test/c/Stefan/test_blackjack.c index a106eed..26f0412 100644 --- a/src/test/c/Stefan/test_blackjack.c +++ b/src/test/c/Stefan/test_blackjack.c @@ -362,4 +362,19 @@ void test_subtract_bet_1_from_balance_100000() { //assert TEST_ASSERT_EQUAL_INT(expected_result, actual_result); +} + +void test_subtract_bet_10_from_balance_1() { + + //arrange + int bet = 10; + int balance = 1; + int expected_result = 0; + + //act + int actual_result = subtractBetFromBalanceBJ(bet, balance); + + //assert + TEST_ASSERT_EQUAL_INT(expected_result, actual_result); + } \ No newline at end of file