diff --git a/src/c/weapon.c b/src/c/weapon.c index 3524f59..5c7caba 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -2,4 +2,8 @@ char *getName(Weapon *weapon){ return weapon->name; +} + +void setName(Weapon *weapon, char *nameToSet){ + weapon->name = nameToSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 895dac2..c978816 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -11,11 +11,15 @@ typedef struct int id; char *fullName; char *name; + int typeID; + char *typeName; int damageModifier; int baseDamage; bool canBeUsed; } Weapon; char *getName(Weapon *weapon); +void setName(Weapon *weapon, char *nameToSet); + #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 4280c9c..145d98f 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -5,14 +5,12 @@ void setUp(void) { - } void tearDown(void) { } - void test_getName(void) { // arrange @@ -31,4 +29,21 @@ void test_getName(void) TEST_ASSERT_EQUAL(nameOfWeapon, result); } +void test_setName(void) +{ + // arrange + char *nameWeapon = "switchblade", *result; + + // act + Weapon test; + setName(&test, nameWeapon); + result = test.name; + + // output + printf("setName | name set to: %s -> after set: %s", nameWeapon, result); + + // assert + TEST_ASSERT_EQUAL(nameWeapon, result); +} + #endif // TEST