From 72ea0de711353db98d54bf01c2c513f5edb66d4b Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:06:09 +0100 Subject: [PATCH] added getFullname with test --- src/c/weapon.c | 4 ++++ src/c/weapon.h | 1 + test/c/test_weapon.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/c/weapon.c b/src/c/weapon.c index 5c7caba..50d8692 100644 --- a/src/c/weapon.c +++ b/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; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index c978816..9f1febc 100644 --- a/src/c/weapon.h +++ b/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 \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 145d98f..bb24bd3 100644 --- a/test/c/test_weapon.c +++ b/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