From c485a3c87bc6d7a8ab0b3470160913d4edff25bf Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 11:41:30 +0100 Subject: [PATCH] =?UTF-8?q?if=20Anweisung=20nach=20links=20hinzugef=C3=BCg?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 4 ++++ src/c/labyrinth.h | 4 ++-- test/c/test_labyrinth.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 410dce2..f791a7f 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -37,5 +37,9 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ if (!*done && y - 1 >= 0 && laby[y-1][x] == '0'){ // oben wegsuchen(laby, done, y - 1, x, ziely, zielx); } + if (!*done && x - 1 >= 0 && laby[y][x-1] == '0'){ // links + wegsuchen(laby, done, y, x - 1, ziely, zielx); + } + } } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 146fffb..3d71f1e 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -3,8 +3,8 @@ #include -#define MAXZEILEN 5 -#define MAXSPALTEN 5 +#define MAXZEILEN 10 +#define MAXSPALTEN 10 typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index f2d1e80..369501e 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -148,4 +148,24 @@ void test_LabyrinthOben(void){ TEST_ASSERT_EQUAL_INT(1, result); } + +void test_LabyrinthLinks(void){ + + bool result; + int input = 1; + int hoehe = 5; + int breite = 6; + lab laby = { + {'0', '1', '0', '0', '0', '0'}, + {'0', '1', '0', '1', '1', '0'}, + {'0', '1', '0', '0', '1', '0'}, + {'0', '1', '1', '0', '1', '0'}, + {'0', '0', '0', '0', '1', '0'}, + }; + + wegsuchen(laby, &result, 0, 0, 4, 5); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); +} + #endif // TEST \ No newline at end of file