Browse Source

added getTypeID with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
584b48ee4e
  1. 5
      src/c/weapon.c
  2. 2
      src/c/weapon.h
  3. 18
      test/c/test_weapon.c

5
src/c/weapon.c

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

2
src/c/weapon.h

@ -24,4 +24,6 @@ void setName(Weapon *weapon, char *nameToSet);
char *getFullName(Weapon *weapon); char *getFullName(Weapon *weapon);
void setFullName(Weapon *weapon, char *fullNameToSet); void setFullName(Weapon *weapon, char *fullNameToSet);
int getTypeID(Weapon *weapon);
#endif #endif

18
test/c/test_weapon.c

@ -81,4 +81,22 @@ void test_setFullName(void)
TEST_ASSERT_EQUAL(fullNameWeapon, result); TEST_ASSERT_EQUAL(fullNameWeapon, result);
} }
void test_getTypeID(void)
{
// arrange
int type = 1, result;
Weapon test;
test.typeID = type;
/* act */
// Die Funktion wird ausgeführt
result = getTypeID(&test);
// output
printf("getTypeID | typeID should be: %d -> is: %d", type, result);
// assert
TEST_ASSERT_EQUAL(type, result);
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save