diff --git a/src/c/weapon.c b/src/c/weapon.c new file mode 100644 index 0000000..3524f59 --- /dev/null +++ b/src/c/weapon.c @@ -0,0 +1,5 @@ +#include "weapon.h" + +char *getName(Weapon *weapon){ + return weapon->name; +} \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h new file mode 100644 index 0000000..895dac2 --- /dev/null +++ b/src/c/weapon.h @@ -0,0 +1,21 @@ +#ifndef WEAPON_H +#define WEAPON_H + +#include +#include +#include +#include + +typedef struct +{ + int id; + char *fullName; + char *name; + int damageModifier; + int baseDamage; + bool canBeUsed; +} Weapon; + +char *getName(Weapon *weapon); + +#endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c new file mode 100644 index 0000000..4280c9c --- /dev/null +++ b/test/c/test_weapon.c @@ -0,0 +1,34 @@ +#ifdef TEST + +#include "unity.h" +#include "weapon.h" + +void setUp(void) +{ + +} + +void tearDown(void) +{ +} + + +void test_getName(void) +{ + // arrange + char *nameOfWeapon = "Kukri", *result; + Weapon test; + test.name = nameOfWeapon; + + /* act */ + // Die Funktion wird ausgeführt + result = getName(&test); + + // output + printf("getName | name should be: %s -> is: %s", nameOfWeapon, result); + + // assert + TEST_ASSERT_EQUAL(nameOfWeapon, result); +} + +#endif // TEST