Browse Source

prod/test: created setCharacterDexterity and test_setCharacterDexterity

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

9
src/c/character.c

@ -13,11 +13,14 @@ int getCharacterHealthPoints (Character *character) {
return character->healthPoints;
}
void setCharacterStrength(Character *character, int newStrength)
{
void setCharacterStrength (Character *character, int newStrength) {
character->strength = newStrength;
}
int getCharacterStrength(Character *character) {
int getCharacterStrength (Character *character) {
return character->strength;
}
void setCharacterDexterity (Character *character, int newDexterity) {
character->dexterity = newDexterity;
}

4
src/c/character.h

@ -12,6 +12,8 @@ int getCharacterHealthPoints (Character *character);
void setCharacterStrength (Character *character, int newStrength);
int getCharacterStrength(Character *character)
int getCharacterStrength(Character *character);
void setCharacterDexterity (Character *character, int newDexterity);
#endif

11
test/c/test_character.c

@ -10,6 +10,8 @@ void setUp(void)
testCharacter2.healthPoints = 15;
testCharacter.strength = 0;
testCharacter2.strength = 5;
testCharacter.dexterity = 0;
testCharacter2.dexterity = 5;
}
void tearDown(void)
@ -26,8 +28,7 @@ void test_setCharacterHealthPoints(void)
void test_getCharacterHealthPoints (void) {
TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints);
}
void test_setCharacterStrenght(void)
{
void test_setCharacterStrenght(void) {
TEST_ASSERT_EQUAL_INT(0,testCharacter.strength);
setCharacterStrength(&testCharacter,50);
TEST_ASSERT_EQUAL_INT(50,testCharacter.strength);
@ -37,4 +38,10 @@ void test_getCharacterStrength(void) {
TEST_ASSERT_EQUAL_INT(5,testCharacter2.strength);
}
void test_setCharacterDexterity(void) {
TEST_ASSERT_EQUAL_INT(0,testCharacter.dexterity);
setCharacterDexterity(&testCharacter,50);
TEST_ASSERT_EQUAL_INT(50,testCharacter.dexterity);
}
#endif // TEST
Loading…
Cancel
Save