From f22cc3b419bb1349f46eedd9e35a85e138842c6f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 19:47:30 +0100 Subject: [PATCH] add a test for max_spellpoints --- src/magic.test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/magic.test.c b/src/magic.test.c index b32211fd4..e2c25bf81 100644 --- a/src/magic.test.c +++ b/src/magic.test.c @@ -425,6 +425,29 @@ static void test_magic_resistance(CuTest *tc) { test_cleanup(); } +static void test_max_spellpoints(CuTest *tc) { + unit *u; + race *rc; + + test_setup(); + rc = test_create_race("human"); + u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); + CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); + rc->maxaura = 1.0; + CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u)); + rc->maxaura = 2.0; + CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u)); + create_mage(u, M_GRAY); + set_level(u, SK_MAGIC, 1); + CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u)); + set_level(u, SK_MAGIC, 2); + CuAssertIntEquals(tc, 9, max_spellpoints(u->region, u)); + // permanent aura loss: + CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2)); + CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u)); + test_cleanup(); +} + CuSuite *get_magic_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -441,5 +464,6 @@ CuSuite *get_magic_suite(void) SUITE_ADD_TEST(suite, test_set_post_combatspell); SUITE_ADD_TEST(suite, test_hasspell); SUITE_ADD_TEST(suite, test_magic_resistance); + SUITE_ADD_TEST(suite, test_max_spellpoints); return suite; }