|
@ -53,4 +53,19 @@ void test_processUserAnswer_correct(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_processUserAnswer_wrong(void) { |
|
|
|
|
|
int score = 0; |
|
|
|
|
|
int totalCorrectAnswers = 0; |
|
|
|
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
int correctIndex = 0; |
|
|
|
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
|
|
|
|
|
|
|
|
|
// Call the function to process user answer |
|
|
|
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
|
|
|
|
|
|
|
|
|
// Assert that the score remains unchanged and total correct answers is not incremented |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(0, score); |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#endif //TEST |
|
|
#endif //TEST |