From c8faaa8ba57710efbf577c08c25c6079e5c91ebf Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 29 Jan 2024 18:09:06 +0100 Subject: [PATCH] Test, falls keine Reihe gewinnt --- src/main/c/Stefan/slot_machine.c | 2 +- src/test/c/Stefan/test_slot_machine.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index 114583d..5acc8bf 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -107,7 +107,7 @@ int getWinnings(char symbols[], int bet){ if (symbols[i * ROWS] == symbols[i * ROWS + 1] && symbols[i * ROWS] == symbols[i * ROWS + 2]) { - switch(symbols[i]){ + switch(symbols[i * ROWS]){ case 'A': winnings = bet * 3; break; case 'B': winnings = bet * 5; break; case 'C': winnings = bet * 10; break; diff --git a/src/test/c/Stefan/test_slot_machine.c b/src/test/c/Stefan/test_slot_machine.c index 9781e62..76f8258 100644 --- a/src/test/c/Stefan/test_slot_machine.c +++ b/src/test/c/Stefan/test_slot_machine.c @@ -38,4 +38,19 @@ void test_subtract_bet_5_from_balance_10() { //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); -} \ No newline at end of file +} + +void test_no_rows_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"AABAACAAD"}; + + + int expectedResult = 0; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +}