diff --git a/src/c/weapon.c b/src/c/weapon.c index ccc980d..adfb91e 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -23,4 +23,9 @@ void setFullName(Weapon *weapon, char *fullNameToSet) int getTypeID(Weapon *weapon) { return weapon->typeID; +} + +void setTypeID(Weapon *weapon, int typeToSet) +{ + weapon->typeID = typeToSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 54110b4..32172df 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -25,5 +25,6 @@ char *getFullName(Weapon *weapon); void setFullName(Weapon *weapon, char *fullNameToSet); int getTypeID(Weapon *weapon); +void setTypeID(Weapon *weapon, int typeToSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 9599e3b..2643f7b 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -99,4 +99,21 @@ void test_getTypeID(void) TEST_ASSERT_EQUAL(type, result); } +void test_setTypeID(void) +{ + // arrange + int type = 2, result; + + // act + Weapon test; + setTypeID(&test, type); + result = test.typeID; + + // output + printf("setTypeID | typeID set to: %d -> after set: %d", type, result); + + // assert + TEST_ASSERT_EQUAL(type, result); +} + #endif // TEST