From 584b48ee4eee0f737ef1c64dd5196dab976abb38 Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 04:07:18 +0100 Subject: [PATCH] added getTypeID with test --- src/c/weapon.c | 5 +++++ src/c/weapon.h | 2 ++ test/c/test_weapon.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/c/weapon.c b/src/c/weapon.c index a506bb9..ccc980d 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -18,4 +18,9 @@ char *getFullName(Weapon *weapon) void setFullName(Weapon *weapon, char *fullNameToSet) { weapon->fullName = fullNameToSet; +} + +int getTypeID(Weapon *weapon) +{ + return weapon->typeID; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 86d4209..54110b4 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -24,4 +24,6 @@ void setName(Weapon *weapon, char *nameToSet); char *getFullName(Weapon *weapon); void setFullName(Weapon *weapon, char *fullNameToSet); +int getTypeID(Weapon *weapon); + #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 0998f6f..9599e3b 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -81,4 +81,22 @@ void test_setFullName(void) TEST_ASSERT_EQUAL(fullNameWeapon, result); } +void test_getTypeID(void) +{ + // arrange + int type = 1, result; + Weapon test; + test.typeID = type; + + /* act */ + // Die Funktion wird ausgeführt + result = getTypeID(&test); + + // output + printf("getTypeID | typeID should be: %d -> is: %d", type, result); + + // assert + TEST_ASSERT_EQUAL(type, result); +} + #endif // TEST