From 9cefe4afedc5e47bb79bf49182bdf425b5e964d9 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 14 Jan 2023 17:20:54 +0100 Subject: [PATCH] prod/test: created test_addCharacterStrength and addCharacterStrength --- src/c/character.c | 4 ++++ src/c/character.h | 2 ++ test/c/test_character.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/c/character.c b/src/c/character.c index 2409dab..c3010be 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -25,6 +25,10 @@ int getCharacterStrength (Character *character) { return character->strength; } +void addCharacterStrength (Character *character, int addStrength) { + character->strength += addStrength; +} + void setCharacterDexterity (Character *character, int newDexterity) { character->dexterity = newDexterity; } diff --git a/src/c/character.h b/src/c/character.h index 0c18944..5caca85 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -16,6 +16,8 @@ void setCharacterStrength (Character *character, int newStrength); int getCharacterStrength (Character *character); +void addCharacterStrength (Character *character, int addStrength); + void setCharacterDexterity (Character *character, int newDexterity); int getCharacterDexterity (Character *character); diff --git a/test/c/test_character.c b/test/c/test_character.c index 71b43ec..d948c3c 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -47,6 +47,11 @@ void test_getCharacterStrength(void) { TEST_ASSERT_EQUAL_INT(5,testCharacter2.strength); } +void test_addCharacterStrength (void) { + addCharacterStrength(&testCharacter2,15); + TEST_ASSERT_EQUAL_INT(20,testCharacter2.strength); +} + void test_setCharacterDexterity(void) { TEST_ASSERT_EQUAL_INT(0,testCharacter.dexterity); setCharacterDexterity(&testCharacter,50);