Browse Source

added getRoomSuccessor with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
573504153c
  1. 6
      src/c/map.c
  2. 6
      src/c/map.h
  3. 28
      test/c/test_map.c

6
src/c/map.c

@ -57,4 +57,8 @@ Room *getMap(char *gameMapFile)
fclose(stream); /* closing file */
return fillMap;
};
};
int getRoomSuccessor(Room *room){
return room->successor;
}

6
src/c/map.h

@ -26,4 +26,10 @@ typedef struct Room
Room *getMap(char *gameMapFile);
int getRoomSuccessor(Room *room);
#endif // MAP_H

28
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
Loading…
Cancel
Save