From 5742861b08305c70b14e9e93a00013196d0a5fab Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:04:41 +0100 Subject: [PATCH] added weapon with struct & getName with test --- src/c/weapon.c | 5 +++++ src/c/weapon.h | 21 +++++++++++++++++++++ test/c/test_weapon.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/c/weapon.c create mode 100644 src/c/weapon.h create mode 100644 test/c/test_weapon.c 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