Browse Source

added setTotal with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
11d7f06b92
  1. 7
      src/c/player.c
  2. 5
      src/c/player.h
  3. 22
      test/c/test_player.c

7
src/c/player.c

@ -51,6 +51,13 @@ Player removeItemFromInventory(int itemIndex, Player actualPlayer)
return actualPlayer;
}
//currency
Player setTotal(Player actualPlayer, int value)
{
actualPlayer.wallet = value;
return actualPlayer;
}
//show
void showInventory(Player actualPlayer)
{

5
src/c/player.h

@ -11,9 +11,14 @@ typedef struct
int wallet;
} Player;
//add and remove items
Player addItemToInventory(Item *availableItem, int itemIndex, Player actualPlayer);
Player removeItemFromInventory(int index, Player actualPlayer);
//currency
Player setTotal(Player actualPlayer, int value);
//show
void showInventory(Player actualPlayer);
#endif

22
test/c/test_player.c

@ -44,10 +44,32 @@ void test_removeItemFromInventory(void)
Item itemAfterRemove = actualPlayer.itemInventory[0];
// OUTPUT
printf("removeItem | ID_before: %d -> ID_after: %d", itemBeforeRemove.id, itemAfterRemove.id);
/* assert */
// Vergleichen mit Inhalt von game.Map File
TEST_ASSERT_NOT_EQUAL_UINT8(itemBeforeRemove.id, itemAfterRemove.id);
}
void test_setTotal(void)
{
/* arrange */
// Hier die Werte eingeben/deklarieren
int setMoney = 100;
/* act */
// Die Funktion wird ausgeführt
int valueBefore = actualPlayer.wallet;
actualPlayer = setTotal(actualPlayer, setMoney);
int valueAfter = actualPlayer.wallet;
// OUTPUT
printf("setTotal | before: %d -> after: %d", valueBefore, valueAfter);
/* assert */
// Vergleichen mit Inhalt
TEST_ASSERT_EQUAL_INT(setMoney, actualPlayer.wallet);
TEST_ASSERT_NOT_EQUAL_UINT8(valueBefore, valueAfter);
}
#endif // TEST
Loading…
Cancel
Save