Browse Source

added setBaseDamage with test

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

5
src/c/weapon.c

@ -43,4 +43,9 @@ void setDamageModifier(Weapon *weapon, int modifierSet)
int getBaseDamage(Weapon *weapon) int getBaseDamage(Weapon *weapon)
{ {
return weapon->baseDamage; return weapon->baseDamage;
}
void setBaseDamage(Weapon *weapon, int baseDmgSet)
{
weapon->baseDamage = baseDmgSet;
} }

3
src/c/weapon.h

@ -27,11 +27,12 @@ void setFullName(Weapon *weapon, char *fullNameToSet);
int getTypeID(Weapon *weapon); int getTypeID(Weapon *weapon);
void setTypeID(Weapon *weapon, int typeToSet); void setTypeID(Weapon *weapon, int typeToSet);
//typeName placeholder
// typeName placeholder
int getDamageModifier(Weapon *weapon); int getDamageModifier(Weapon *weapon);
void setDamageModifier(Weapon *weapon, int modifierSet); void setDamageModifier(Weapon *weapon, int modifierSet);
int getBaseDamage(Weapon *weapon); int getBaseDamage(Weapon *weapon);
void setBaseDamage(Weapon *weapon, int baseDmgSet);
#endif #endif

17
test/c/test_weapon.c

@ -169,4 +169,21 @@ void test_getBaseDamage(void)
TEST_ASSERT_EQUAL(baseDamage, result); TEST_ASSERT_EQUAL(baseDamage, result);
} }
void test_setBaseDamage(void)
{
// arrange
int baseDamage = 43, result;
// act
Weapon test;
setBaseDamage(&test, baseDamage);
result = test.baseDamage;
// output
printf("setBaseDamage | baseDamage set to: %d -> after set: %d", baseDamage, result);
// assert
TEST_ASSERT_EQUAL(baseDamage, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save