Browse Source

prod/test: created getCharacterLevel and test_getCharacterLevel

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

4
src/c/character.c

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

2
src/c/character.h

@ -28,5 +28,7 @@ int getCharacterIntelligence (Character *character);
void setCharacterLevel (Character *character, int newLevel);
int getCharacterLevel (Character *character);
void increaseStat (Character *character, int stat, int amount);
#endif

4
test/c/test_character.c

@ -69,6 +69,10 @@ void test_setCharacterLevel(void) {
TEST_ASSERT_EQUAL_INT(1,testCharacter.level);
}
void test_getCharacterLevel(void) {
TEST_ASSERT_EQUAL_INT(5,testCharacter2.level);
}
void test_increaseStat(void) {
increaseStat(&testCharacter2,STRENGTH,15);
TEST_ASSERT_EQUAL_INT(20,testCharacter2.strength);

Loading…
Cancel
Save