From ebbe703493be84a50a2dfab4777b1bd59d41065b Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:01:01 +0100 Subject: [PATCH] added setRoomSuccessor with test --- src/c/map.c | 4 ++++ src/c/map.h | 2 +- test/c/test_map.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/c/map.c b/src/c/map.c index fef25b3..eb67707 100644 --- a/src/c/map.c +++ b/src/c/map.c @@ -62,3 +62,7 @@ Room *getMap(char *gameMapFile) int getRoomSuccessor(Room *room){ return room->successor; } + +void setRoomSuccessor(Room *room, int successorSet){ + room->successor = successorSet; +} diff --git a/src/c/map.h b/src/c/map.h index d91b417..e26284b 100644 --- a/src/c/map.h +++ b/src/c/map.h @@ -28,7 +28,7 @@ Room *getMap(char *gameMapFile); int getRoomSuccessor(Room *room); - +void setRoomSuccessor(Room *room, int successorSet); diff --git a/test/c/test_map.c b/test/c/test_map.c index 5db052e..337a247 100644 --- a/test/c/test_map.c +++ b/test/c/test_map.c @@ -63,6 +63,23 @@ void test_getRoomSuccessor(void) TEST_ASSERT_EQUAL(successor, result); } +void test_setRoomSuccessor(void) +{ + // arrange + int successor = 2, result; + + // act + Room test; + setRoomSuccessor(&test, successor); + result = test.successor; + + //output + printf("setRoomSuccessor | successor to set: %d -> is: %d", successor, result); + + // assert + TEST_ASSERT_EQUAL(successor, result); +} + #endif // TEST