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