From bc7ba1d0a6a908e426e91b52bea930e80309cf29 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 18:51:52 +0100 Subject: [PATCH] =?UTF-8?q?Implementation=20der=20Tests=20f=C3=BCr=20den?= =?UTF-8?q?=20Testfall=20'Verloren'=20+=20Korrektur=20im=20Produktivcode?= =?UTF-8?q?=20bei=20der=20Ergebnisberechnung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/SchereSteinPapier.c | 4 ++-- src/test/c/Tim/test_SchereSteinPapier.c | 27 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/c/Tim/SchereSteinPapier.c b/src/main/c/Tim/SchereSteinPapier.c index 6862522..3b71014 100644 --- a/src/main/c/Tim/SchereSteinPapier.c +++ b/src/main/c/Tim/SchereSteinPapier.c @@ -70,9 +70,9 @@ int calculateWinner(int x, int y) } case(3): switch (y) { - case(1): return 1; + case(1): return -1; - case(2): return -1; + case(2): return 1; case(3): return 0; diff --git a/src/test/c/Tim/test_SchereSteinPapier.c b/src/test/c/Tim/test_SchereSteinPapier.c index 5a65733..6707100 100644 --- a/src/test/c/Tim/test_SchereSteinPapier.c +++ b/src/test/c/Tim/test_SchereSteinPapier.c @@ -35,5 +35,32 @@ void test_drawPaperPaper() int actualResult = calculateWinner(3,3); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Scissor_COM_Rock() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(1,2); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Paper_COM_Scissor() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(3,1); + + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_lose_USER_Rock_COM_Paper() +{ + int expectedResult = -1; + + int actualResult = calculateWinner(2,3); + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } \ No newline at end of file