Browse Source

added setTypeID with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
9410e3395e
  1. 5
      src/c/weapon.c
  2. 1
      src/c/weapon.h
  3. 17
      test/c/test_weapon.c

5
src/c/weapon.c

@ -23,4 +23,9 @@ void setFullName(Weapon *weapon, char *fullNameToSet)
int getTypeID(Weapon *weapon) int getTypeID(Weapon *weapon)
{ {
return weapon->typeID; return weapon->typeID;
}
void setTypeID(Weapon *weapon, int typeToSet)
{
weapon->typeID = typeToSet;
} }

1
src/c/weapon.h

@ -25,5 +25,6 @@ char *getFullName(Weapon *weapon);
void setFullName(Weapon *weapon, char *fullNameToSet); void setFullName(Weapon *weapon, char *fullNameToSet);
int getTypeID(Weapon *weapon); int getTypeID(Weapon *weapon);
void setTypeID(Weapon *weapon, int typeToSet);
#endif #endif

17
test/c/test_weapon.c

@ -99,4 +99,21 @@ void test_getTypeID(void)
TEST_ASSERT_EQUAL(type, result); 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 #endif // TEST
Loading…
Cancel
Save