Browse Source

added setFullName with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
517f0cfafe
  1. 14
      src/c/weapon.c
  2. 1
      src/c/weapon.h
  3. 17
      test/c/test_weapon.c

14
src/c/weapon.c

@ -1,13 +1,21 @@
#include "weapon.h"
char *getName(Weapon *weapon){
char *getName(Weapon *weapon)
{
return weapon->name;
}
void setName(Weapon *weapon, char *nameToSet){
void setName(Weapon *weapon, char *nameToSet)
{
weapon->name = nameToSet;
}
char *getFullName(Weapon *weapon){
char *getFullName(Weapon *weapon)
{
return weapon->fullName;
}
void setFullName(Weapon *weapon, char *fullNameToSet)
{
weapon->fullName = fullNameToSet;
}

1
src/c/weapon.h

@ -22,5 +22,6 @@ char *getName(Weapon *weapon);
void setName(Weapon *weapon, char *nameToSet);
char *getFullName(Weapon *weapon);
void setFullName(Weapon *weapon, char *fullNameToSet);
#endif

17
test/c/test_weapon.c

@ -64,4 +64,21 @@ void test_getFullName(void)
TEST_ASSERT_EQUAL(nameOfWeapon, result);
}
void test_setFullName(void)
{
// arrange
char *fullNameWeapon = "switchblade v2", *result;
// act
Weapon test;
setFullName(&test, fullNameWeapon);
result = test.fullName;
// output
printf("setFullName | fullName set to: %s -> after set: %s", fullNameWeapon, result);
// assert
TEST_ASSERT_EQUAL(fullNameWeapon, result);
}
#endif // TEST
Loading…
Cancel
Save