Browse Source

prod/test: created setCharacterIntelligence and test_setCharacterIntelligence

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

4
src/c/character.c

@ -27,4 +27,8 @@ void setCharacterDexterity (Character *character, int newDexterity) {
int getCharacterDexterity (Character *character) { int getCharacterDexterity (Character *character) {
return character->dexterity; return character->dexterity;
}
void setCharacterIntelligence (Character *character, int newIntelligence) {
character->intelligence = newIntelligence;
} }

8
src/c/character.h

@ -6,16 +6,18 @@ typedef struct {
char name [50]; char name [50];
} Character; } Character;
void setCharacterHealthPoints (Character *character,int newHealthPoints);
void setCharacterHealthPoints (Character *character, int newHealthPoints);
int getCharacterHealthPoints (Character *character); int getCharacterHealthPoints (Character *character);
void setCharacterStrength (Character *character, int newStrength); void setCharacterStrength (Character *character, int newStrength);
int getCharacterStrength(Character *character);
int getCharacterStrength (Character *character);
void setCharacterDexterity (Character *character, int newDexterity); void setCharacterDexterity (Character *character, int newDexterity);
int getCharacterDexterity(Character *character);
int getCharacterDexterity (Character *character);
void setCharacterIntelligence (Character *character, int newIntelligence);
#endif #endif

9
test/c/test_character.c

@ -12,6 +12,8 @@ void setUp(void)
testCharacter2.strength = 5; testCharacter2.strength = 5;
testCharacter.dexterity = 0; testCharacter.dexterity = 0;
testCharacter2.dexterity = 5; testCharacter2.dexterity = 5;
testCharacter.intelligence = 0;
testCharacter2.intelligence = 5;
} }
void tearDown(void) void tearDown(void)
@ -44,9 +46,14 @@ void test_setCharacterDexterity(void) {
TEST_ASSERT_EQUAL_INT(50,testCharacter.dexterity); TEST_ASSERT_EQUAL_INT(50,testCharacter.dexterity);
} }
void test_getCharacterDexterity(void) { void test_getCharacterDexterity(void) {
TEST_ASSERT_EQUAL_INT(5,testCharacter2.dexterity); TEST_ASSERT_EQUAL_INT(5,testCharacter2.dexterity);
} }
void test_setCharacterIntelligence(void) {
TEST_ASSERT_EQUAL_INT(0,testCharacter.intelligence);
setCharacterIntelligence(&testCharacter,45);
TEST_ASSERT_EQUAL_INT(45,testCharacter.intelligence);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save