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

11 months ago
  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "timequiz.h"
  4. // Test setup function
  5. void setUp(void) {
  6. // This function will be called before each test
  7. }
  8. // Test teardown function
  9. void tearDown(void) {
  10. // This function will be called after each test
  11. }
  12. void test_getRandomQuestionIndex(void) {
  13. int askedQuestions[10] = {0};
  14. int totalQuestions = 10;
  15. // Call the function to get a random question index
  16. int index = getRandomQuestionIndex(askedQuestions, totalQuestions);
  17. // Assert that the index is within the valid range
  18. TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions);
  19. }
  20. void test_displayQuestion(void) {
  21. char* question = "Test Question";
  22. char* answers[] = {"A", "B", "C", "D"};
  23. int correctIndex = 0;
  24. printf("\nExpected Output:\n");
  25. printf("Question: %s\n", question);
  26. for (int i = 0; i < 4; i++) {
  27. printf("%d. %s\n", i + 1, answers[i]);
  28. }
  29. printf("\n");
  30. printf("Actual Output:\n");
  31. displayQuestion(question, answers, correctIndex);
  32. }
  33. #endif //TEST