From b2232479decc409718a189576f711b0a99d7683f Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 14 Jan 2023 18:27:40 +0100 Subject: [PATCH] prod/test: created getCharacterLevel and test_getCharacterLevel --- 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 1b12e2c..2229b51 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -42,6 +42,10 @@ void setCharacterLevel (Character *character, int newLevel) { character->level = newLevel; } +int getCharacterLevel (Character *character) { + return character->level; +} + void increaseStat (Character *character, int stat, int amount) { switch (stat) diff --git a/src/c/character.h b/src/c/character.h index 411a1e3..6e53350 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -28,5 +28,7 @@ int getCharacterIntelligence (Character *character); void setCharacterLevel (Character *character, int newLevel); +int getCharacterLevel (Character *character); + void increaseStat (Character *character, int stat, int amount); #endif \ No newline at end of file diff --git a/test/c/test_character.c b/test/c/test_character.c index 8dff325..44fdd1c 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -69,6 +69,10 @@ void test_setCharacterLevel(void) { TEST_ASSERT_EQUAL_INT(1,testCharacter.level); } +void test_getCharacterLevel(void) { + TEST_ASSERT_EQUAL_INT(5,testCharacter2.level); +} + void test_increaseStat(void) { increaseStat(&testCharacter2,STRENGTH,15); TEST_ASSERT_EQUAL_INT(20,testCharacter2.strength);