Browse Source

prod/test: created test_calculateStatIncrease and calculateStatIncrease

remotes/origin/characterStats
Kai Kehres 2 years ago
parent
commit
98ea061df8
  1. 4
      src/c/character.c
  2. 2
      src/c/character.h
  3. 4
      test/c/test_character.c

4
src/c/character.c

@ -46,6 +46,10 @@ int getCharacterLevel (Character *character) {
return character->level; return character->level;
} }
int calculateStatIncrease (Character *character, int amount) {
return character->level*amount;
}
void increaseStat (Character *character, int stat, int amount) { void increaseStat (Character *character, int stat, int amount) {
switch (stat) switch (stat)

2
src/c/character.h

@ -31,4 +31,6 @@ void setCharacterLevel (Character *character, int newLevel);
int getCharacterLevel (Character *character); int getCharacterLevel (Character *character);
void increaseStat (Character *character, int stat, int amount); void increaseStat (Character *character, int stat, int amount);
int calculateStatIncrease (Character *character, int amount);
#endif #endif

4
test/c/test_character.c

@ -80,4 +80,8 @@ void test_increaseStat(void) {
TEST_ASSERT_EQUAL_INT(22,testCharacter2.intelligence); TEST_ASSERT_EQUAL_INT(22,testCharacter2.intelligence);
} }
void test_calculateStatIncrease(void) {
TEST_ASSERT_EQUAL_INT(5,testCharacter2.level);
TEST_ASSERT_EQUAL_INT(25,calculateStatIncrease(&testCharacter2,5));
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save