Merge pull request #273 from ennorehling/feature/fix-bad-spell-tests

managed to commit some broken tests, and travis let them pass.
This commit is contained in:
Enno Rehling 2015-08-07 18:36:34 +02:00
commit 16e922c334
2 changed files with 52 additions and 9 deletions

View File

@ -26,7 +26,7 @@ static void test_create_castorder(castorder *order, unit *u, int level, float fo
create_castorder(order, u, NULL, NULL, u->region, level, force, range, create_order(K_CAST, lang, ""), NULL);
}
static void test_dreams(CuTest *tc) {
static void test_good_dreams(CuTest *tc) {
struct region *r;
struct faction *f1, *f2;
unit *u1, *u2;
@ -52,13 +52,23 @@ static void test_dreams(CuTest *tc) {
a_age(&r->attribs);
CuAssertIntEquals_Msg(tc, "good dreams give +1 to allies", 1, get_modifier(u1, SK_MELEE, 11, r, false));
CuAssertIntEquals_Msg(tc, "good dreams have no effect on non-allies", 0, get_modifier(u2, SK_MELEE, 11, r, false));
}
level = sp_baddreams(&order);
CuAssertIntEquals(tc, 10, level);
static void test_dreams(CuTest *tc) {
struct region *r;
struct faction *f1, *f2;
unit *u1, *u2;
castorder order;
a_age(&r->attribs);
CuAssertIntEquals_Msg(tc, "bad dreams have no effect on allies", 0, get_modifier(u1, SK_MELEE, 11, r, false));
CuAssertIntEquals_Msg(tc, "bad dreams give -1 to non-allies", -1, get_modifier(u2, SK_MELEE, 11, r, false));
test_cleanup();
test_create_world();
r = findregion(0, 0);
f1 = test_create_faction(0);
f2 = test_create_faction(0);
u1 = test_create_unit(f1, r);
u2 = test_create_unit(f2, r);
test_create_castorder(&order, u1, 10, 10., 0);
sp_gooddreams(&order);
sp_baddreams(&order);
@ -70,9 +80,42 @@ static void test_dreams(CuTest *tc) {
test_cleanup();
}
static void test_bad_dreams(CuTest *tc) {
struct region *r;
struct faction *f1, *f2;
unit *u1, *u2;
int level;
castorder order;
test_cleanup();
test_create_world();
r = findregion(0, 0);
f1 = test_create_faction(0);
f2 = test_create_faction(0);
u1 = test_create_unit(f1, r);
u2 = test_create_unit(f2, r);
test_create_castorder(&order, u1, 10, 10., 0);
level = sp_baddreams(&order);
CuAssertIntEquals(tc, 10, level);
curse *curse = get_curse(r->attribs, ct_find("gbdream"));
CuAssertTrue(tc, curse && curse->duration > 1);
CuAssertTrue(tc, curse->effect == -1);
a_age(&r->attribs);
CuAssertIntEquals_Msg(tc, "bad dreams have no effect on allies", 0, get_modifier(u1, SK_MELEE, 11, r, false));
CuAssertIntEquals_Msg(tc, "bad dreams give -1 to non-allies", -1, get_modifier(u2, SK_MELEE, 11, r, false));
free_castorder(&order);
test_cleanup();
}
CuSuite *get_spells_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_good_dreams);
SUITE_ADD_TEST(suite, test_bad_dreams);
SUITE_ADD_TEST(suite, test_dreams);
return suite;
}

View File

@ -43,7 +43,7 @@ static void test_magicresistance_unit(CuTest *tc) {
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)u2->attribs->type);
msg = c->type->curseinfo(u2, TYP_UNIT, c, 1);
CuAssertPtrNotNull(tc, msg);
CuAssertStrEquals(tc, "curseinfo::magicresistance", test_get_messagetype(msg));
CuAssertStrEquals(tc, "curseinfo::magicresistance_unit", test_get_messagetype(msg));
test_cleanup();
}
@ -69,7 +69,7 @@ static void test_magicresistance_building(CuTest *tc) {
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)b1->attribs->type);
msg = c->type->curseinfo(b1, TYP_BUILDING, c, 1);
CuAssertPtrNotNull(tc, msg);
CuAssertStrEquals(tc, "curseinfo::homestone", test_get_messagetype(msg));
CuAssertStrEquals(tc, "curseinfo::magicresistance_building", test_get_messagetype(msg));
test_cleanup();
}