diff --git a/src/c/encounter.c b/src/c/encounter.c index a43acba..9bd8a89 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -36,5 +36,6 @@ void *setEnemyHealth(int *num, int health){ } int getEnemyHealth(enemy enemy){ + //gibt health zurück, benötigt keine adress pointer return enemy.health; } diff --git a/src/c/encounter.h b/src/c/encounter.h index b42072d..4dd6bf3 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -9,6 +9,7 @@ typedef struct { //setEnemyHealth(&enemy.health, health); void *setEnemyHealth(int *num, int health); +int getEnemyHealth(enemy enemy); bool playerAlive(int health); int playerHealth(int health, int damage); diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index 6b4abdf..eb40728 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -54,6 +54,15 @@ void test_setEnemyHealth(void){ TEST_ASSERT_EQUAL(health, test.health); } +void test_getEnemyHealth(void){ + //arrange + int health = 50; + //act + enemy test = {health}; + //assert + TEST_ASSERT_EQUAL(health, getEnemyHealth(test)); +} + #endif // TEST