Browse Source

added setAvailable (canBeUsed) with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
7617bb7f51
  1. 5
      src/c/weapon.c
  2. 2
      src/c/weapon.h
  3. 17
      test/c/test_weapon.c

5
src/c/weapon.c

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

2
src/c/weapon.h

@ -36,6 +36,6 @@ int getBaseDamage(Weapon *weapon);
void setBaseDamage(Weapon *weapon, int baseDmgSet); void setBaseDamage(Weapon *weapon, int baseDmgSet);
bool getAvailable(Weapon *weapon); bool getAvailable(Weapon *weapon);
void setAvailable(Weapon *weapon, bool availableSet);
#endif #endif

17
test/c/test_weapon.c

@ -204,4 +204,21 @@ void test_getAvailable(void)
TEST_ASSERT_EQUAL(canBeUsed, result); TEST_ASSERT_EQUAL(canBeUsed, result);
} }
void test_setAvailable(void)
{
// arrange
bool canBeUsed = false, result;
// act
Weapon test;
setAvailable(&test, canBeUsed);
result = test.canBeUsed;
// output
printf("setAvailable | canBeUsed set to: %d -> after set: %d", canBeUsed, result);
// assert
TEST_ASSERT_EQUAL(canBeUsed, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save