diff --git a/src/c/map.c b/src/c/map.c index 83c3cdc..fef25b3 100644 --- a/src/c/map.c +++ b/src/c/map.c @@ -57,4 +57,8 @@ Room *getMap(char *gameMapFile) fclose(stream); /* closing file */ return fillMap; -}; \ No newline at end of file +}; + +int getRoomSuccessor(Room *room){ + return room->successor; +} diff --git a/src/c/map.h b/src/c/map.h index dd31690..d91b417 100644 --- a/src/c/map.h +++ b/src/c/map.h @@ -26,4 +26,10 @@ typedef struct Room Room *getMap(char *gameMapFile); + +int getRoomSuccessor(Room *room); + + + + #endif // MAP_H \ No newline at end of file diff --git a/test/c/test_map.c b/test/c/test_map.c index dcda939..5db052e 100644 --- a/test/c/test_map.c +++ b/test/c/test_map.c @@ -4,8 +4,10 @@ #include "map.h" #include "nav_helper.h" + void setUp(void) { + } void tearDown(void) @@ -16,13 +18,14 @@ void test_map(void) { /* arrange */ // Hier die Werte eingeben - Room* map; + Room *map; /* act */ // Die Funktion wird ausgeführt map = getMap("./src/content/game.map"); - for(int i=0; i<4;i++){ + for (int i = 0; i < 4; i++) + { printf("%s\n", map[i].nameRoom); } @@ -41,4 +44,25 @@ void test_map(void) TEST_ASSERT_EQUAL_INT(fdExpectedID, map[2].id); } +void test_getRoomSuccessor(void) +{ + // arrange + int successor = 1, result; + Room test; + test.successor = successor; + + /* act */ + // Die Funktion wird ausgeführt + result = getRoomSuccessor(&test); + + // output + printf("---------------------------------------------------------\n"); + printf("getRoomSuccessor | Successor should be: %d -> is: %d", successor, result); + + // assert + TEST_ASSERT_EQUAL(successor, result); +} + + + #endif // TEST