Browse Source

prod/test: created test_addCharacterHealthPoints and addCharacterHealthPoints

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

4
src/c/character.c

@ -13,6 +13,10 @@ int getCharacterHealthPoints (Character *character) {
return character->healthPoints;
}
void addCharacterHealthPoints (Character *character, int addedHealthPoints) {
character->healthPoints += addedHealthPoints;
}
void setCharacterStrength (Character *character, int newStrength) {
character->strength = newStrength;
}

2
src/c/character.h

@ -10,6 +10,8 @@ void setCharacterHealthPoints (Character *character, int newHealthPoints);
int getCharacterHealthPoints (Character *character);
void addCharacterHealthPoints (Character *character, int addedHealthPoints);
void setCharacterStrength (Character *character, int newStrength);
int getCharacterStrength (Character *character);

7
test/c/test_character.c

@ -30,6 +30,13 @@ void test_setCharacterHealthPoints(void)
void test_getCharacterHealthPoints (void) {
TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints);
}
void test_addCharacterHealthPoints (void) {
addCharacterHealthPoints(&testCharacter2,5);
TEST_ASSERT_EQUAL_INT(20,testCharacter2.healthPoints);
}
void test_setCharacterStrenght(void) {
TEST_ASSERT_EQUAL_INT(0,testCharacter.strength);
setCharacterStrength(&testCharacter,50);

Loading…
Cancel
Save