diff --git a/src/c/items.c b/src/c/items.c index 191051a..7f09bd5 100644 --- a/src/c/items.c +++ b/src/c/items.c @@ -55,3 +55,9 @@ Item *getItems(char *itemsMapFile) } return getItems; } + + +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 ed50446..143006f 100644 --- a/src/c/items.h +++ b/src/c/items.h @@ -17,4 +17,6 @@ typedef struct Item *getItems(char *itemsMapFile); +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 9fc3ce3..f9bf002 100644 --- a/test/c/test_items.c +++ b/test/c/test_items.c @@ -16,7 +16,7 @@ void test_items(void) { /* arrange */ // Hier die Werte eingeben/deklarieren - Item* items; + Item *items; int expectedItemID = 1; int expectedSecondItemID = 2; @@ -25,7 +25,8 @@ void test_items(void) items = getItems("./src/content/items.map"); /* make visible OUTPUT */ - for(int i=0; i<4;i++){ + for (int i = 0; i < 4; i++) + { printf("%s\n", items[i].itemName); } @@ -35,4 +36,21 @@ void test_items(void) TEST_ASSERT_EQUAL_INT(expectedSecondItemID, items[1].id); } +void test_setItemPrice(void) +{ + + // arrange + int price = 50, result; + // act + Item test; + setItemPrice(&test, price); + result = test.price; + + printf("---------------------------------------------------\n"); + printf("setItemPrice | price to set: %d -> item.price: %d", price, result); + + // assert + TEST_ASSERT_EQUAL(price, result); +} + #endif // TEST