From 129fb04dcb5a7177b879494477584a57c6944e32 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 14 Jan 2023 17:14:43 +0100 Subject: [PATCH] prod/test: created test_addCharacterHealthPoints and addCharacterHealthPoints --- src/c/character.c | 4 ++++ src/c/character.h | 2 ++ test/c/test_character.c | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/src/c/character.c b/src/c/character.c index d529731..2409dab 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -13,6 +13,10 @@ int getCharacterHealthPoints (Character *character) { return character->healthPoints; } +void addCharacterHealthPoints (Character *character, int addedHealthPoints) { + character->healthPoints += addedHealthPoints; +} + void setCharacterStrength (Character *character, int newStrength) { character->strength = newStrength; } diff --git a/src/c/character.h b/src/c/character.h index 80b6dd1..0c18944 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -10,6 +10,8 @@ void setCharacterHealthPoints (Character *character, int newHealthPoints); int getCharacterHealthPoints (Character *character); +void addCharacterHealthPoints (Character *character, int addedHealthPoints); + void setCharacterStrength (Character *character, int newStrength); int getCharacterStrength (Character *character); diff --git a/test/c/test_character.c b/test/c/test_character.c index e216d43..71b43ec 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -30,6 +30,13 @@ void test_setCharacterHealthPoints(void) void test_getCharacterHealthPoints (void) { TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints); } + +void test_addCharacterHealthPoints (void) { + addCharacterHealthPoints(&testCharacter2,5); + TEST_ASSERT_EQUAL_INT(20,testCharacter2.healthPoints); + +} + void test_setCharacterStrenght(void) { TEST_ASSERT_EQUAL_INT(0,testCharacter.strength); setCharacterStrength(&testCharacter,50);