From 8615b3e13647f7a4946d6cfd97345925101b53bb Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:08:32 +0100 Subject: [PATCH] added getDamageModifier with test --- src/c/weapon.c | 5 +++++ src/c/weapon.h | 4 ++++ test/c/test_weapon.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/c/weapon.c b/src/c/weapon.c index adfb91e..8d34e27 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -28,4 +28,9 @@ int getTypeID(Weapon *weapon) void setTypeID(Weapon *weapon, int typeToSet) { weapon->typeID = typeToSet; +} + +int getDamageModifier(Weapon *weapon) +{ + return weapon->damageModifier; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 32172df..4693398 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -27,4 +27,8 @@ void setFullName(Weapon *weapon, char *fullNameToSet); int getTypeID(Weapon *weapon); void setTypeID(Weapon *weapon, int typeToSet); +//typeName placeholder + +int getDamageModifier(Weapon *weapon); + #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 2643f7b..db8830e 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -116,4 +116,22 @@ void test_setTypeID(void) TEST_ASSERT_EQUAL(type, result); } +void test_getDamageModifier(void) +{ + // arrange + int damageModifier = 2, result; + Weapon test; + test.damageModifier = damageModifier; + + /* act */ + // Die Funktion wird ausgeführt + result = getDamageModifier(&test); + + // output + printf("getDamageModifier | damageModifier should be: %d -> is: %d", damageModifier, result); + + // assert + TEST_ASSERT_EQUAL(damageModifier, result); +} + #endif // TEST