Browse Source

added setRoomShopAvailable with test

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

10
src/c/map.c

@ -78,3 +78,13 @@ void setRoomPredecessor(Room *room, int predecessorSet)
{ {
room->predecessor = predecessorSet; room->predecessor = predecessorSet;
} }
bool getRoomShopAvailable(Room *room)
{
return room->shopAvailable;
}
void setRoomShopAvailable(Room *room, bool shopAvailableSet)
{
room->shopAvailable = shopAvailableSet;
}

3
src/c/map.h

@ -33,4 +33,7 @@ void setRoomSuccessor(Room *room, int successorSet);
int getRoomPredecessor(Room *room); int getRoomPredecessor(Room *room);
void setRoomPredecessor(Room *room, int predecessorSet); void setRoomPredecessor(Room *room, int predecessorSet);
bool getRoomShopAvailable(Room *room);
void setRoomShopAvailable(Room *room, bool shopAvailableSet);
#endif // MAP_H #endif // MAP_H

34
test/c/test_map.c

@ -115,5 +115,39 @@ void test_setRoomPredecessor(void)
TEST_ASSERT_EQUAL(predecessor, result); TEST_ASSERT_EQUAL(predecessor, result);
} }
void test_getRoomShopAvailable(void)
{
// arrange
bool available = true, result;
Room test;
test.shopAvailable = available;
/* act */
// Die Funktion wird ausgeführt
result = getRoomShopAvailable(&test);
// output
printf("getRoomShopAvailable | shopAvailable should be: %d -> is: %d", available, result);
// assert
TEST_ASSERT_EQUAL(available, result);
}
void test_setRoomShopAvailable(void)
{
// arrange
bool available = true, result;
// act
Room test;
setRoomShopAvailable(&test, available);
result = test.shopAvailable;
//output
printf("setRoomShopAvailable | shopAvailable set to: %d -> after set: %d", available, result);
// assert
TEST_ASSERT_EQUAL(available, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save