From 27d170b01f6f8626a5d5704babd9f1f1fad5bfeb Mon Sep 17 00:00:00 2001 From: Ronja Awe Date: Wed, 1 Feb 2023 10:53:08 +0100 Subject: [PATCH] =?UTF-8?q?return-typ=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/labyrinth.c | 7 +++---- src/c/labyrinth.h | 4 +++- test/c/test_labyrinth.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/c/labyrinth.c b/src/c/labyrinth.c index a5feb45..6ca56f7 100644 --- a/src/c/labyrinth.c +++ b/src/c/labyrinth.c @@ -20,15 +20,14 @@ int printlabyrinth(lab laby, int hoehe, int breite){ return 0; } -int wegsuchen(lab laby, int y, int x, int ziely, int zielx){ +void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx){ laby[y][x] = 'X'; if(x == zielx && y == ziely){ - return 0; + *done = true; } else{ - return -1; + *done = false; } - } \ No newline at end of file diff --git a/src/c/labyrinth.h b/src/c/labyrinth.h index 3d1ee01..146fffb 100644 --- a/src/c/labyrinth.h +++ b/src/c/labyrinth.h @@ -1,11 +1,13 @@ #ifndef LABYRINTH_H #define LABYRINTH_H +#include + #define MAXZEILEN 5 #define MAXSPALTEN 5 typedef char lab[MAXZEILEN][MAXSPALTEN]; int printlabyrinth(lab laby, int hoehe, int breite); -int wegsuchen(lab laby, int y, int x, int ziely, int zielx); +void wegsuchen(lab laby, bool* done, int y, int x, int ziely, int zielx); #endif \ No newline at end of file diff --git a/test/c/test_labyrinth.c b/test/c/test_labyrinth.c index 6f93168..a399512 100644 --- a/test/c/test_labyrinth.c +++ b/test/c/test_labyrinth.c @@ -2,6 +2,7 @@ #include "unity.h" //in example.h wird die Funktion deklariert #include "labyrinth.h" +#include //Vor- bzw. Nachbereitung void setUp(void) @@ -14,8 +15,7 @@ void tearDown(void) void test_runExampleTest(void) -{ - +{ int result; int input = 1; int hoehe = 3; @@ -36,7 +36,7 @@ void test_runExampleTest(void) void test_LabyrinthAmZiel(void){ - int result; + bool result; int input = 1; int hoehe = 3; int breite = 3; @@ -46,15 +46,15 @@ void test_LabyrinthAmZiel(void){ {'7', '8', '9'}, }; - result = wegsuchen(laby, 0, 0, 0, 0); - TEST_ASSERT_EQUAL_INT(0, result); + wegsuchen(laby, &result, 0, 0, 0, 0); + TEST_ASSERT_EQUAL_INT(1, result); } void test_LabyrinthAmZiel2(void){ - int result; + bool result; int input = 1; int hoehe = 3; int breite = 3; @@ -64,8 +64,8 @@ void test_LabyrinthAmZiel2(void){ {'7', '8', '9'}, }; - result = wegsuchen(laby, 1, 1, 0, 0); - TEST_ASSERT_EQUAL_INT(-1, result); + wegsuchen(laby, &result, 1, 1, 0, 0); + TEST_ASSERT_EQUAL_INT(0, result); } @@ -73,6 +73,7 @@ void test_LabyrinthAmZiel2(void){ void test_LabyrinthMarkiert(void){ char result; + bool du; int input = 1; int hoehe = 3; int breite = 3; @@ -83,7 +84,7 @@ void test_LabyrinthMarkiert(void){ }; - wegsuchen(laby, 0, 0, 0, 0); + wegsuchen(laby, &du, 0, 0, 0, 0); result = laby[0][0]; printlabyrinth(laby, hoehe, breite); TEST_ASSERT_EQUAL_CHAR('X', result);