From 143104533b0e9c860bd5dcbafce9fe5725d0e077 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Fri, 27 Jan 2023 16:38:04 +0100 Subject: [PATCH] refactoring: extracted function calls out of the assert --- test/c/test_encounter.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index bb49353..d74591e 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -55,8 +55,9 @@ void test_playerIsDamaged(void) // arrange int expectedHealth = 90; // act + int result = playerDamaged(&testenemy, &testcharacter); // assert - TEST_ASSERT_EQUAL(expectedHealth, playerDamaged(&testenemy, &testcharacter)); + TEST_ASSERT_EQUAL(expectedHealth, result); } void test_playerIsNotOverhealed(void) @@ -65,8 +66,9 @@ void test_playerIsNotOverhealed(void) setCharacterHealthPoints(&testcharacter, 95); int heal = 10; // act + int result = playerHeal(&testcharacter, heal); // assert - TEST_ASSERT_EQUAL(getCharacterMaxHealthPoints(&testcharacter), playerHeal(&testcharacter,heal)); + TEST_ASSERT_EQUAL(getCharacterMaxHealthPoints(&testcharacter), result); } void test_setEnemyHealth(void) @@ -389,6 +391,9 @@ void test_enemyHealsNoPotion(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