Browse Source

prod/test: created getCharacterIntelligence and test_getCharacterIntelligence

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

4
src/c/character.c

@ -31,4 +31,8 @@ int getCharacterDexterity (Character *character) {
void setCharacterIntelligence (Character *character, int newIntelligence) { void setCharacterIntelligence (Character *character, int newIntelligence) {
character->intelligence = newIntelligence; character->intelligence = newIntelligence;
}
int getCharacterIntelligence (Character *character) {
return character->intelligence;
} }

2
src/c/character.h

@ -20,4 +20,6 @@ int getCharacterDexterity (Character *character);
void setCharacterIntelligence (Character *character, int newIntelligence); void setCharacterIntelligence (Character *character, int newIntelligence);
int getCharacterIntelligence (Character *character);
#endif #endif

6
test/c/test_character.c

@ -13,7 +13,7 @@ void setUp(void)
testCharacter.dexterity = 0; testCharacter.dexterity = 0;
testCharacter2.dexterity = 5; testCharacter2.dexterity = 5;
testCharacter.intelligence = 0; testCharacter.intelligence = 0;
testCharacter2.intelligence = 5;
testCharacter2.intelligence = 7;
} }
void tearDown(void) void tearDown(void)
@ -56,4 +56,8 @@ void test_setCharacterIntelligence(void) {
TEST_ASSERT_EQUAL_INT(45,testCharacter.intelligence); TEST_ASSERT_EQUAL_INT(45,testCharacter.intelligence);
} }
void test_getCharacterIntelligence(void) {
TEST_ASSERT_EQUAL_INT(7,testCharacter2.intelligence);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save