diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index 6ca56f7..0570655 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -28,6 +28,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ *done = true; } else{ - *done = false; + if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){ + wegsuchen(laby, done, y + 1, x, ziely, zielx); + } } } \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index ee0a2bd..1fb675b 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -54,14 +54,14 @@ void test_LabyrinthAmZielAngekommen(void){ void test_LabyrinthAmZielNichtAngekommen(void){ - bool result; + bool result = 0; int input = 1; int hoehe = 3; int breite = 3; lab laby = { - {'1', '2', '3'}, - {'4', '5', '6'}, - {'7', '8', '9'}, + {'0', '1', '1'}, + {'1', '0', '1'}, + {'1', '1', '1'}, }; wegsuchen(laby, &result, 1, 1, 0, 0); @@ -90,6 +90,25 @@ void test_LabyrinthMarkiert(void){ TEST_ASSERT_EQUAL_CHAR('X', result); +} + +void test_LabyrinthUnten(void){ + + bool result; + int input = 1; + int hoehe = 3; + int breite = 3; + lab laby = { + {'0', '1', '1'}, + {'0', '1', '1'}, + {'0', '1', '1'}, + }; + + wegsuchen(laby, &result, 0, 0, 2, 0); + printlabyrinth(laby, hoehe, breite); + TEST_ASSERT_EQUAL_INT(1, result); + + } #endif // TEST \ No newline at end of file