From ea62efd46138f0552394b691f361906e49817c9a Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:10:16 +0100 Subject: [PATCH] added setBaseDamage with test --- src/c/weapon.c | 5 +++++ src/c/weapon.h | 3 ++- test/c/test_weapon.c | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/c/weapon.c b/src/c/weapon.c index c3f5cfc..99c6fce 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -43,4 +43,9 @@ void setDamageModifier(Weapon *weapon, int modifierSet) int getBaseDamage(Weapon *weapon) { return weapon->baseDamage; +} + +void setBaseDamage(Weapon *weapon, int baseDmgSet) +{ + weapon->baseDamage = baseDmgSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 0e11197..4149a10 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -27,11 +27,12 @@ void setFullName(Weapon *weapon, char *fullNameToSet); int getTypeID(Weapon *weapon); void setTypeID(Weapon *weapon, int typeToSet); -//typeName placeholder +// typeName placeholder int getDamageModifier(Weapon *weapon); void setDamageModifier(Weapon *weapon, int modifierSet); int getBaseDamage(Weapon *weapon); +void setBaseDamage(Weapon *weapon, int baseDmgSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 4984557..241c481 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -169,4 +169,21 @@ void test_getBaseDamage(void) TEST_ASSERT_EQUAL(baseDamage, result); } +void test_setBaseDamage(void) +{ + // arrange + int baseDamage = 43, result; + + // act + Weapon test; + setBaseDamage(&test, baseDamage); + result = test.baseDamage; + + // output + printf("setBaseDamage | baseDamage set to: %d -> after set: %d", baseDamage, result); + + // assert + TEST_ASSERT_EQUAL(baseDamage, result); +} + #endif // TEST