@ -106,4 +106,12 @@ bool checkForBlackjack(int userCardArray[]){
return true;
}
return false;
int calculateCardsTotal(int cardsArray[], int len){
int sum = 0;
for(int i = 0; i < len; i++){
sum += cardsArray[i];
return sum;
@ -10,5 +10,6 @@ int userInputBJ();
int getRandCard();
int playBJ(int bet, int balance);
bool checkForBlackjack(int userCards[]);
int calculateCardsTotal(int cardsArray[], int len);
#endif // BLACKJACK_H
@ -30,4 +30,18 @@ void test_no_blackjack() {
//assert
TEST_ASSERT_FALSE(result);
void test_2_cards_total_equals_20() {
//arrange
int userCards[] = {10, 10};
int expected_result = 20;
//act
int actual_result = calculateCardsTotal(userCards, 2);
TEST_ASSERT_EQUAL_INT(expected_result, actual_result);