Browse Source

added setRoomPredecessor with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
2b6449f2a4
  1. 18
      src/c/map.c
  2. 3
      src/c/map.h
  3. 34
      test/c/test_map.c

18
src/c/map.c

@ -1,4 +1,4 @@
//headers
// headers
#include "map.h" #include "map.h"
Room *getMap(char *gameMapFile) Room *getMap(char *gameMapFile)
@ -59,10 +59,22 @@ Room *getMap(char *gameMapFile)
return fillMap; return fillMap;
}; };
int getRoomSuccessor(Room *room){
int getRoomSuccessor(Room *room)
{
return room->successor; return room->successor;
} }
void setRoomSuccessor(Room *room, int successorSet){
void setRoomSuccessor(Room *room, int successorSet)
{
room->successor = successorSet; room->successor = successorSet;
} }
int getRoomPredecessor(Room *room)
{
return room->predecessor;
}
void setRoomPredecessor(Room *room, int predecessorSet)
{
room->predecessor = predecessorSet;
}

3
src/c/map.h

@ -30,6 +30,7 @@ Room *getMap(char *gameMapFile);
int getRoomSuccessor(Room *room); int getRoomSuccessor(Room *room);
void setRoomSuccessor(Room *room, int successorSet); void setRoomSuccessor(Room *room, int successorSet);
int getRoomPredecessor(Room *room);
void setRoomPredecessor(Room *room, int predecessorSet);
#endif // MAP_H #endif // MAP_H

34
test/c/test_map.c

@ -80,6 +80,40 @@ void test_setRoomSuccessor(void)
TEST_ASSERT_EQUAL(successor, result); TEST_ASSERT_EQUAL(successor, result);
} }
void test_getRoomPredecessor(void)
{
// arrange
int predecessor = 1, result;
Room test;
test.predecessor = predecessor;
/* act */
// Die Funktion wird ausgeführt
result = getRoomPredecessor(&test);
// output
printf("getRoomPredecessor | Successor should be: %d -> is: %d", predecessor, result);
// assert
TEST_ASSERT_EQUAL(predecessor, result);
}
void test_setRoomPredecessor(void)
{
// arrange
int predecessor = 3, result;
// act
Room test;
setRoomPredecessor(&test, predecessor);
result = test.predecessor;
//output
printf("setRoomPredecessor | successor to set: %d -> is: %d", predecessor, result);
// assert
TEST_ASSERT_EQUAL(predecessor, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save