From 7617bb7f51399396e21563e4b1cb550277a29ac5 Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:11:47 +0100 Subject: [PATCH] added setAvailable (canBeUsed) with test --- src/c/weapon.c | 5 +++++ src/c/weapon.h | 2 +- test/c/test_weapon.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/c/weapon.c b/src/c/weapon.c index ddb66e8..a29d223 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -53,4 +53,9 @@ void setBaseDamage(Weapon *weapon, int baseDmgSet) bool getAvailable(Weapon *weapon) { return weapon->canBeUsed; +} + +void setAvailable(Weapon *weapon, bool availableSet) +{ + weapon->canBeUsed = availableSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index cbc0661..d016ec9 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -36,6 +36,6 @@ int getBaseDamage(Weapon *weapon); void setBaseDamage(Weapon *weapon, int baseDmgSet); bool getAvailable(Weapon *weapon); - +void setAvailable(Weapon *weapon, bool availableSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 8f23f5b..609aa62 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -204,4 +204,21 @@ void test_getAvailable(void) TEST_ASSERT_EQUAL(canBeUsed, result); } +void test_setAvailable(void) +{ + // arrange + bool canBeUsed = false, result; + + // act + Weapon test; + setAvailable(&test, canBeUsed); + result = test.canBeUsed; + + // output + printf("setAvailable | canBeUsed set to: %d -> after set: %d", canBeUsed, result); + + // assert + TEST_ASSERT_EQUAL(canBeUsed, result); +} + #endif // TEST