Browse Source

Prod/Test: created Character, setCharacterHealthPoints and test_setCharacterHealthPoints

remotes/origin/characterStats
Kai Kehres 2 years ago
parent
commit
ef8a6f5fe1
  1. 10
      src/c/character.c
  2. 12
      src/c/character.h
  3. 22
      test/c/test_character.c

10
src/c/character.c

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "character.h"
Character character;
void setCharacterHealthPoints (Character *character, int newHealthPoints){
character->healthPoints = newHealthPoints;
}

12
src/c/character.h

@ -0,0 +1,12 @@
#ifndef CHARACTER_H
#define CHARACTER_H
typedef struct {
int strength,dexterity,intelligence,healthPoints,manaPoints;
char name [50];
} Character;
void setCharacterHealthPoints (Character *character,int newHealthPoints);
#endif

22
test/c/test_character.c

@ -0,0 +1,22 @@
#ifdef TEST
#include "unity.h"
#include "character.h"
Character testCharacter;
void setUp(void)
{
testCharacter.healthPoints = 0;
}
void tearDown(void)
{
}
void test_setCharacterHealthPoints(void)
{
TEST_ASSERT_EQUAL_INT(0,testCharacter.healthPoints);
setCharacterHealthPoints(&testCharacter,50);
TEST_ASSERT_EQUAL_INT(50,testCharacter.healthPoints);
}
#endif // TEST
Loading…
Cancel
Save