Browse Source

Test, falls keine Reihe gewinnt

remotes/origin/dev
fdai7472 11 months ago
parent
commit
c8faaa8ba5
  1. 2
      src/main/c/Stefan/slot_machine.c
  2. 17
      src/test/c/Stefan/test_slot_machine.c

2
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;

17
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);
}
}
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);
}
Loading…
Cancel
Save