diff --git a/src/c/weapon.c b/src/c/weapon.c index 50d8692..a506bb9 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -1,13 +1,21 @@ #include "weapon.h" -char *getName(Weapon *weapon){ +char *getName(Weapon *weapon) +{ return weapon->name; } -void setName(Weapon *weapon, char *nameToSet){ +void setName(Weapon *weapon, char *nameToSet) +{ weapon->name = nameToSet; } -char *getFullName(Weapon *weapon){ +char *getFullName(Weapon *weapon) +{ return weapon->fullName; +} + +void setFullName(Weapon *weapon, char *fullNameToSet) +{ + weapon->fullName = fullNameToSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 9f1febc..86d4209 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -22,5 +22,6 @@ char *getName(Weapon *weapon); void setName(Weapon *weapon, char *nameToSet); char *getFullName(Weapon *weapon); +void setFullName(Weapon *weapon, char *fullNameToSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index bb24bd3..0998f6f 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -64,4 +64,21 @@ void test_getFullName(void) TEST_ASSERT_EQUAL(nameOfWeapon, result); } +void test_setFullName(void) +{ + // arrange + char *fullNameWeapon = "switchblade v2", *result; + + // act + Weapon test; + setFullName(&test, fullNameWeapon); + result = test.fullName; + + // output + printf("setFullName | fullName set to: %s -> after set: %s", fullNameWeapon, result); + + // assert + TEST_ASSERT_EQUAL(fullNameWeapon, result); +} + #endif // TEST