From df3ed5c1b27ce3091d9887f75347d4e2c0bdc92d Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:26:27 +0100 Subject: [PATCH] =?UTF-8?q?if=20anweisung=20nach=20rechts=20hinzugef=C3=BC?= =?UTF-8?q?gt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 3 +++ test/c/test_labyrinth.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 0570655..c4cefe3 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -31,5 +31,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ wegsuchen(laby, done, y + 1, x, ziely, zielx); } + if (!*done && x + 1 <= zielx && laby[y][x+1] == '0'){ + wegsuchen(laby, done, y, x + 1, ziely, zielx); + } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 1fb675b..9b9448c 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -109,6 +109,25 @@ void test_LabyrinthUnten(void){ TEST_ASSERT_EQUAL_INT(1, result); +} + +void test_LabyrinthRechts(void){ + + bool result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'0', '0', '0'}, + {'1', '1', '1'}, + {'1', '1', '1'}, + }; + + wegsuchen(laby, &result, 0, 0, 0, 2); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); + + } #endif // TEST \ No newline at end of file