release order reference used to create castorder, message

This commit is contained in:
Enno Rehling 2015-10-13 23:02:01 +02:00
parent a6ca489d9a
commit 24f1f82e93
2 changed files with 18 additions and 14 deletions

View File

@ -252,6 +252,7 @@ static void test_give_peasants(CuTest * tc) {
CuAssertStrEquals(tc, "give_person_peasants", (const char*)msg->parameters[0].v); CuAssertStrEquals(tc, "give_person_peasants", (const char*)msg->parameters[0].v);
CuAssertIntEquals(tc, 0, env.src->number); CuAssertIntEquals(tc, 0, env.src->number);
CuAssertIntEquals(tc, 1, env.r->land->peasants); CuAssertIntEquals(tc, 1, env.r->land->peasants);
msg_release(msg);
test_cleanup(); test_cleanup();
} }

View File

@ -20,10 +20,13 @@
#include <assert.h> #include <assert.h>
static void test_create_castorder(castorder *order, unit *u, int level, float force, int range) { static void test_create_castorder(castorder *co, unit *u, int level, float force, int range) {
struct locale * lang; struct locale * lang;
order *ord;
lang = get_or_create_locale("en"); lang = get_or_create_locale("en");
create_castorder(order, u, NULL, NULL, u->region, level, force, range, create_order(K_CAST, lang, ""), NULL); create_castorder(co, u, NULL, NULL, u->region, level, force, range, ord = create_order(K_CAST, lang, ""), NULL);
free_order(ord);
} }
static void test_good_dreams(CuTest *tc) { static void test_good_dreams(CuTest *tc) {
@ -31,7 +34,7 @@ static void test_good_dreams(CuTest *tc) {
struct faction *f1, *f2; struct faction *f1, *f2;
unit *u1, *u2; unit *u1, *u2;
int level; int level;
castorder order; castorder co;
test_cleanup(); test_cleanup();
test_create_world(); test_create_world();
@ -41,9 +44,9 @@ static void test_good_dreams(CuTest *tc) {
u1 = test_create_unit(f1, r); u1 = test_create_unit(f1, r);
u2 = test_create_unit(f2, r); u2 = test_create_unit(f2, r);
test_create_castorder(&order, u1, 10, 10., 0); test_create_castorder(&co, u1, 10, 10., 0);
level = sp_gooddreams(&order); level = sp_gooddreams(&co);
CuAssertIntEquals(tc, 10, level); CuAssertIntEquals(tc, 10, level);
curse *curse = get_curse(r->attribs, ct_find("gbdream")); curse *curse = get_curse(r->attribs, ct_find("gbdream"));
CuAssertTrue(tc, curse && curse->duration > 1); CuAssertTrue(tc, curse && curse->duration > 1);
@ -58,7 +61,7 @@ static void test_dreams(CuTest *tc) {
struct region *r; struct region *r;
struct faction *f1, *f2; struct faction *f1, *f2;
unit *u1, *u2; unit *u1, *u2;
castorder order; castorder co;
test_cleanup(); test_cleanup();
test_create_world(); test_create_world();
@ -68,15 +71,15 @@ static void test_dreams(CuTest *tc) {
u1 = test_create_unit(f1, r); u1 = test_create_unit(f1, r);
u2 = test_create_unit(f2, r); u2 = test_create_unit(f2, r);
test_create_castorder(&order, u1, 10, 10., 0); test_create_castorder(&co, u1, 10, 10., 0);
sp_gooddreams(&order); sp_gooddreams(&co);
sp_baddreams(&order); sp_baddreams(&co);
a_age(&r->attribs); a_age(&r->attribs);
CuAssertIntEquals_Msg(tc, "good dreams in same region as bad dreams", 1, get_modifier(u1, SK_MELEE, 11, r, false)); CuAssertIntEquals_Msg(tc, "good dreams in same region as bad dreams", 1, get_modifier(u1, SK_MELEE, 11, r, false));
CuAssertIntEquals_Msg(tc, "bad dreams in same region as good dreams", -1, get_modifier(u2, SK_MELEE, 11, r, false)); CuAssertIntEquals_Msg(tc, "bad dreams in same region as good dreams", -1, get_modifier(u2, SK_MELEE, 11, r, false));
free_castorder(&order); free_castorder(&co);
test_cleanup(); test_cleanup();
} }
@ -85,7 +88,7 @@ static void test_bad_dreams(CuTest *tc) {
struct faction *f1, *f2; struct faction *f1, *f2;
unit *u1, *u2; unit *u1, *u2;
int level; int level;
castorder order; castorder co;
test_cleanup(); test_cleanup();
test_create_world(); test_create_world();
@ -95,9 +98,9 @@ static void test_bad_dreams(CuTest *tc) {
u1 = test_create_unit(f1, r); u1 = test_create_unit(f1, r);
u2 = test_create_unit(f2, r); u2 = test_create_unit(f2, r);
test_create_castorder(&order, u1, 10, 10., 0); test_create_castorder(&co, u1, 10, 10., 0);
level = sp_baddreams(&order); level = sp_baddreams(&co);
CuAssertIntEquals(tc, 10, level); CuAssertIntEquals(tc, 10, level);
curse *curse = get_curse(r->attribs, ct_find("gbdream")); curse *curse = get_curse(r->attribs, ct_find("gbdream"));
CuAssertTrue(tc, curse && curse->duration > 1); CuAssertTrue(tc, curse && curse->duration > 1);
@ -107,7 +110,7 @@ static void test_bad_dreams(CuTest *tc) {
CuAssertIntEquals_Msg(tc, "bad dreams have no effect on allies", 0, get_modifier(u1, SK_MELEE, 11, r, false)); 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)); CuAssertIntEquals_Msg(tc, "bad dreams give -1 to non-allies", -1, get_modifier(u2, SK_MELEE, 11, r, false));
free_castorder(&order); free_castorder(&co);
test_cleanup(); test_cleanup();
} }