Browse Source

2. Unittest

remotes/origin/Pascal
Pascal Schneider 11 months ago
parent
commit
74423aecd4
  1. 28
      build/test/cache/test_timequiz.c
  2. BIN
      build/test/out/c/test_timequiz.o
  3. BIN
      build/test/out/c/test_timequiz_runner.o
  4. BIN
      build/test/out/c/timequiz.o
  5. BIN
      build/test/out/test_timequiz.out
  6. 28
      build/test/preprocess/files/test_timequiz.c
  7. 2
      build/test/results/test_casualQuiz.pass
  8. 2
      build/test/results/test_quizduell.pass
  9. 27
      build/test/results/test_timequiz.pass
  10. 2
      build/test/results/test_wwm.pass
  11. 2
      build/test/runners/test_timequiz_runner.c
  12. 14
      test/test_timequiz.c

28
build/test/cache/test_timequiz.c

@ -45,3 +45,31 @@ void test_getRandomQuestionIndex(void) {
do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0);
}
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);
}

BIN
build/test/out/c/test_timequiz.o

BIN
build/test/out/c/test_timequiz_runner.o

BIN
build/test/out/c/timequiz.o

BIN
build/test/out/test_timequiz.out

28
build/test/preprocess/files/test_timequiz.c

@ -45,3 +45,31 @@ void test_getRandomQuestionIndex(void) {
do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0);
}
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);
}

2
build/test/results/test_casualQuiz.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.014249100000597537
:time: 0.01952290000008361

2
build/test/results/test_quizduell.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.0164414000000761
:time: 0.016257900000709924

27
build/test/results/test_timequiz.pass

@ -7,12 +7,31 @@
:line: 16
:message: ''
:unity_test_time: 0
- :test: test_displayQuestion
:line: 27
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 1
:passed: 1
:total: 2
:passed: 2
:failed: 0
:ignored: 0
:stdout: []
:time: 0.02380760000050941
:stdout:
- ''
- 'Expected Output:'
- 'Question: Test Question'
- 1. A
- 2. B
- 3. C
- 4. D
- ''
- 'Actual Output:'
- ''
- 'Question: Test Question'
- 1. A
- 2. B
- 3. C
- 4. D
:time: 0.03188090000003285

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.014939400000002934
:time: 0.016452499999104475

2
build/test/runners/test_timequiz_runner.c

@ -11,6 +11,7 @@ char* GlobalOrderError;
extern void setUp(void);
extern void tearDown(void);
extern void test_getRandomQuestionIndex(void);
extern void test_displayQuestion(void);
/*=======Mock Management=====*/
@ -76,6 +77,7 @@ int main(void)
{
UnityBegin("test_timequiz.c");
run_test(test_getRandomQuestionIndex, "test_getRandomQuestionIndex", 16);
run_test(test_displayQuestion, "test_displayQuestion", 27);
return UnityEnd();
}

14
test/test_timequiz.c

@ -24,4 +24,18 @@ void test_getRandomQuestionIndex(void) {
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
Loading…
Cancel
Save