From 98ea061df8f5ce703239effe313583ba0c72995e Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 14 Jan 2023 18:40:15 +0100 Subject: [PATCH] prod/test: created test_calculateStatIncrease and calculateStatIncrease --- src/c/character.c | 4 ++++ src/c/character.h | 2 ++ test/c/test_character.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/c/character.c b/src/c/character.c index 2229b51..cb8f3b8 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -46,6 +46,10 @@ int getCharacterLevel (Character *character) { return character->level; } +int calculateStatIncrease (Character *character, int amount) { + return character->level*amount; +} + void increaseStat (Character *character, int stat, int amount) { switch (stat) diff --git a/src/c/character.h b/src/c/character.h index 6e53350..633d3e1 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -31,4 +31,6 @@ void setCharacterLevel (Character *character, int newLevel); int getCharacterLevel (Character *character); void increaseStat (Character *character, int stat, int amount); + +int calculateStatIncrease (Character *character, int amount); #endif \ No newline at end of file diff --git a/test/c/test_character.c b/test/c/test_character.c index 44fdd1c..f6c9f75 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -80,4 +80,8 @@ void test_increaseStat(void) { TEST_ASSERT_EQUAL_INT(22,testCharacter2.intelligence); } +void test_calculateStatIncrease(void) { + TEST_ASSERT_EQUAL_INT(5,testCharacter2.level); + TEST_ASSERT_EQUAL_INT(25,calculateStatIncrease(&testCharacter2,5)); +} #endif // TEST \ No newline at end of file