From d6b4aa16f890bbee361d0241360704c1dcff89df Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Mon, 5 Feb 2024 23:54:16 +0100 Subject: [PATCH] 3. Unittest --- test/test_timequiz.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test_timequiz.c b/test/test_timequiz.c index 3199b75..00e3be7 100644 --- a/test/test_timequiz.c +++ b/test/test_timequiz.c @@ -38,4 +38,19 @@ void test_displayQuestion(void) { 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