Browse Source

added weapon with struct & getName with test

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
5742861b08
  1. 5
      src/c/weapon.c
  2. 21
      src/c/weapon.h
  3. 34
      test/c/test_weapon.c

5
src/c/weapon.c

@ -0,0 +1,5 @@
#include "weapon.h"
char *getName(Weapon *weapon){
return weapon->name;
}

21
src/c/weapon.h

@ -0,0 +1,21 @@
#ifndef WEAPON_H
#define WEAPON_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
typedef struct
{
int id;
char *fullName;
char *name;
int damageModifier;
int baseDamage;
bool canBeUsed;
} Weapon;
char *getName(Weapon *weapon);
#endif

34
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
Loading…
Cancel
Save