From b13d7494bbefbfbead968971341b5917cd973cd4 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Thu, 12 Jan 2023 18:36:34 +0100 Subject: [PATCH] prod/test: created setCharacterStrength and test_setCharacterStrength --- src/c/character.c | 7 ++++++- src/c/character.h | 5 +++++ test/c/test_character.c | 18 +++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/c/character.c b/src/c/character.c index 3da86cd..1664eea 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -11,4 +11,9 @@ void setCharacterHealthPoints (Character *character, int newHealthPoints){ int getCharacterHealthPoints (Character *character) { return character->healthPoints; -} \ No newline at end of file +} + +void setCharacterStrength(Character *character, int newStrength) +{ + character->strength = newStrength; +} diff --git a/src/c/character.h b/src/c/character.h index be8bf95..999692c 100644 --- a/src/c/character.h +++ b/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 \ No newline at end of file diff --git a/test/c/test_character.c b/test/c/test_character.c index d4aca2f..3e26839 100644 --- a/test/c/test_character.c +++ b/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 \ No newline at end of file