diff --git a/build/test/cache/defines_dependency.yml b/build/test/cache/defines_dependency.yml index 276aae5..a81d8fc 100644 --- a/build/test/cache/defines_dependency.yml +++ b/build/test/cache/defines_dependency.yml @@ -5,3 +5,5 @@ src/minirechner.c: - TEST src/zahlenraten.c: - TEST +src/SchereSteinPapier.c: +- TEST diff --git a/build/test/cache/test_SchereSteinPapier.c b/build/test/cache/test_SchereSteinPapier.c new file mode 100644 index 0000000..a1c62af --- /dev/null +++ b/build/test/cache/test_SchereSteinPapier.c @@ -0,0 +1,43 @@ +#include "src/SchereSteinPapier.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_Scheresteinpapier_generateRandom(void) { + + + + srand(42); + + + + for (int i = 0; i < 100; ++i) { + + int result = generateRandom(); + + do {if ((result >= 0 && result <= 2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0); + + } + +} diff --git a/build/test/dependencies/SchereSteinPapier.d b/build/test/dependencies/SchereSteinPapier.d new file mode 100644 index 0000000..83e9bd7 --- /dev/null +++ b/build/test/dependencies/SchereSteinPapier.d @@ -0,0 +1,2 @@ +build/test/out/c/SchereSteinPapier.o: src/SchereSteinPapier.c \ + src/SchereSteinPapier.h diff --git a/build/test/dependencies/test_SchereSteinPapier.d b/build/test/dependencies/test_SchereSteinPapier.d new file mode 100644 index 0000000..f88fdf7 --- /dev/null +++ b/build/test/dependencies/test_SchereSteinPapier.d @@ -0,0 +1,4 @@ +build/test/out/c/test_SchereSteinPapier.o: test/test_SchereSteinPapier.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/SchereSteinPapier.h diff --git a/build/test/dependencies/test_SchereSteinPapier_runner.d b/build/test/dependencies/test_SchereSteinPapier_runner.d new file mode 100644 index 0000000..623b8b2 --- /dev/null +++ b/build/test/dependencies/test_SchereSteinPapier_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_SchereSteinPapier_runner.o: \ + build/test/runners/test_SchereSteinPapier_runner.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 diff --git a/build/test/out/c/SchereSteinPapier.o b/build/test/out/c/SchereSteinPapier.o new file mode 100644 index 0000000..dc33abe Binary files /dev/null and b/build/test/out/c/SchereSteinPapier.o differ diff --git a/build/test/out/c/test_SchereSteinPapier.o b/build/test/out/c/test_SchereSteinPapier.o new file mode 100644 index 0000000..5b69bb8 Binary files /dev/null and b/build/test/out/c/test_SchereSteinPapier.o differ diff --git a/build/test/out/c/test_SchereSteinPapier_runner.o b/build/test/out/c/test_SchereSteinPapier_runner.o new file mode 100644 index 0000000..a3c117c Binary files /dev/null and b/build/test/out/c/test_SchereSteinPapier_runner.o differ diff --git a/build/test/out/test_SchereSteinPapier.out b/build/test/out/test_SchereSteinPapier.out new file mode 100644 index 0000000..c3e9f54 Binary files /dev/null and b/build/test/out/test_SchereSteinPapier.out differ diff --git a/build/test/out/test_ageinseconds.out b/build/test/out/test_ageinseconds.out index c56e3fe..56606b6 100644 Binary files a/build/test/out/test_ageinseconds.out and b/build/test/out/test_ageinseconds.out differ diff --git a/build/test/out/test_minirechner.out b/build/test/out/test_minirechner.out index 09ee708..e3a27d6 100644 Binary files a/build/test/out/test_minirechner.out and b/build/test/out/test_minirechner.out differ diff --git a/build/test/out/test_zahlenraten.out b/build/test/out/test_zahlenraten.out index 557c303..0417dd4 100644 Binary files a/build/test/out/test_zahlenraten.out and b/build/test/out/test_zahlenraten.out differ diff --git a/build/test/preprocess/files/test_SchereSteinPapier.c b/build/test/preprocess/files/test_SchereSteinPapier.c new file mode 100644 index 0000000..a1c62af --- /dev/null +++ b/build/test/preprocess/files/test_SchereSteinPapier.c @@ -0,0 +1,43 @@ +#include "src/SchereSteinPapier.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_Scheresteinpapier_generateRandom(void) { + + + + srand(42); + + + + for (int i = 0; i < 100; ++i) { + + int result = generateRandom(); + + do {if ((result >= 0 && result <= 2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0); + + } + +} diff --git a/build/test/preprocess/includes/test_SchereSteinPapier.c b/build/test/preprocess/includes/test_SchereSteinPapier.c new file mode 100644 index 0000000..1bb5f0e --- /dev/null +++ b/build/test/preprocess/includes/test_SchereSteinPapier.c @@ -0,0 +1,3 @@ +--- +- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h +- src/SchereSteinPapier.h diff --git a/build/test/results/test_SchereSteinPapier.pass b/build/test/results/test_SchereSteinPapier.pass new file mode 100644 index 0000000..df998a3 --- /dev/null +++ b/build/test/results/test_SchereSteinPapier.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test + :file: test_SchereSteinPapier.c +:successes: +- :test: test_Scheresteinpapier_generateRandom + :line: 15 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.03652950000105193 diff --git a/build/test/results/test_ageinseconds.pass b/build/test/results/test_ageinseconds.pass index fffdc3a..a921d54 100644 --- a/build/test/results/test_ageinseconds.pass +++ b/build/test/results/test_ageinseconds.pass @@ -23,4 +23,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.8361497999994754 +:time: 0.03658220000033907 diff --git a/build/test/results/test_minirechner.pass b/build/test/results/test_minirechner.pass index 7e7a215..89514e2 100644 --- a/build/test/results/test_minirechner.pass +++ b/build/test/results/test_minirechner.pass @@ -83,4 +83,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.33068490000005113 +:time: 0.03659530000004452 diff --git a/build/test/results/test_zahlenraten.pass b/build/test/results/test_zahlenraten.pass index 15fdbb1..a5a6eda 100644 --- a/build/test/results/test_zahlenraten.pass +++ b/build/test/results/test_zahlenraten.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.31757349999952567 +:time: 0.03663650000089547 diff --git a/build/test/runners/test_SchereSteinPapier_runner.c b/build/test/runners/test_SchereSteinPapier_runner.c new file mode 100644 index 0000000..6583e72 --- /dev/null +++ b/build/test/runners/test_SchereSteinPapier_runner.c @@ -0,0 +1,81 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_Scheresteinpapier_generateRandom(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +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_SchereSteinPapier.c"); + run_test(test_Scheresteinpapier_generateRandom, "test_Scheresteinpapier_generateRandom", 15); + + return UnityEnd(); +} diff --git a/src/SchereSteinPapier.h b/src/SchereSteinPapier.h index ca588ce..4d4c26e 100644 --- a/src/SchereSteinPapier.h +++ b/src/SchereSteinPapier.h @@ -2,5 +2,6 @@ #define SCHERESTEINPAPIER_H int generateRandom(); +int determineWinner(int spielerWahl, int computerWahl); #endif // SCHERESTEINPAPIER_H diff --git a/test/test_SchereSteinPapier.c b/test/test_SchereSteinPapier.c index 4273d92..aa5b429 100644 --- a/test/test_SchereSteinPapier.c +++ b/test/test_SchereSteinPapier.c @@ -22,4 +22,26 @@ void test_Scheresteinpapier_generateRandom(void) { } } +void test_Scheresteinpapier_determineWinner(void) { + + for (int spieler = 0; spieler <= 2; ++spieler) { + for (int computer = 0; computer <= 2; ++computer) { + int result = determineWinner(spieler, computer); + + + if ((spieler == 0 && computer == 2) || + (spieler == 1 && computer == 0) || + (spieler == 2 && computer == 1)) { + TEST_ASSERT_EQUAL(1, result); // Spieler gewinnt + } + else if (spieler == computer) { + TEST_ASSERT_EQUAL(0, result); // Unentschieden + } + else { + TEST_ASSERT_EQUAL(-1, result); // Computer gewinnt + } + } + } +} + #endif // TEST