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