From 1d083d7d5635e4030fca7e89588e956d6988b711 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Thu, 12 Jan 2023 19:11:42 +0100 Subject: [PATCH] prod/test: created setCharacterDexterity and test_setCharacterDexterity --- src/c/character.c | 9 ++++++--- src/c/character.h | 4 +++- test/c/test_character.c | 11 +++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/c/character.c b/src/c/character.c index 9d3517e..b0ff012 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -13,11 +13,14 @@ int getCharacterHealthPoints (Character *character) { return character->healthPoints; } -void setCharacterStrength(Character *character, int newStrength) -{ +void setCharacterStrength (Character *character, int newStrength) { character->strength = newStrength; } -int getCharacterStrength(Character *character) { +int getCharacterStrength (Character *character) { return character->strength; } + +void setCharacterDexterity (Character *character, int newDexterity) { + character->dexterity = newDexterity; +} \ No newline at end of file diff --git a/src/c/character.h b/src/c/character.h index 2396bc7..55ce4eb 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -12,6 +12,8 @@ int getCharacterHealthPoints (Character *character); void setCharacterStrength (Character *character, int newStrength); -int getCharacterStrength(Character *character) +int getCharacterStrength(Character *character); + +void setCharacterDexterity (Character *character, int newDexterity); #endif \ No newline at end of file diff --git a/test/c/test_character.c b/test/c/test_character.c index d4012d2..0119f86 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -10,6 +10,8 @@ void setUp(void) testCharacter2.healthPoints = 15; testCharacter.strength = 0; testCharacter2.strength = 5; + testCharacter.dexterity = 0; + testCharacter2.dexterity = 5; } void tearDown(void) @@ -26,8 +28,7 @@ void test_setCharacterHealthPoints(void) void test_getCharacterHealthPoints (void) { TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints); } -void test_setCharacterStrenght(void) -{ +void test_setCharacterStrenght(void) { TEST_ASSERT_EQUAL_INT(0,testCharacter.strength); setCharacterStrength(&testCharacter,50); TEST_ASSERT_EQUAL_INT(50,testCharacter.strength); @@ -37,4 +38,10 @@ void test_getCharacterStrength(void) { TEST_ASSERT_EQUAL_INT(5,testCharacter2.strength); } +void test_setCharacterDexterity(void) { + TEST_ASSERT_EQUAL_INT(0,testCharacter.dexterity); + setCharacterDexterity(&testCharacter,50); + TEST_ASSERT_EQUAL_INT(50,testCharacter.dexterity); +} + #endif // TEST \ No newline at end of file