Browse Source

prod/test: created test_addCharacterStrength and addCharacterStrength

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

4
src/c/character.c

@ -25,6 +25,10 @@ int getCharacterStrength (Character *character) {
return character->strength; return character->strength;
} }
void addCharacterStrength (Character *character, int addStrength) {
character->strength += addStrength;
}
void setCharacterDexterity (Character *character, int newDexterity) { void setCharacterDexterity (Character *character, int newDexterity) {
character->dexterity = newDexterity; character->dexterity = newDexterity;
} }

2
src/c/character.h

@ -16,6 +16,8 @@ void setCharacterStrength (Character *character, int newStrength);
int getCharacterStrength (Character *character); int getCharacterStrength (Character *character);
void addCharacterStrength (Character *character, int addStrength);
void setCharacterDexterity (Character *character, int newDexterity); void setCharacterDexterity (Character *character, int newDexterity);
int getCharacterDexterity (Character *character); int getCharacterDexterity (Character *character);

5
test/c/test_character.c

@ -47,6 +47,11 @@ void test_getCharacterStrength(void) {
TEST_ASSERT_EQUAL_INT(5,testCharacter2.strength); TEST_ASSERT_EQUAL_INT(5,testCharacter2.strength);
} }
void test_addCharacterStrength (void) {
addCharacterStrength(&testCharacter2,15);
TEST_ASSERT_EQUAL_INT(20,testCharacter2.strength);
}
void test_setCharacterDexterity(void) { void test_setCharacterDexterity(void) {
TEST_ASSERT_EQUAL_INT(0,testCharacter.dexterity); TEST_ASSERT_EQUAL_INT(0,testCharacter.dexterity);
setCharacterDexterity(&testCharacter,50); setCharacterDexterity(&testCharacter,50);

Loading…
Cancel
Save