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