From 32c777d4286d3dbbd73b197ccd6ed32dc981ddc1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 9 Nov 2015 19:46:01 +0100 Subject: [PATCH] add missing test file, try again --- src/triggers/shock.test.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/triggers/shock.test.c diff --git a/src/triggers/shock.test.c b/src/triggers/shock.test.c new file mode 100644 index 000000000..8957c33fc --- /dev/null +++ b/src/triggers/shock.test.c @@ -0,0 +1,53 @@ +#include +#include "shock.h" +#include "../magic.h" + +#include +#include +#include + +#include +#include + +static void test_shock(CuTest *tc) { + unit *u; + trigger *tt; + test_cleanup(); + + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + create_mage(u, M_GRAY); + set_level(u, SK_MAGIC, 5); + set_spellpoints(u, 10); + u->hp = 10; + tt = trigger_shock(u); + tt->type->handle(tt, u); + CuAssertIntEquals(tc, 2, u->hp); + CuAssertIntEquals(tc, 2, get_spellpoints(u)); + CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "shock")); + test_cleanup(); +} + +static void test_shock_low(CuTest *tc) { + unit *u; + trigger *tt; + test_cleanup(); + + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + create_mage(u, M_GRAY); + set_level(u, SK_MAGIC, 5); + set_spellpoints(u, 1); + u->hp = 1; + tt = trigger_shock(u); + tt->type->handle(tt, u); + CuAssertIntEquals(tc, 1, u->hp); + CuAssertIntEquals(tc, 1, get_spellpoints(u)); + test_cleanup(); +} + +CuSuite *get_shock_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_shock); + SUITE_ADD_TEST(suite, test_shock_low); + return suite; +}