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.

44 lines
1.8 KiB

11 months ago
11 months ago
11 months ago
  1. #ifdef TEST
  2. #include <stdlib.h>
  3. #include "unity.h"
  4. #include "quizduell.h"
  5. void setUp(void) {}
  6. void tearDown(void) {}
  7. void test_erstelleFrage(void) {
  8. QuizFrage testFrage = erstelleFrage("Testfrage", "AntwortA", "AntwortB", "AntwortC", "AntwortD", 'A');
  9. TEST_ASSERT_EQUAL_STRING("Testfrage", testFrage.frage);
  10. TEST_ASSERT_EQUAL_STRING("AntwortA", testFrage.antwortA);
  11. TEST_ASSERT_EQUAL_STRING("AntwortB", testFrage.antwortB);
  12. TEST_ASSERT_EQUAL_STRING("AntwortC", testFrage.antwortC);
  13. TEST_ASSERT_EQUAL_STRING("AntwortD", testFrage.antwortD);
  14. TEST_ASSERT_EQUAL_CHAR('A', testFrage.korrekteAntwort);
  15. }
  16. void test_CookingFragen(void) {
  17. Kategorie kategorien[MAX_CATEGORIES];
  18. kategorien[1].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage));
  19. kategorien[1].fragen[0] = erstelleFrage("Which Ingredient is used traditionally for Pesto?", "Tomatoes", "Basil", "Spinach", "Oregano", 'B');
  20. kategorien[1].fragen[1] = erstelleFrage("Which meal is known for its usage of rice?", "Lasagna", "Sushi", "Pizza", "Hamburger", 'B');
  21. kategorien[1].fragen[2] = erstelleFrage("Which color has a ripe banana?", "Red", "Green", "Yellow", "Orange", 'C');
  22. kategorien[1].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY;
  23. kategorien[1].joker = 1;
  24. TEST_ASSERT_EQUAL_STRING("Which Ingredient is used traditionally for Pesto?", kategorien[1].fragen[0].frage);
  25. TEST_ASSERT_EQUAL_STRING("Tomatoes", kategorien[1].fragen[0].antwortA);
  26. TEST_ASSERT_EQUAL_STRING("Basil", kategorien[1].fragen[0].antwortB);
  27. TEST_ASSERT_EQUAL_STRING("Spinach", kategorien[1].fragen[0].antwortC);
  28. TEST_ASSERT_EQUAL_STRING("Oregano", kategorien[1].fragen[0].antwortD);
  29. TEST_ASSERT_EQUAL_CHAR('B', kategorien[1].fragen[0].korrekteAntwort);
  30. free(kategorien[1].fragen);
  31. }
  32. #endif //TEST