diff --git a/build/test/cache/test_SchereSteinPapier.c b/build/test/cache/test_SchereSteinPapier.c index a1c62af..fa6927c 100644 --- a/build/test/cache/test_SchereSteinPapier.c +++ b/build/test/cache/test_SchereSteinPapier.c @@ -41,3 +41,59 @@ 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)) { + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + } + + else if (spieler == computer) { + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); + + } + + else { + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_INT); + + } + + } + + } + +} diff --git a/build/test/out/c/test_SchereSteinPapier.o b/build/test/out/c/test_SchereSteinPapier.o index 5b69bb8..070fe23 100644 Binary files a/build/test/out/c/test_SchereSteinPapier.o 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 index a3c117c..cf0b230 100644 Binary files a/build/test/out/c/test_SchereSteinPapier_runner.o 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 index c3e9f54..7cb45e2 100644 Binary files a/build/test/out/test_SchereSteinPapier.out and b/build/test/out/test_SchereSteinPapier.out differ diff --git a/build/test/preprocess/files/test_SchereSteinPapier.c b/build/test/preprocess/files/test_SchereSteinPapier.c index a1c62af..fa6927c 100644 --- a/build/test/preprocess/files/test_SchereSteinPapier.c +++ b/build/test/preprocess/files/test_SchereSteinPapier.c @@ -41,3 +41,59 @@ 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)) { + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + } + + else if (spieler == computer) { + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); + + } + + else { + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_INT); + + } + + } + + } + +} diff --git a/build/test/results/test_SchereSteinPapier.pass b/build/test/results/test_SchereSteinPapier.pass index df998a3..c55454e 100644 --- a/build/test/results/test_SchereSteinPapier.pass +++ b/build/test/results/test_SchereSteinPapier.pass @@ -7,12 +7,16 @@ :line: 15 :message: '' :unity_test_time: 0 +- :test: test_Scheresteinpapier_determineWinner + :line: 25 + :message: '' + :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 1 - :passed: 1 + :total: 2 + :passed: 2 :failed: 0 :ignored: 0 :stdout: [] -:time: 0.03652950000105193 +:time: 0.04412409999895317 diff --git a/build/test/results/test_ageinseconds.pass b/build/test/results/test_ageinseconds.pass index a921d54..b170330 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.03658220000033907 +:time: 0.040927000000010594 diff --git a/build/test/results/test_minirechner.pass b/build/test/results/test_minirechner.pass index 89514e2..8d85ca6 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.03659530000004452 +:time: 0.04142449999926612 diff --git a/build/test/results/test_zahlenraten.pass b/build/test/results/test_zahlenraten.pass index a5a6eda..b6451c0 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.03663650000089547 +:time: 0.04121030000169412 diff --git a/build/test/runners/test_SchereSteinPapier_runner.c b/build/test/runners/test_SchereSteinPapier_runner.c index 6583e72..7302e60 100644 --- a/build/test/runners/test_SchereSteinPapier_runner.c +++ b/build/test/runners/test_SchereSteinPapier_runner.c @@ -11,6 +11,7 @@ char* GlobalOrderError; extern void setUp(void); extern void tearDown(void); extern void test_Scheresteinpapier_generateRandom(void); +extern void test_Scheresteinpapier_determineWinner(void); /*=======Mock Management=====*/ @@ -76,6 +77,7 @@ int main(void) { UnityBegin("test_SchereSteinPapier.c"); run_test(test_Scheresteinpapier_generateRandom, "test_Scheresteinpapier_generateRandom", 15); + run_test(test_Scheresteinpapier_determineWinner, "test_Scheresteinpapier_determineWinner", 25); return UnityEnd(); } diff --git a/src/menue.c b/src/menue.c index cedd321..52199fe 100644 --- a/src/menue.c +++ b/src/menue.c @@ -4,6 +4,7 @@ int run_minirechner(); int run_ageinseconds(); int run_magiceightball(); void run_zahlenraten(); +int run_scheresteinpapier(); void trenner () { // Die laenge der Abtrenner kann hier fuer alle 3 angepasst werden @@ -16,7 +17,7 @@ int main() { while (eingabe != 0) { trenner(); - printf("\nWelches Programm wollen Sie starten?\n<1> Minirechner \n<2> AlterinSekunden\n<3> MagicEightBall\n<4> Zahlenraten\nZum Abbrechen 0 eingeben.\n"); + printf("\nWelches Programm wollen Sie starten?\n<1> Minirechner \n<2> AlterinSekunden\n<3> MagicEightBall\n<4> Zahlenraten\n<5> SchereSteinPapier\nZum Abbrechen 0 eingeben.\n"); trenner(); printf("\nEingabe: "); scanf("%d", &eingabe); @@ -43,6 +44,10 @@ int main() { case 4: run_zahlenraten(); break; + + case 5: + run_scheresteinpapier(); + break; default: printf("Bitte verwenden sie eine der gegebenen Ziffern");