Browse Source

3. Unittest

remotes/origin/Pascal
Pascal Schneider 11 months ago
parent
commit
d6b4aa16f8
  1. 15
      test/test_timequiz.c

15
test/test_timequiz.c

@ -38,4 +38,19 @@ void test_displayQuestion(void) {
displayQuestion(question, answers, correctIndex); displayQuestion(question, answers, correctIndex);
} }
void test_processUserAnswer_correct(void) {
int score = 0;
int totalCorrectAnswers = 0;
char* answers[] = {"Paris", "London", "Berlin", "Madrid"};
int correctIndex = 0;
int userAnswer = 1;
// Call the function to process user answer
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers);
// Assert that the score and total correct answers are updated correctly
TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
}
#endif //TEST #endif //TEST
Loading…
Cancel
Save