You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

#ifdef TEST
#include "unity.h"
#include "timequiz.h"
// Test setup function
void setUp(void) {
// This function will be called before each test
}
// Test teardown function
void tearDown(void) {
// This function will be called after each test
}
void test_getRandomQuestionIndex(void) {
int askedQuestions[10] = {0};
int totalQuestions = 10;
// Call the function to get a random question index
int index = getRandomQuestionIndex(askedQuestions, totalQuestions);
// Assert that the index is within the valid range
TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions);
}
void test_displayQuestion(void) {
char* question = "Test Question";
char* answers[] = {"A", "B", "C", "D"};
int correctIndex = 0;
printf("\nExpected Output:\n");
printf("Question: %s\n", question);
for (int i = 0; i < 4; i++) {
printf("%d. %s\n", i + 1, answers[i]);
}
printf("\n");
printf("Actual Output:\n");
displayQuestion(question, answers, correctIndex);
}
#endif //TEST