diff --git a/.gitignore b/.gitignore index 7893b49..9ee5328 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/gcov builld/logs build/temp build/test -.vscode \ No newline at end of file +.vscode +encounter_test.sh \ No newline at end of file diff --git a/src/c/encounter.c b/src/c/encounter.c index 5ee3f85..e6d6c88 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -58,3 +58,8 @@ void *setEnemyArmor(int *num, int armor){ int getEnemyInt(int *structParam){ return *structParam; } + +int switchTurns(int currentTurn){ + currentTurn = currentTurn % 2 + 1; + return currentTurn; +} diff --git a/src/c/encounter.h b/src/c/encounter.h index d6ddb68..1e5ea08 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -14,7 +14,7 @@ typedef struct { bool playerAlive(int health); int playerHealth(int health, int damage); int enemyDamaged(enemy enemy, int damage); - +int switchTurns(int currentTurn); //Getter/Setter Funktionen diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index f6782dd..dde9b12 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -21,6 +21,16 @@ void test_isPlayerAlive_healthGreaterZero(void) TEST_ASSERT_TRUE(playerAlive(health)); } + +void test_isPlayerAlive_healthLowerZero(void) +{ + //arrange + int health = -1; + //act + //assert + TEST_ASSERT_FALSE(playerAlive(health)); +} + void test_playerIsDamaged(void) { //arrange @@ -125,4 +135,14 @@ void test_getterWithParams(void){ TEST_ASSERT_EQUAL(damage, getEnemyInt(&test.damage)); TEST_ASSERT_EQUAL(attack, getEnemyInt(&test.attack)); } + +void test_switchingTurns(void) +{ + //arrange + int currentTurn = 0, result; + //act + result = switchTurns(currentTurn); + //assert + TEST_ASSERT_EQUAL(1,result); +} #endif // TEST