Browse Source

added getAvailable (canBeUsed) with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
766ac86c7e
  1. 5
      src/c/weapon.c
  2. 3
      src/c/weapon.h
  3. 18
      test/c/test_weapon.c

5
src/c/weapon.c

@ -48,4 +48,9 @@ int getBaseDamage(Weapon *weapon)
void setBaseDamage(Weapon *weapon, int baseDmgSet)
{
weapon->baseDamage = baseDmgSet;
}
bool getAvailable(Weapon *weapon)
{
return weapon->canBeUsed;
}

3
src/c/weapon.h

@ -35,4 +35,7 @@ void setDamageModifier(Weapon *weapon, int modifierSet);
int getBaseDamage(Weapon *weapon);
void setBaseDamage(Weapon *weapon, int baseDmgSet);
bool getAvailable(Weapon *weapon);
#endif

18
test/c/test_weapon.c

@ -186,4 +186,22 @@ void test_setBaseDamage(void)
TEST_ASSERT_EQUAL(baseDamage, result);
}
void test_getAvailable(void)
{
// arrange
bool canBeUsed = true, result;
Weapon test;
test.canBeUsed = canBeUsed;
/* act */
// Die Funktion wird ausgeführt
result = getAvailable(&test);
// output
printf("getAvailable | canBeUsed should be: %d -> is: %d", canBeUsed, result);
// assert
TEST_ASSERT_EQUAL(canBeUsed, result);
}
#endif // TEST
Loading…
Cancel
Save