diff --git a/src/c/items.c b/src/c/items.c index 7f09bd5..1b223fa 100644 --- a/src/c/items.c +++ b/src/c/items.c @@ -56,8 +56,12 @@ Item *getItems(char *itemsMapFile) return getItems; } +int getItemPrice(Item *item) +{ + return item->price; +} void setItemPrice(Item* item, int price) { item->price = price; -} \ No newline at end of file +} diff --git a/src/c/items.h b/src/c/items.h index 143006f..0fa3740 100644 --- a/src/c/items.h +++ b/src/c/items.h @@ -2,7 +2,7 @@ #define ITEMS_H #define itemAttributesMax 4 // for items -#define maxItems 100 // for inventory/item list +#define maxItems 100 // for inventory/item list #include @@ -17,6 +17,9 @@ typedef struct Item *getItems(char *itemsMapFile); -void setItemPrice(Item* item, int price); +int getItemPrice(Item *item); +void setItemPrice(Item *item, int price); + + #endif \ No newline at end of file diff --git a/test/c/test_items.c b/test/c/test_items.c index f9bf002..bfd4439 100644 --- a/test/c/test_items.c +++ b/test/c/test_items.c @@ -38,14 +38,15 @@ void test_items(void) void test_setItemPrice(void) { - // arrange int price = 50, result; + // act Item test; setItemPrice(&test, price); result = test.price; + //output printf("---------------------------------------------------\n"); printf("setItemPrice | price to set: %d -> item.price: %d", price, result); @@ -53,4 +54,22 @@ void test_setItemPrice(void) TEST_ASSERT_EQUAL(price, result); } + +void test_getItemPrice(void) +{ + // arrange + int price = 50, result; + + // act + Item test; + test.price = price; + result = getItemPrice(&test); + + //output + printf("getItemPrice | price should be: %d -> price is: %d", price, result); + + // assert + TEST_ASSERT_EQUAL(price, result); +} + #endif // TEST