diff --git a/src/c/encounter.c b/src/c/encounter.c index a82e847..4937d79 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -72,6 +72,8 @@ int fight(int playerH, int playerDamage, int playerArmor, int playerAttack, enem case 'h': playerH = playerHealth(playerH, -10, playerArmor); break; + case 'f': + return 2; } } diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index 7ff85ea..34c5412 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -237,4 +237,18 @@ void test_FightPlayerHeals_thenAttacks_Wins(void) TEST_ASSERT_EQUAL(1, result); } +void test_FightPlayerFlees(void) +{ + //arrange + int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerAttack = 10; + int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5; + int result; + //act + enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack}; + playerInput_ExpectAndReturn('f'); + result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test); + //assert + TEST_ASSERT_EQUAL(2, result); +} + #endif // TEST