Browse Source

Unittest Struktur und 1. Unittest

remotes/origin/Pascal
Pascal Schneider 11 months ago
parent
commit
98df4cfb40
  1. 47
      build/test/cache/test_timequiz.c
  2. 5
      build/test/dependencies/test_timequiz.d
  3. BIN
      build/test/out/c/test_timequiz.o
  4. BIN
      build/test/out/c/test_timequiz_runner.o
  5. BIN
      build/test/out/c/timequiz.o
  6. BIN
      build/test/out/test_timequiz.out
  7. 47
      build/test/preprocess/files/test_timequiz.c
  8. 4
      build/test/preprocess/includes/test_timequiz.c
  9. 2
      build/test/results/test_casualQuiz.pass
  10. 2
      build/test/results/test_quizduell.pass
  11. 12
      build/test/results/test_timequiz.pass
  12. 2
      build/test/results/test_wwm.pass
  13. 36
      build/test/runners/test_timequiz_runner.c
  14. 27
      test/test_timequiz.c

47
build/test/cache/test_timequiz.c

@ -0,0 +1,47 @@
#include "src/timequiz.h"
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
void setUp(void) {
}
void tearDown(void) {
}
void test_getRandomQuestionIndex(void) {
int askedQuestions[10] = {0};
int totalQuestions = 10;
int index = getRandomQuestionIndex(askedQuestions, totalQuestions);
do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0);
}

5
build/test/dependencies/test_timequiz.d

@ -1 +1,4 @@
build/test/out/c/test_timequiz.o: test/test_timequiz.c
build/test/out/c/test_timequiz.o: test/test_timequiz.c \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \
src/timequiz.h

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

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

@ -0,0 +1,47 @@
#include "src/timequiz.h"
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
void setUp(void) {
}
void tearDown(void) {
}
void test_getRandomQuestionIndex(void) {
int askedQuestions[10] = {0};
int totalQuestions = 10;
int index = getRandomQuestionIndex(askedQuestions, totalQuestions);
do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0);
}

4
build/test/preprocess/includes/test_timequiz.c

@ -1 +1,3 @@
--- []
---
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h
- src/timequiz.h

2
build/test/results/test_casualQuiz.pass

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

2
build/test/results/test_quizduell.pass

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

12
build/test/results/test_timequiz.pass

@ -2,13 +2,17 @@
:source:
:path: test
:file: test_timequiz.c
:successes: []
:successes:
- :test: test_getRandomQuestionIndex
:line: 16
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 0
:passed: 0
:total: 1
:passed: 1
:failed: 0
:ignored: 0
:stdout: []
:time: 0.014682400000310736
:time: 0.02380760000050941

2
build/test/results/test_wwm.pass

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

36
build/test/runners/test_timequiz_runner.c

@ -10,6 +10,7 @@ char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_getRandomQuestionIndex(void);
/*=======Mock Management=====*/
@ -26,12 +27,6 @@ static void CMock_Destroy(void)
{
}
/*=======Setup (stub)=====*/
void setUp(void) {}
/*=======Teardown (stub)=====*/
void tearDown(void) {}
/*=======Test Reset Options=====*/
void resetTest(void);
void resetTest(void)
@ -48,10 +43,39 @@ void verifyTest(void)
CMock_Verify();
}
/*=======Test Runner Used To Run Each Test=====*/
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)
{
Unity.CurrentTestName = name;
Unity.CurrentTestLineNumber = line_num;
#ifdef UNITY_USE_COMMAND_LINE_ARGS
if (!UnityTestMatches())
return;
#endif
Unity.NumberOfTests++;
UNITY_CLR_DETAILS();
UNITY_EXEC_TIME_START();
CMock_Init();
if (TEST_PROTECT())
{
setUp();
func();
}
if (TEST_PROTECT())
{
tearDown();
CMock_Verify();
}
CMock_Destroy();
UNITY_EXEC_TIME_STOP();
UnityConcludeTest();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("test_timequiz.c");
run_test(test_getRandomQuestionIndex, "test_getRandomQuestionIndex", 16);
return UnityEnd();
}

27
test/test_timequiz.c

@ -0,0 +1,27 @@
#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);
}
#endif //TEST
Loading…
Cancel
Save