Browse Source

refactoring: extracted function calls out of the assert

remotes/origin/thirdcycle
Kai Kehres 2 years ago
parent
commit
143104533b
  1. 11
      test/c/test_encounter.c

11
test/c/test_encounter.c

@ -55,8 +55,9 @@ void test_playerIsDamaged(void)
// arrange // arrange
int expectedHealth = 90; int expectedHealth = 90;
// act // act
int result = playerDamaged(&testenemy, &testcharacter);
// assert // assert
TEST_ASSERT_EQUAL(expectedHealth, playerDamaged(&testenemy, &testcharacter));
TEST_ASSERT_EQUAL(expectedHealth, result);
} }
void test_playerIsNotOverhealed(void) void test_playerIsNotOverhealed(void)
@ -65,8 +66,9 @@ void test_playerIsNotOverhealed(void)
setCharacterHealthPoints(&testcharacter, 95); setCharacterHealthPoints(&testcharacter, 95);
int heal = 10; int heal = 10;
// act // act
int result = playerHeal(&testcharacter, heal);
// assert // assert
TEST_ASSERT_EQUAL(getCharacterMaxHealthPoints(&testcharacter), playerHeal(&testcharacter,heal));
TEST_ASSERT_EQUAL(getCharacterMaxHealthPoints(&testcharacter), result);
} }
void test_setEnemyHealth(void) void test_setEnemyHealth(void)
@ -389,6 +391,9 @@ void test_enemyHealsNoPotion(void)
} }
int test_rollInitiative (void) { int test_rollInitiative (void) {
TEST_ASSERT(testcharacter.dexterity + 1 <= rollInitiative(&testcharacter) && testcharacter.dexterity + 20 >= rollInitiative(&testcharacter));
int initiative = rollInitiative(&testcharacter);
TEST_ASSERT(testcharacter.dexterity + 1 <= initiative && testcharacter.dexterity + 20 >= initiative);
} }
#endif // TEST #endif // TEST
Loading…
Cancel
Save