diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 3b71014..12b9735 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -43,7 +43,9 @@ void schereSteinPapier() } } - +//Berechnung,welche Auswahl gewinnt. +//@return: 0 = unentschieden; 1 = gewonnen; -1 = verloren; 3 = Fehler bei der Wertübergabe +//@param x = UserChoice; y = COMChoice int calculateWinner(int x, int y) { switch (x) @@ -78,5 +80,7 @@ int calculateWinner(int x, int y) default: return 3; } + default: return 3; } + } \ No newline at end of file diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index bbe81fe..2b1d348 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -1,5 +1,6 @@ #include "SchereSteinPapier.h" #include "unity.h" +#include void setUp(void) { @@ -88,5 +89,42 @@ void test_Win_USER_Paper_COM_Rock() int actualResult = calculateWinner(3,2); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + + +void test_USER_unknownParameter_Rock_randomChoice() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(5,rand() % 3 + 1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_randomChoice_Rock_unknownParameter() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(rand() % 3 + 1, 5); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_randomChoice_Rock_zero() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(rand() % 3 + 1, 0); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_USER_zero_Rock_randomChoice() +{ + int expectedResult = 3; + + int actualResult = calculateWinner(0, rand() % 3 + 1); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file