From ef8a6f5fe122e7e69a202453fa77c41f1e382505 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Thu, 12 Jan 2023 14:53:23 +0100 Subject: [PATCH] Prod/Test: created Character, setCharacterHealthPoints and test_setCharacterHealthPoints --- src/c/character.c | 10 ++++++++++ src/c/character.h | 12 ++++++++++++ test/c/test_character.c | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/c/character.c create mode 100644 src/c/character.h create mode 100644 test/c/test_character.c 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