Browse Source

added getFullname with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
72ea0de711
  1. 4
      src/c/weapon.c
  2. 1
      src/c/weapon.h
  3. 18
      test/c/test_weapon.c

4
src/c/weapon.c

@ -6,4 +6,8 @@ char *getName(Weapon *weapon){
void setName(Weapon *weapon, char *nameToSet){
weapon->name = nameToSet;
}
char *getFullName(Weapon *weapon){
return weapon->fullName;
}

1
src/c/weapon.h

@ -21,5 +21,6 @@ typedef struct
char *getName(Weapon *weapon);
void setName(Weapon *weapon, char *nameToSet);
char *getFullName(Weapon *weapon);
#endif

18
test/c/test_weapon.c

@ -46,4 +46,22 @@ void test_setName(void)
TEST_ASSERT_EQUAL(nameWeapon, result);
}
void test_getFullName(void)
{
// arrange
char *nameOfWeapon = "Kukri v2", *result;
Weapon test;
test.fullName = nameOfWeapon;
/* act */
// Die Funktion wird ausgeführt
result = getFullName(&test);
// output
printf("getFullName | fullName should be: %s -> is: %s", nameOfWeapon, result);
// assert
TEST_ASSERT_EQUAL(nameOfWeapon, result);
}
#endif // TEST
Loading…
Cancel
Save