Browse Source

if anweisung nach unten hinzugefügt

remotes/origin/Labyrinth
Ronja Awe 2 years ago
parent
commit
84cbf04cf1
  1. 4
      src/c/labyrinth.c
  2. 27
      test/c/test_labyrinth.c

4
src/c/labyrinth.c

@ -28,6 +28,8 @@ void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){
*done = true; *done = true;
} }
else{ else{
*done = false;
if (!*done && y + 1 <= ziely && laby[y+1][x] == '0'){
wegsuchen(laby, done, y + 1, x, ziely, zielx);
}
} }
} }

27
test/c/test_labyrinth.c

@ -54,14 +54,14 @@ void test_LabyrinthAmZielAngekommen(void){
void test_LabyrinthAmZielNichtAngekommen(void){ void test_LabyrinthAmZielNichtAngekommen(void){
bool result;
bool result = 0;
int input = 1; int input = 1;
int hoehe = 3; int hoehe = 3;
int breite = 3; int breite = 3;
lab laby = { 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); wegsuchen(laby, &result, 1, 1, 0, 0);
@ -90,6 +90,25 @@ void test_LabyrinthMarkiert(void){
TEST_ASSERT_EQUAL_CHAR('X', result); 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 #endif // TEST
Loading…
Cancel
Save