diff --git a/src/c/character.c b/src/c/character.c new file mode 100644 index 0000000..5e9d001 --- /dev/null +++ b/src/c/character.c @@ -0,0 +1,10 @@ +#include +#include +#include + +#include "character.h" +Character character; + +void setCharacterHealthPoints (Character *character, int newHealthPoints){ + character->healthPoints = newHealthPoints; +} \ No newline at end of file diff --git a/src/c/character.h b/src/c/character.h new file mode 100644 index 0000000..be8bf95 --- /dev/null +++ b/src/c/character.h @@ -0,0 +1,12 @@ +#ifndef CHARACTER_H +#define CHARACTER_H + +typedef struct { + int strength,dexterity,intelligence,healthPoints,manaPoints; + char name [50]; +} Character; + +void setCharacterHealthPoints (Character *character,int newHealthPoints); + + +#endif \ No newline at end of file diff --git a/test/c/test_character.c b/test/c/test_character.c new file mode 100644 index 0000000..d4aca2f --- /dev/null +++ b/test/c/test_character.c @@ -0,0 +1,22 @@ +#ifdef TEST +#include "unity.h" +#include "character.h" +Character testCharacter; + +void setUp(void) +{ + testCharacter.healthPoints = 0; +} + +void tearDown(void) +{ +} + +void test_setCharacterHealthPoints(void) +{ + TEST_ASSERT_EQUAL_INT(0,testCharacter.healthPoints); + setCharacterHealthPoints(&testCharacter,50); + TEST_ASSERT_EQUAL_INT(50,testCharacter.healthPoints); +} + +#endif // TEST \ No newline at end of file