Browse Source

prod/test: created setCharacterStrength and test_setCharacterStrength

remotes/origin/characterStats
Kai Kehres 2 years ago
parent
commit
b13d7494bb
  1. 7
      src/c/character.c
  2. 5
      src/c/character.h
  3. 18
      test/c/test_character.c

7
src/c/character.c

@ -11,4 +11,9 @@ void setCharacterHealthPoints (Character *character, int newHealthPoints){
int getCharacterHealthPoints (Character *character) {
return character->healthPoints;
}
}
void setCharacterStrength(Character *character, int newStrength)
{
character->strength = newStrength;
}

5
src/c/character.h

@ -8,5 +8,10 @@ typedef struct {
void setCharacterHealthPoints (Character *character,int newHealthPoints);
int getCharacterHealthPoints (Character *character);
void setCharacterStrength (Character *character, int newStrength);
#endif

18
test/c/test_character.c

@ -2,10 +2,14 @@
#include "unity.h"
#include "character.h"
Character testCharacter;
Character testCharacter2;
void setUp(void)
{
testCharacter.healthPoints = 0;
testCharacter.healthPoints = 0;
testCharacter2.healthPoints = 15;
testCharacter.strength = 0;
testCharacter2.strength = 5;
}
void tearDown(void)
@ -19,4 +23,16 @@ void test_setCharacterHealthPoints(void)
TEST_ASSERT_EQUAL_INT(50,testCharacter.healthPoints);
}
void test_getCharacterHealthPoints (void) {
TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints);
}
void test_setCharacterStrenght(void)
{
TEST_ASSERT_EQUAL_INT(0,testCharacter.strength);
setCharacterStrength(&testCharacter,50);
TEST_ASSERT_EQUAL_INT(50,testCharacter.strength);
}
#endif // TEST
Loading…
Cancel
Save