Browse Source

Tests, falls 2 Reihen gewinnen + Fehler bei Gewinnberechnung behoben

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

8
src/main/c/Stefan/slot_machine.c

@ -108,10 +108,10 @@ int getWinnings(char symbols[], int bet){
if (symbols[i * ROWS] == symbols[i * ROWS + 1] && symbols[i * ROWS] == symbols[i * ROWS + 2]) {
switch(symbols[i * ROWS]){
case 'A': winnings = bet * 3; break;
case 'B': winnings = bet * 5; break;
case 'C': winnings = bet * 10; break;
case 'D': winnings = bet * 20; break;
case 'A': winnings += bet * 3; break;
case 'B': winnings += bet * 5; break;
case 'C': winnings += bet * 10; break;
case 'D': winnings += bet * 20; break;
}
}
}

85
src/test/c/Stefan/test_slot_machine.c

@ -16,6 +16,7 @@ void test_subtract_bet_10_from_balance_10() {
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_subtract_bet_0_from_balance_10() {
//arrange
@ -109,3 +110,87 @@ void test_3_D_won_bet_equals_10() {
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_6_A_won_bet_equals_10() {
//arrange
char testSymbols[] = {"AAAAAACAC"};
int expectedResult = 60;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_6_B_won_bet_equals_10() {
//arrange
char testSymbols[] = {"BBBBBBCAC"};
int expectedResult = 100;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_6_C_won_bet_equals_10() {
//arrange
char testSymbols[] = {"CCCCCCCAC"};
int expectedResult = 200;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_6_D_won_bet_equals_10() {
//arrange
char testSymbols[] = {"DDDDDDCAC"};
int expectedResult = 400;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_3_A_3_B_won_bet_equals_10() {
//arrange
char testSymbols[] = {"AAABBBCAC"};
int expectedResult = 80;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
void test_3_C_3_D_won_bet_equals_10() {
//arrange
char testSymbols[] = {"BAACCCDDD"};
int expectedResult = 300;
//act
int actualResult = getWinnings(testSymbols, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
Loading…
Cancel
Save