Browse Source

added getItemShopAvailable with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
6ce6fced5a
  1. 11
      src/c/items.c
  2. 2
      src/c/items.h
  3. 19
      test/c/test_items.c

11
src/c/items.c

@ -46,7 +46,7 @@ Item *getItems(char *itemsMapFile)
Item i; Item i;
i.id = atoi(arr[0]); i.id = atoi(arr[0]);
strcpy(i.itemName, arr[1]); strcpy(i.itemName, arr[1]);
//printf(arr[2]);
// printf(arr[2]);
i.price = atoi(arr[3]); i.price = atoi(arr[3]);
getItems[lineCounter] = i; getItems[lineCounter] = i;
@ -61,7 +61,12 @@ int getItemPrice(Item *item)
return item->price; return item->price;
} }
void setItemPrice(Item* item, int price)
void setItemPrice(Item *item, int price)
{ {
item->price = price;
item->price = price;
}
int getItemShopAvailable(Item *item)
{
return item->inShopAvailable;
} }

2
src/c/items.h

@ -20,6 +20,6 @@ Item *getItems(char *itemsMapFile);
int getItemPrice(Item *item); int getItemPrice(Item *item);
void setItemPrice(Item *item, int price); void setItemPrice(Item *item, int price);
int getItemShopAvailable(Item *item);
#endif #endif

19
test/c/test_items.c

@ -72,4 +72,23 @@ void test_getItemPrice(void)
TEST_ASSERT_EQUAL(price, result); TEST_ASSERT_EQUAL(price, result);
} }
void test_getItemShopAvailable(void)
{
// arrange
bool value = true, result;
// act
Item test;
test.inShopAvailable = value;
result = getItemShopAvailable(&test);
//output
printf("getItemShopAvailable | value should be: %d -> is: %d", value, result);
// assert
TEST_ASSERT_EQUAL(value, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save