Browse Source

4. Unittest

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

15
test/test_timequiz.c

@ -53,4 +53,19 @@ void test_processUserAnswer_correct(void) {
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
Loading…
Cancel
Save