From e294af735da1120724adf656f0e2504b34e1b0bf Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 03:57:26 +0100 Subject: [PATCH] added setItemShopAvailable with test --- src/c/items.c | 5 +++++ src/c/items.h | 2 +- test/c/test_items.c | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/c/items.c b/src/c/items.c index 801c49b..e44fdbc 100644 --- a/src/c/items.c +++ b/src/c/items.c @@ -70,3 +70,8 @@ int getItemShopAvailable(Item *item) { return item->inShopAvailable; } + +void setItemShopAvailable(Item *item, bool value) +{ + item->inShopAvailable = value; +} \ No newline at end of file diff --git a/src/c/items.h b/src/c/items.h index 68fa410..3d56b65 100644 --- a/src/c/items.h +++ b/src/c/items.h @@ -16,10 +16,10 @@ typedef struct Item *getItems(char *itemsMapFile); - int getItemPrice(Item *item); void setItemPrice(Item *item, int price); int getItemShopAvailable(Item *item); +void setItemShopAvailable(Item *item, bool value); #endif \ No newline at end of file diff --git a/test/c/test_items.c b/test/c/test_items.c index 8904fe1..8083d3b 100644 --- a/test/c/test_items.c +++ b/test/c/test_items.c @@ -89,6 +89,21 @@ void test_getItemShopAvailable(void) TEST_ASSERT_EQUAL(value, result); } +void test_setItemShopAvailable(void) +{ + // arrange + bool value = true, result; + + // act + Item test; + setItemShopAvailable(&test, value); + result = test.inShopAvailable; + //output + printf("setItemShopAvailable | value should be: %d -> is: %d", value, result); + + // assert + TEST_ASSERT_EQUAL(value, result); +} #endif // TEST