forked from github/server
celan up tests, rename test_cleanup -> test_teardown.
This commit is contained in:
parent
250faefff4
commit
cff4e12fbd
73 changed files with 783 additions and 681 deletions
res/core
scripts/tests/e2
src
alchemy.test.c
attributes
battle.test.ccalendar.test.ccreport.test.cdirection.test.cdonations.test.ceconomy.test.cgive.test.cguard.test.citems
json.test.ckernel
alliance.test.cbuild.test.cbuilding.test.ccommand.test.cconfig.test.ccurse.test.cdatabase.test.cequipment.test.cfaction.test.cgroup.test.citem.test.cjsonconf.test.cmessages.test.corder.test.cplane.test.cpool.test.crace.test.cregion.test.csave.test.cship.hship.test.cspell.test.cunit.test.cxmlreader.c
keyword.test.claws.test.clighthouse.test.cmagic.test.cmarket.test.cmonsters.test.cmove.test.cnames.test.corderfile.test.cpiracy.test.cprefix.test.crenumber.test.creport.test.creports.test.cskill.test.cspells.test.cspells
spy.test.cstudy.test.csummary.test.ctests.ctests.htests.test.ctravelthru.test.ctriggers
upkeep.test.cutil
volcano.test.cvortex.test.cwormhole.test.c
|
@ -14,7 +14,7 @@
|
|||
</construction>
|
||||
</ship>
|
||||
|
||||
<ship name="dragonship" range="5" storm="1.00" damage="1.00" cargo="100000" cptskill="2" minskill="1" sumskill="50" opensea="yes">
|
||||
<ship name="dragonship" range="5" storm="1.00" damage="1.00" cargo="100000" cptskill="2" minskill="1" sumskill="50" opensea="yes" speedy="yes">
|
||||
<coast terrain="plain"/>
|
||||
<construction skill="shipcraft" minskill="2" maxsize="100">
|
||||
<requirement type="log" quantity="1"/>
|
||||
|
|
|
@ -41,3 +41,20 @@ function test_ship_happy_case()
|
|||
assert_equal(r2, u1.region)
|
||||
assert_equal(r2, u2.region)
|
||||
end
|
||||
|
||||
function test_speedy_ship()
|
||||
local r1 = region.create(0, 0, 'ocean')
|
||||
local f = faction.create("human", "hodor@eressea.de", "de")
|
||||
local u1 = unit.create(f, r1, 1)
|
||||
local u2 = unit.create(f, r1, 2)
|
||||
for x = 1, 10 do
|
||||
region.create(x, 0, 'ocean')
|
||||
end
|
||||
u1.ship = ship.create(r1, "dragonship")
|
||||
u2.ship = u1.ship
|
||||
u1:set_skill("sailing", 2) -- cptskill = 2
|
||||
u2:set_skill("sailing", 24) -- sumskill = 50
|
||||
u1:add_order("NACH O O O O O O O O O O")
|
||||
process_orders()
|
||||
assert_equal(5, u1.region.x)
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ static void test_herbsearch(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error59"));
|
||||
test_clear_messages(f);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_alchemy_suite(void)
|
||||
|
|
|
@ -30,7 +30,7 @@ static void test_rules(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, false, rule_stealth_anon());
|
||||
config_set("stealth.faction.anon", "1");
|
||||
CuAssertIntEquals(tc, true, rule_stealth_anon());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_otherfaction(CuTest *tc) {
|
||||
|
@ -45,7 +45,7 @@ static void test_otherfaction(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u->faction, visible_faction(f, u));
|
||||
a_add(&u->attribs, make_otherfaction(f));
|
||||
CuAssertPtrEquals(tc, f, visible_faction(f, u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_otherfaction_suite(void)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
static void test_stealth(CuTest *tc) {
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, 0));
|
||||
set_level(u, SK_STEALTH, 2);
|
||||
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
||||
|
@ -28,7 +28,7 @@ static void test_stealth(CuTest *tc) {
|
|||
u_seteffstealth(u, -1);
|
||||
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
||||
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_stealth_suite(void)
|
||||
|
|
|
@ -65,7 +65,7 @@ static void test_make_fighter(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, af->horses);
|
||||
CuAssertIntEquals(tc, 0, af->elvenhorses);
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static building_type * setup_castle(void) {
|
||||
|
@ -124,7 +124,7 @@ static void test_defenders_get_building_bonus(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, skilldiff(dt, at, 0));
|
||||
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_attackers_get_no_building_bonus(CuTest * tc)
|
||||
|
@ -153,7 +153,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc)
|
|||
|
||||
CuAssertPtrEquals(tc, 0, af->building);
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_building_bonus_respects_size(CuTest * tc)
|
||||
|
@ -190,7 +190,7 @@ static void test_building_bonus_respects_size(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, bld, af->building);
|
||||
CuAssertPtrEquals(tc, 0, df->building);
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_building_defence_bonus(CuTest * tc)
|
||||
|
@ -214,7 +214,7 @@ static void test_building_defence_bonus(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, building_protection(btype, 1));
|
||||
CuAssertIntEquals(tc, 2, building_protection(btype, 2));
|
||||
CuAssertIntEquals(tc, 2, building_protection(btype, 3));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static fighter *setup_fighter(battle **bp, unit *u) {
|
||||
|
@ -245,7 +245,7 @@ static void test_natural_armor(CuTest * tc)
|
|||
rc_set_param(rc, "armor.stamina", "2");
|
||||
CuAssertIntEquals(tc, 2, rc_armor_bonus(rc));
|
||||
CuAssertIntEquals(tc, 1, natural_armor(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_calculate_armor(CuTest * tc)
|
||||
|
@ -316,7 +316,7 @@ static void test_calculate_armor(CuTest * tc)
|
|||
CuAssertIntEquals_Msg(tc, "laen armor", 3, calculate_armor(dt, 0, 0, &magres));
|
||||
CuAssertIntEquals_Msg(tc, "laen magres bonus", 4, magres.sa[1]);
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_magic_resistance(CuTest *tc)
|
||||
|
@ -388,7 +388,7 @@ static void test_magic_resistance(CuTest *tc)
|
|||
CuAssert(tc, "damage reduction is never < 0.1", frac_equal(magres, frac_make(1, 10)));
|
||||
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_projectile_armor(CuTest * tc)
|
||||
|
@ -427,7 +427,7 @@ static void test_projectile_armor(CuTest * tc)
|
|||
wtype->flags = WTF_NONE;
|
||||
CuAssertIntEquals_Msg(tc, "no projectiles", 4, calculate_armor(dt, 0, wtype, 0));
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_battle_skilldiff(CuTest *tc)
|
||||
|
@ -461,7 +461,7 @@ static void test_battle_skilldiff(CuTest *tc)
|
|||
/* TODO: weapon modifiers, missiles, skill_formula */
|
||||
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_battle_skilldiff_building(CuTest *tc)
|
||||
|
@ -496,36 +496,37 @@ static void test_battle_skilldiff_building(CuTest *tc)
|
|||
CuAssertIntEquals(tc, -4, skilldiff(ta, td, 0));
|
||||
|
||||
free_battle(b);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void assert_skill(CuTest *tc, char *msg, unit *u, skill_t sk, int level, int week, int weekmax)
|
||||
{
|
||||
skill *sv = unit_skill(u, sk);
|
||||
char buf[256];
|
||||
if (sv) {
|
||||
sprintf(buf, "%s level %d != %d", msg, sv->level, level);
|
||||
CuAssertIntEquals_Msg(tc, (const char *)&buf, level, sv->level);
|
||||
sprintf(buf, "%s week %d !<= %d !<= %d", msg, week, sv->weeks, weekmax);
|
||||
CuAssert(tc, (const char *)&buf, sv->weeks >= week && sv->weeks <=weekmax);
|
||||
} else {
|
||||
CuAssertIntEquals_Msg(tc, msg, level, 0);
|
||||
CuAssertIntEquals_Msg(tc, msg, week, 0);
|
||||
}
|
||||
skill *sv = unit_skill(u, sk);
|
||||
char buf[256];
|
||||
if (sv) {
|
||||
sprintf(buf, "%s level %d != %d", msg, sv->level, level);
|
||||
CuAssertIntEquals_Msg(tc, (const char *)&buf, level, sv->level);
|
||||
sprintf(buf, "%s week %d !<= %d !<= %d", msg, week, sv->weeks, weekmax);
|
||||
CuAssert(tc, (const char *)&buf, sv->weeks >= week && sv->weeks <= weekmax);
|
||||
}
|
||||
else {
|
||||
CuAssertIntEquals_Msg(tc, msg, level, 0);
|
||||
CuAssertIntEquals_Msg(tc, msg, week, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_drain_exp(CuTest *tc)
|
||||
static void test_drain_exp(CuTest *tc)
|
||||
{
|
||||
unit *u;
|
||||
char *msg;
|
||||
int i;
|
||||
double rand;
|
||||
|
||||
|
||||
test_setup();
|
||||
config_set("study.random_progress", "0");
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
|
||||
|
||||
CuAssertIntEquals(tc, 3, unit_skill(u, SK_STAMINA)->level);
|
||||
CuAssertIntEquals(tc, 4, unit_skill(u, SK_STAMINA)->weeks);
|
||||
|
||||
|
@ -533,46 +534,47 @@ static void test_drain_exp(CuTest *tc)
|
|||
assert_skill(tc, msg, u, SK_STAMINA, 3, 4, 4);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
for (i=0; i<10; ++i) {
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 0);
|
||||
assert_skill(tc, msg = "0 change", u, SK_STAMINA, 3, 4, 4);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
for (i = 0; i < 10; ++i) {
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 0);
|
||||
assert_skill(tc, msg = "0 change", u, SK_STAMINA, 3, 4, 4);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
for (rand = 0.0; rand < 2.0; rand += 1) {
|
||||
random_source_inject_constant(rand);
|
||||
for (rand = 0.0; rand < 2.0; rand += 1) {
|
||||
random_source_inject_constant(rand);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 29);
|
||||
|
||||
assert_skill(tc, msg = "no change yet", u, SK_STAMINA, 3, 4, rand == 0.0?4:5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 1);
|
||||
|
||||
assert_skill(tc, msg = "random change", u, SK_STAMINA, 3, 4, rand == 0.0?4:5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 29);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 30);
|
||||
|
||||
assert_skill(tc, msg = "plus one", u, SK_STAMINA, 3, 5, 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
}
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 90);
|
||||
|
||||
assert_skill(tc, msg = "plus three", u, SK_STAMINA, 3, 7, 7);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 120);
|
||||
|
||||
assert_skill(tc, msg = "plus four", u, SK_STAMINA, 2, 5, 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
assert_skill(tc, msg = "no change yet", u, SK_STAMINA, 3, 4, rand == 0.0 ? 4 : 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 1);
|
||||
|
||||
assert_skill(tc, msg = "random change", u, SK_STAMINA, 3, 4, rand == 0.0 ? 4 : 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 30);
|
||||
|
||||
assert_skill(tc, msg = "plus one", u, SK_STAMINA, 3, 5, 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
}
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 90);
|
||||
|
||||
assert_skill(tc, msg = "plus three", u, SK_STAMINA, 3, 7, 7);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
drain_exp(u, 120);
|
||||
|
||||
assert_skill(tc, msg = "plus four", u, SK_STAMINA, 2, 5, 5);
|
||||
assert_skill(tc, msg, u, SK_MINING, 0, 0, 0);
|
||||
}
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_battle_suite(void)
|
||||
|
|
|
@ -16,7 +16,7 @@ static void test_calendar_config(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, first_turn());
|
||||
config_set_int("game.start", 42);
|
||||
CuAssertIntEquals(tc, 42, first_turn());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_calendar(CuTest * tc)
|
||||
|
@ -62,7 +62,7 @@ static void test_calendar(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 2, gd.month);
|
||||
CuAssertIntEquals(tc, 0, gd.week);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_calendar_season(CuTest * tc)
|
||||
|
@ -85,7 +85,7 @@ static void test_calendar_season(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, gd.month);
|
||||
CuAssertIntEquals(tc, 1, gd.week);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_calendar_suite(void)
|
||||
|
|
|
@ -36,7 +36,7 @@ static void test_cr_unit(CuTest *tc) {
|
|||
region *r;
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -48,7 +48,7 @@ static void test_cr_unit(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, line, "EINHEIT 1234");
|
||||
mstream_done(&strm);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void setup_resources(void) {
|
||||
|
@ -158,7 +158,7 @@ static void test_cr_resources(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "1;number", line);
|
||||
|
||||
mstream_done(&strm);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cr_mallorn(CuTest *tc) {
|
||||
|
@ -204,7 +204,7 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
mstream_done(&strm);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static int cr_get_int(stream *strm, const char *match, int def)
|
||||
|
@ -319,7 +319,7 @@ static void test_cr_factionstealth(CuTest *tc) {
|
|||
u->flags &= ~UFL_ANON_FACTION;
|
||||
mstream_done(&strm);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_creport_suite(void)
|
||||
|
|
|
@ -16,7 +16,7 @@ static void test_init_directions(CuTest *tc) {
|
|||
locale_setstring(lang, "dir_nw", "NW");
|
||||
init_directions(lang);
|
||||
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nw", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_init_direction(CuTest *tc) {
|
||||
|
@ -33,7 +33,7 @@ static void test_init_direction(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, D_EAST, get_direction("ost", lang));
|
||||
CuAssertIntEquals(tc, D_EAST, get_direction("O", lang));
|
||||
CuAssertIntEquals(tc, NODIRECTION, get_direction("east", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_finddirection(CuTest *tc) {
|
||||
|
@ -47,7 +47,7 @@ static void test_finddirection(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, D_PAUSE, finddirection("pause"));
|
||||
CuAssertIntEquals(tc, NODIRECTION, finddirection(""));
|
||||
CuAssertIntEquals(tc, NODIRECTION, finddirection("potato"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_direction_suite(void)
|
||||
|
|
|
@ -11,7 +11,7 @@ static void test_add_donation(CuTest *tc) {
|
|||
faction *f1, *f2;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
f1 = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
|
@ -19,7 +19,7 @@ static void test_add_donation(CuTest *tc) {
|
|||
report_donations();
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->individual_messages->msgs, "donation"));
|
||||
free_donations();
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_donations_suite(void)
|
||||
|
|
|
@ -31,7 +31,7 @@ static void test_give_control_building(CuTest * tc)
|
|||
struct faction *f;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
b = test_create_building(r, 0);
|
||||
|
@ -42,7 +42,7 @@ static void test_give_control_building(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u1, building_owner(b));
|
||||
give_control(u1, u2);
|
||||
CuAssertPtrEquals(tc, u2, building_owner(b));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_control_ship(CuTest * tc)
|
||||
|
@ -52,7 +52,7 @@ static void test_give_control_ship(CuTest * tc)
|
|||
struct faction *f;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
sh = test_create_ship(r, 0);
|
||||
|
@ -63,7 +63,7 @@ static void test_give_control_ship(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u1, ship_owner(sh));
|
||||
give_control(u1, u2);
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
struct steal {
|
||||
|
@ -83,13 +83,13 @@ static void test_steal_okay(CuTest * tc) {
|
|||
race *rc;
|
||||
struct terrain_type *ter;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
ter = test_create_terrain("plain", LAND_REGION);
|
||||
rc = test_create_race("human");
|
||||
rc->flags = 0;
|
||||
setup_steal(&env, ter, rc);
|
||||
CuAssertPtrEquals(tc, 0, steal_message(env.u, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_steal_nosteal(CuTest * tc) {
|
||||
|
@ -98,14 +98,14 @@ static void test_steal_nosteal(CuTest * tc) {
|
|||
terrain_type *ter;
|
||||
message *msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
ter = test_create_terrain("plain", LAND_REGION);
|
||||
rc = test_create_race("human");
|
||||
rc->flags = RCF_NOSTEAL;
|
||||
setup_steal(&env, ter, rc);
|
||||
CuAssertPtrNotNull(tc, msg = steal_message(env.u, 0));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_steal_ocean(CuTest * tc) {
|
||||
|
@ -114,13 +114,13 @@ static void test_steal_ocean(CuTest * tc) {
|
|||
terrain_type *ter;
|
||||
message *msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
ter = test_create_terrain("ocean", SEA_REGION);
|
||||
rc = test_create_race("human");
|
||||
setup_steal(&env, ter, rc);
|
||||
CuAssertPtrNotNull(tc, msg = steal_message(env.u, 0));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static struct unit *create_recruiter(void) {
|
||||
|
@ -153,7 +153,7 @@ static void test_heroes_dont_recruit(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 1, u->number);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_herorecruit"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_normals_recruit(CuTest * tc) {
|
||||
|
@ -168,7 +168,7 @@ static void test_normals_recruit(CuTest * tc) {
|
|||
|
||||
CuAssertIntEquals(tc, 2, u->number);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +246,7 @@ static void test_trade_insect(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 5, get_item(u, it_silver));
|
||||
|
||||
terraform_region(r, get_terrain("swamp"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buy_cmd(CuTest *tc) {
|
||||
|
@ -297,7 +297,7 @@ static void test_buy_cmd(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "buyamount"));
|
||||
CuAssertIntEquals(tc, 1, get_item(u, it_luxury));
|
||||
CuAssertIntEquals(tc, 995, get_item(u, rt_silver->itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_tax_cmd(CuTest *tc) {
|
||||
|
@ -355,7 +355,7 @@ static void test_tax_cmd(CuTest *tc) {
|
|||
test_clear_messages(u->faction);
|
||||
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,7 +370,7 @@ static void test_maintain_buildings(CuTest *tc) {
|
|||
maintenance *req;
|
||||
item_type *itype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
btype = test_create_buildingtype("Hort");
|
||||
btype->maxsize = 10;
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
@ -422,7 +422,7 @@ static void test_maintain_buildings(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_noowner"));
|
||||
test_clear_messagelist(&r->msgs);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_recruit(CuTest *tc) {
|
||||
|
@ -446,7 +446,7 @@ static void test_recruit(CuTest *tc) {
|
|||
add_recruits(u, 1, 2);
|
||||
CuAssertIntEquals(tc, 3, u->number);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "recruit"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_income(CuTest *tc)
|
||||
|
@ -459,7 +459,7 @@ static void test_income(CuTest *tc)
|
|||
CuAssertIntEquals(tc, 20, income(u));
|
||||
u->number = 5;
|
||||
CuAssertIntEquals(tc, 100, income(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_modify_material(CuTest *tc) {
|
||||
|
@ -507,7 +507,7 @@ static void test_modify_material(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 2, get_item(u, itype));
|
||||
CuAssertIntEquals(tc, 0, get_item(u, rtype->itype));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_modify_skill(CuTest *tc) {
|
||||
|
@ -565,7 +565,7 @@ static void test_modify_skill(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 5, get_item(u, itype));
|
||||
CuAssertIntEquals(tc, 1, get_item(u, rtype->itype));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
||||
|
@ -667,7 +667,7 @@ static void test_modify_production(CuTest *tc) {
|
|||
split_allocations(u->region);
|
||||
CuAssertIntEquals(tc, 38, get_item(u, itype));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_economy_suite(void)
|
||||
|
|
|
@ -71,7 +71,7 @@ static void test_give_unit(CuTest * tc) {
|
|||
CuAssertPtrEquals(tc, 0, env.f1->units);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "give_person"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(env.f2->msgs, "receive_person"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_unit_limits(CuTest * tc) {
|
||||
|
@ -89,7 +89,7 @@ static void test_give_unit_limits(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 1, env.f1->num_units);
|
||||
CuAssertIntEquals(tc, 1, env.f2->num_units);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "too_many_units_in_faction"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_unit_to_peasants(CuTest * tc) {
|
||||
|
@ -102,7 +102,7 @@ static void test_give_unit_to_peasants(CuTest * tc) {
|
|||
give_unit(env.src, NULL, NULL);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
CuAssertIntEquals(tc, 1, rpeasants(env.r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_unit_to_ocean(CuTest * tc) {
|
||||
|
@ -114,7 +114,7 @@ static void test_give_unit_to_ocean(CuTest * tc) {
|
|||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
give_unit(env.src, NULL, NULL);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men(CuTest * tc) {
|
||||
|
@ -125,7 +125,7 @@ static void test_give_men(CuTest * tc) {
|
|||
CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL));
|
||||
CuAssertIntEquals(tc, 2, env.dst->number);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_magicians(CuTest * tc) {
|
||||
|
@ -150,7 +150,7 @@ static void test_give_men_magicians(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, p+1, rpeasants(env.r));
|
||||
msg_release(msg);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_limit(CuTest * tc) {
|
||||
|
@ -180,7 +180,7 @@ static void test_give_men_limit(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 0, env.f1->newbies);
|
||||
msg_release(msg);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_in_ocean(CuTest * tc) {
|
||||
|
@ -196,7 +196,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
|
|||
CuAssertStrEquals(tc, "give_person_ocean", (const char *)msg->parameters[0].v);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_too_many(CuTest * tc) {
|
||||
|
@ -207,7 +207,7 @@ static void test_give_men_too_many(CuTest * tc) {
|
|||
CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL));
|
||||
CuAssertIntEquals(tc, 2, env.dst->number);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_none(CuTest * tc) {
|
||||
|
@ -222,7 +222,7 @@ static void test_give_men_none(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 1, env.dst->number);
|
||||
CuAssertIntEquals(tc, 1, env.src->number);
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_other_faction(CuTest * tc) {
|
||||
|
@ -239,7 +239,7 @@ static void test_give_men_other_faction(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 2, env.dst->number);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_requires_contact(CuTest * tc) {
|
||||
|
@ -264,7 +264,7 @@ static void test_give_men_requires_contact(CuTest * tc) {
|
|||
|
||||
msg_release(msg);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_men_not_to_self(CuTest * tc) {
|
||||
|
@ -277,7 +277,7 @@ static void test_give_men_not_to_self(CuTest * tc) {
|
|||
CuAssertStrEquals(tc, "error10", test_get_messagetype(msg));
|
||||
CuAssertIntEquals(tc, 1, env.src->number);
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_peasants(CuTest * tc) {
|
||||
|
@ -294,7 +294,7 @@ static void test_give_peasants(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
CuAssertIntEquals(tc, 1, rpeasants(env.r));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give(CuTest * tc) {
|
||||
|
@ -312,7 +312,7 @@ static void test_give(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, -1, give_item(10, env.itype, env.src, env.dst, 0));
|
||||
CuAssertIntEquals(tc, 0, i_get(env.src->items, env.itype));
|
||||
CuAssertIntEquals(tc, 10, i_get(env.dst->items, env.itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_cmd(CuTest * tc) {
|
||||
|
@ -333,7 +333,7 @@ static void test_give_cmd(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 5, i_get(env.dst->items, env.itype));
|
||||
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_herbs(CuTest * tc) {
|
||||
|
@ -352,7 +352,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 0, i_get(env.src->items, env.itype));
|
||||
CuAssertIntEquals(tc, 10, i_get(env.dst->items, env.itype));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_okay(CuTest * tc) {
|
||||
|
@ -364,7 +364,7 @@ static void test_give_okay(CuTest * tc) {
|
|||
|
||||
config_set("rules.give.flags", "0");
|
||||
CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_denied_by_rules(CuTest * tc) {
|
||||
|
@ -379,7 +379,7 @@ static void test_give_denied_by_rules(CuTest * tc) {
|
|||
config_set("rules.give.flags", "0");
|
||||
CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_dead_unit(CuTest * tc) {
|
||||
|
@ -394,7 +394,7 @@ static void test_give_dead_unit(CuTest * tc) {
|
|||
freset(env.dst, UFL_ISNEW);
|
||||
CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_new_unit(CuTest * tc) {
|
||||
|
@ -407,7 +407,7 @@ static void test_give_new_unit(CuTest * tc) {
|
|||
env.dst->number = 0;
|
||||
fset(env.dst, UFL_ISNEW);
|
||||
CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_give_invalid_target(CuTest *tc) {
|
||||
|
@ -428,7 +428,7 @@ static void test_give_invalid_target(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 10, i_get(env.src->items, env.itype));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(env.f1->msgs, "feedback_unit_not_found"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_give_suite(void)
|
||||
|
|
|
@ -23,7 +23,7 @@ static void test_is_guarded(CuTest *tc) {
|
|||
region *r;
|
||||
race *rc;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
@ -32,7 +32,7 @@ static void test_is_guarded(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, is_guarded(r, u1));
|
||||
setguard(u2, true);
|
||||
CuAssertPtrEquals(tc, u2, is_guarded(r, u1));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_guard_unskilled(CuTest * tc)
|
||||
|
@ -57,7 +57,7 @@ static void test_guard_unskilled(CuTest * tc)
|
|||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_guard_armed(CuTest * tc)
|
||||
|
@ -76,7 +76,7 @@ static void test_guard_armed(CuTest * tc)
|
|||
set_level(ug, SK_MELEE, 2);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_is_guard(CuTest * tc)
|
||||
|
@ -97,7 +97,7 @@ static void test_is_guard(CuTest * tc)
|
|||
set_level(ug, SK_MELEE, 1);
|
||||
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
||||
CuAssertTrue(tc, is_guard(ug));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_guard_unarmed(CuTest * tc)
|
||||
|
@ -114,7 +114,7 @@ static void test_guard_unarmed(CuTest * tc)
|
|||
ug = test_create_unit(test_create_faction(rc), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_guard_monsters(CuTest * tc)
|
||||
|
@ -128,7 +128,7 @@ static void test_guard_monsters(CuTest * tc)
|
|||
ug = test_create_unit(get_monsters(), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_update_guard(CuTest * tc)
|
||||
|
@ -156,7 +156,7 @@ static void test_update_guard(CuTest * tc)
|
|||
update_guards();
|
||||
CuAssertTrue(tc, ! is_guard(ug));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_guard_on(CuTest * tc)
|
||||
|
@ -229,7 +229,7 @@ static void test_guard_on(CuTest * tc)
|
|||
config_set("NewbieImmunity", NULL);
|
||||
|
||||
test_clear_messages(ug->faction);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_guard_suite(void)
|
||||
|
|
|
@ -65,7 +65,7 @@ struct order *ord)
|
|||
|
||||
int
|
||||
use_manacrystal(struct unit *u, const struct item_type *itype, int amount,
|
||||
struct order *ord)
|
||||
struct order *ord)
|
||||
{
|
||||
int i, sp = 0;
|
||||
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#include <CuTest.h>
|
||||
|
||||
static void test_manacrystal(CuTest *tc) {
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_skillpotion(CuTest *tc) {
|
||||
|
@ -25,7 +24,7 @@ static void test_skillpotion(CuTest *tc) {
|
|||
int initialWeeks_Stamina = 0;
|
||||
int initialWeeks_Magic = 0;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(NULL), findregion(0, 0));
|
||||
itype = test_create_itemtype("skillpotion");
|
||||
|
@ -57,7 +56,7 @@ static void test_skillpotion(CuTest *tc) {
|
|||
pSkill = unit_skill(u, SK_MAGIC);
|
||||
CuAssertIntEquals(tc, initialWeeks_Magic - 3, pSkill->weeks);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_xerewards_suite(void)
|
||||
|
|
|
@ -40,6 +40,7 @@ static void test_export_no_regions(CuTest * tc) {
|
|||
int err;
|
||||
size_t len;
|
||||
|
||||
test_setup();
|
||||
mstream_init(&out);
|
||||
err = json_export(&out, EXPORT_REGIONS);
|
||||
CuAssertIntEquals(tc, 0, err);
|
||||
|
@ -48,7 +49,7 @@ static void test_export_no_regions(CuTest * tc) {
|
|||
buf[len] = '\0';
|
||||
CuAssertStrEquals(tc, "{}", strip(buf));
|
||||
mstream_done(&out);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static cJSON *export_a_region(CuTest * tc, const struct terrain_type *terrain, region **_r) {
|
||||
|
@ -93,24 +94,26 @@ static void test_export_land_region(CuTest * tc) {
|
|||
region *r;
|
||||
struct terrain_type *terrain;
|
||||
cJSON *json, *attr;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
terrain = test_create_terrain("plain", LAND_REGION);
|
||||
json = export_a_region(tc, terrain, &r);
|
||||
CuAssertPtrNotNull(tc, attr = cJSON_GetObjectItem(json, "name"));
|
||||
CuAssertStrEquals(tc, r->land->name, attr->valuestring);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_export_ocean_region(CuTest * tc) {
|
||||
struct terrain_type *terrain;
|
||||
cJSON *json;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
json = export_a_region(tc, terrain, 0);
|
||||
CuAssertPtrEquals(tc, 0, cJSON_GetObjectItem(json, "name"));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_export_no_factions(CuTest * tc) {
|
||||
|
@ -119,6 +122,7 @@ static void test_export_no_factions(CuTest * tc) {
|
|||
int err;
|
||||
size_t len;
|
||||
|
||||
test_setup();
|
||||
mstream_init(&out);
|
||||
err = json_export(&out, EXPORT_FACTIONS);
|
||||
CuAssertIntEquals(tc, 0, err);
|
||||
|
@ -127,7 +131,7 @@ static void test_export_no_factions(CuTest * tc) {
|
|||
buf[len] = 0;
|
||||
CuAssertStrEquals(tc, "{}", strip(buf));
|
||||
mstream_done(&out);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_json_suite(void) {
|
||||
|
|
|
@ -42,7 +42,7 @@ static void test_alliance_make(CuTest *tc) {
|
|||
free_alliances();
|
||||
CuAssertPtrEquals(tc, 0, findalliance(1));
|
||||
CuAssertPtrEquals(tc, 0, alliances);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_join(CuTest *tc) {
|
||||
|
@ -61,7 +61,7 @@ static void test_alliance_join(CuTest *tc) {
|
|||
setalliance(fix.f1, 0);
|
||||
CuAssertPtrEquals(tc, fix.f2, alliance_get_leader(al));
|
||||
CuAssertTrue(tc, !is_allied(fix.f1, fix.f2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_dead_faction(CuTest *tc) {
|
||||
|
@ -82,7 +82,7 @@ static void test_alliance_dead_faction(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, f2, alliance_get_leader(al));
|
||||
CuAssertPtrEquals(tc, NULL, f->alliance);
|
||||
CuAssertTrue(tc, !f->_alive);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_cmd(CuTest *tc) {
|
||||
|
@ -109,7 +109,7 @@ static void test_alliance_cmd(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, al, findalliance(42));
|
||||
CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
|
||||
CuAssertPtrEquals(tc, al, u2->faction->alliance);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_limits(CuTest *tc) {
|
||||
|
@ -132,7 +132,7 @@ static void test_alliance_limits(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, f_get_alliance(u2->faction));
|
||||
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "too_many_units_in_alliance"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_cmd_kick(CuTest *tc) {
|
||||
|
@ -153,7 +153,7 @@ static void test_alliance_cmd_kick(CuTest *tc) {
|
|||
alliance_cmd();
|
||||
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
|
||||
CuAssertPtrEquals(tc, 0, f_get_alliance(u2->faction));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_cmd_no_invite(CuTest *tc) {
|
||||
|
@ -173,7 +173,7 @@ static void test_alliance_cmd_no_invite(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, f_get_alliance(u1->faction));
|
||||
CuAssertPtrEquals(tc, 0, f_get_alliance(u2->faction));
|
||||
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_cmd_leave(CuTest *tc) {
|
||||
|
@ -194,7 +194,7 @@ static void test_alliance_cmd_leave(CuTest *tc) {
|
|||
alliance_cmd();
|
||||
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
|
||||
CuAssertPtrEquals(tc, 0, f_get_alliance(u1->faction));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_alliance_cmd_transfer(CuTest *tc) {
|
||||
|
@ -213,7 +213,7 @@ static void test_alliance_cmd_transfer(CuTest *tc) {
|
|||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_TRANSFER], itoa36(u2->faction->no)));
|
||||
alliance_cmd();
|
||||
CuAssertPtrEquals(tc, u2->faction, alliance_get_leader(al));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_alliance_suite(void)
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef struct build_fixture {
|
|||
} build_fixture;
|
||||
|
||||
static unit * setup_build(build_fixture *bf) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
init_resources();
|
||||
|
||||
test_create_itemtype("stone");
|
||||
|
@ -53,7 +53,7 @@ static unit * setup_build(build_fixture *bf) {
|
|||
|
||||
static void teardown_build(build_fixture *bf) {
|
||||
free(bf->cons.materials);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_build_requires_materials(CuTest *tc) {
|
||||
|
@ -254,7 +254,7 @@ static void test_build_destroy_road(CuTest *tc)
|
|||
order *ord;
|
||||
message *m;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
mt_register(mt_new_va("destroy_road", "unit:unit", "from:region", "to:region", 0));
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
@ -282,7 +282,7 @@ static void test_build_destroy_road(CuTest *tc)
|
|||
set_level(u, SK_ROAD_BUILDING, 2);
|
||||
CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
|
||||
CuAssertIntEquals(tc, 87, rroad(r, D_EAST));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
unit *test_create_guard(region *r, faction *f, race *rc) {
|
||||
|
@ -308,7 +308,7 @@ static void test_build_destroy_road_guard(CuTest *tc)
|
|||
unit *u, *ug;
|
||||
order *ord;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
|
@ -330,7 +330,7 @@ static void test_build_destroy_road_guard(CuTest *tc)
|
|||
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "error70"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "destroy_road"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_build_destroy_road_limit(CuTest *tc)
|
||||
|
@ -340,7 +340,7 @@ static void test_build_destroy_road_limit(CuTest *tc)
|
|||
unit *u;
|
||||
order *ord;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
|
@ -357,7 +357,7 @@ static void test_build_destroy_road_limit(CuTest *tc)
|
|||
CuAssertIntEquals(tc, 98, rroad(r, D_EAST));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "destroy_road"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_build_destroy_cmd(CuTest *tc) {
|
||||
|
@ -369,7 +369,7 @@ static void test_build_destroy_cmd(CuTest *tc) {
|
|||
u->thisorder = create_order(K_DESTROY, f->locale, NULL);
|
||||
CuAssertIntEquals(tc, 138, destroy_cmd(u, u->thisorder));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error138"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_build_roqf_factor(CuTest *tc) {
|
||||
|
@ -377,7 +377,7 @@ static void test_build_roqf_factor(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 10, roqf_factor());
|
||||
config_set("rules.economy.roqf", "50");
|
||||
CuAssertIntEquals(tc, 50, roqf_factor());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_build_suite(void)
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_register_building(CuTest * tc)
|
|||
building_type *btype;
|
||||
int cache = 0;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
CuAssertIntEquals(tc, true, bt_changed(&cache));
|
||||
CuAssertIntEquals(tc, false, bt_changed(&cache));
|
||||
|
@ -30,7 +30,7 @@ static void test_register_building(CuTest * tc)
|
|||
|
||||
free_buildingtypes();
|
||||
CuAssertIntEquals(tc, true, bt_changed(&cache));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_building_set_owner(CuTest * tc)
|
||||
|
@ -55,7 +55,7 @@ static void test_building_set_owner(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u1, building_owner(bld));
|
||||
building_set_owner(u2);
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_next_when_empty(CuTest * tc)
|
||||
|
@ -81,7 +81,7 @@ static void test_buildingowner_goes_to_next_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
u->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_other_when_empty(CuTest * tc)
|
||||
|
@ -108,7 +108,7 @@ static void test_buildingowner_goes_to_other_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
u->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc)
|
||||
|
@ -139,7 +139,7 @@ static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u3, building_owner(bld));
|
||||
u3->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_next_after_leave(CuTest * tc)
|
||||
|
@ -164,7 +164,7 @@ static void test_buildingowner_goes_to_next_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
leave_building(u);
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_other_after_leave(CuTest * tc)
|
||||
|
@ -190,7 +190,7 @@ static void test_buildingowner_goes_to_other_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
leave_building(u);
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc)
|
||||
|
@ -223,7 +223,7 @@ static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
leave_building(u2);
|
||||
CuAssertPtrEquals(tc, 0, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingowner_resets_when_empty(CuTest * tc)
|
||||
|
@ -249,7 +249,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, building_owner(bld));
|
||||
u->number = 1;
|
||||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
||||
|
@ -282,12 +282,13 @@ void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, building_owner(bld));
|
||||
u2->number = 1;
|
||||
CuAssertPtrEquals(tc, u2, building_owner(bld));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_btype_defaults(CuTest *tc) {
|
||||
building_type * btype;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
|
||||
btype = bt_get_or_create("hodor");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
@ -303,7 +304,7 @@ static void test_btype_defaults(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, btype->magresbonus);
|
||||
CuAssertIntEquals(tc, 0, btype->fumblebonus);
|
||||
CuAssertIntEquals(tc, 0, btype->flags);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingtype_exists(CuTest * tc)
|
||||
|
@ -341,6 +342,7 @@ static void test_buildingtype_exists(CuTest * tc)
|
|||
CuAssertTrue(tc, buildingtype_exists(r, btype, true));
|
||||
freset(b, BLD_MAINTAINED);
|
||||
CuAssertTrue(tc, !buildingtype_exists(r, btype, true));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_active_building(CuTest *tc) {
|
||||
|
@ -349,7 +351,7 @@ static void test_active_building(CuTest *tc) {
|
|||
unit *u;
|
||||
building_type *btype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
btype = test_create_buildingtype("castle");
|
||||
assert(btype && btype->maxsize == -1);
|
||||
|
@ -375,14 +377,14 @@ static void test_active_building(CuTest *tc) {
|
|||
b->flags &= ~BLD_MAINTAINED;
|
||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_safe_building(CuTest *tc) {
|
||||
building_type *btype;
|
||||
unit *u1, *u2;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
btype = test_create_buildingtype("castle");
|
||||
u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
u2 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
|
@ -397,7 +399,7 @@ static void test_safe_building(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
u1->building->size = 3;
|
||||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_building_type(CuTest *tc) {
|
||||
|
@ -406,7 +408,7 @@ static void test_building_type(CuTest *tc) {
|
|||
btype = test_create_buildingtype("house");
|
||||
CuAssertIntEquals(tc, true, is_building_type(btype, "house"));
|
||||
CuAssertIntEquals(tc, false, is_building_type(btype, "castle"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cmp_castle_size(CuTest *tc) {
|
||||
|
@ -427,7 +429,7 @@ static void test_cmp_castle_size(CuTest *tc) {
|
|||
CuAssertTrue(tc, cmp_castle_size(b1, b2) < 0);
|
||||
CuAssertTrue(tc, cmp_castle_size(b2, b1) > 0);
|
||||
CuAssertTrue(tc, cmp_castle_size(b1, b1) == 0);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cmp_wage(CuTest *tc) {
|
||||
|
@ -447,7 +449,7 @@ static void test_cmp_wage(CuTest *tc) {
|
|||
CuAssertTrue(tc, cmp_wage(b1, b2) < 0);
|
||||
CuAssertTrue(tc, cmp_wage(b2, b1) > 0);
|
||||
CuAssertTrue(tc, cmp_wage(b1, b1) == 0);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cmp_taxes(CuTest *tc) {
|
||||
|
@ -472,7 +474,7 @@ static void test_cmp_taxes(CuTest *tc) {
|
|||
CuAssertTrue(tc, cmp_taxes(b1, b2) < 0);
|
||||
CuAssertTrue(tc, cmp_taxes(b2, b1) > 0);
|
||||
CuAssertTrue(tc, cmp_taxes(b1, b1) == 0);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cmp_current_owner(CuTest *tc) {
|
||||
|
@ -505,7 +507,7 @@ static void test_cmp_current_owner(CuTest *tc) {
|
|||
CuAssertTrue(tc, cmp_current_owner(b2, b1) < 0);
|
||||
CuAssertTrue(tc, cmp_current_owner(b1, b2) > 0);
|
||||
CuAssertTrue(tc, cmp_current_owner(b1, b1) == 0);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_building_effsize(CuTest *tc) {
|
||||
|
@ -530,7 +532,7 @@ static void test_building_effsize(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
|
||||
b->size = 20;
|
||||
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static int cmp_size(const building *lhs, const building *rhs) {
|
||||
|
@ -553,7 +555,7 @@ static void test_largestbuilding(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, b1, largestbuilding(r, cmp_size, false));
|
||||
b2->size = 3;
|
||||
CuAssertPtrEquals(tc, b2, largestbuilding(r, cmp_size, false));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingtype(CuTest *tc) {
|
||||
|
@ -567,7 +569,7 @@ static void test_buildingtype(CuTest *tc) {
|
|||
btype = bt_get_or_create("portal");
|
||||
CuAssertPtrEquals(tc, NULL, btype->construction);
|
||||
CuAssertStrEquals(tc, "portal", buildingtype(btype, NULL, 1));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_buildingcapacity(CuTest *tc) {
|
||||
|
@ -587,7 +589,7 @@ static void test_buildingcapacity(CuTest *tc) {
|
|||
btype->capacity = -1;
|
||||
CuAssertTrue(tc, building_finished(b));
|
||||
CuAssertIntEquals(tc, btype->maxcapacity, buildingcapacity(b));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_building_suite(void)
|
||||
|
|
|
@ -48,7 +48,7 @@ static void test_command(CuTest * tc) {
|
|||
do_command(st->root, u, u->thisorder);
|
||||
CuAssertIntEquals(tc, u->number, 2);
|
||||
stree_free(st);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_command_suite(void)
|
||||
|
|
|
@ -57,7 +57,7 @@ static void test_read_unitid(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_getunit(CuTest *tc) {
|
||||
|
@ -118,7 +118,7 @@ static void test_getunit(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, u2);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_set_param(CuTest * tc)
|
||||
|
@ -135,7 +135,7 @@ static void test_get_set_param(CuTest * tc)
|
|||
set_param(&par, "bar", NULL);
|
||||
CuAssertPtrEquals(tc, NULL, (void *)get_param(par, "bar"));
|
||||
free_params(&par);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_param_int(CuTest * tc)
|
||||
|
@ -148,7 +148,7 @@ static void test_param_int(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 23, get_param_int(par, "foo", 0));
|
||||
CuAssertIntEquals(tc, 42, get_param_int(par, "bar", 0));
|
||||
free_params(&par);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_param_flt(CuTest * tc)
|
||||
|
@ -161,7 +161,7 @@ static void test_param_flt(CuTest * tc)
|
|||
CuAssertDblEquals(tc, 23.0, get_param_flt(par, "foo", 0.0), 0.01);
|
||||
CuAssertDblEquals(tc, 42.0, get_param_flt(par, "bar", 0.0), 0.01);
|
||||
free_params(&par);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_forbiddenid(CuTest *tc) {
|
||||
|
@ -189,7 +189,7 @@ static void test_default_order(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, ord);
|
||||
CuAssertIntEquals(tc, K_WORK, getkeyword(ord));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_config_cache(CuTest *tc) {
|
||||
|
@ -202,7 +202,7 @@ static void test_config_cache(CuTest *tc) {
|
|||
CuAssertTrue(tc, !config_changed(&key));
|
||||
free_config();
|
||||
CuAssertTrue(tc, config_changed(&key));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rules(CuTest *tc) {
|
||||
|
@ -247,7 +247,7 @@ static void test_config_inifile(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Eressea", game_name());
|
||||
CuAssertIntEquals(tc, 42, game_id());
|
||||
iniparser_freedict(ini);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_findparam(CuTest *tc) {
|
||||
|
@ -270,7 +270,7 @@ static void test_findparam(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", de, true));
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam_block("PARTEI", en, false));
|
||||
CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", en, true));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_game_mailcmd(CuTest *tc) {
|
||||
|
@ -283,7 +283,7 @@ static void test_game_mailcmd(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "HODOR", game_mailcmd());
|
||||
config_set("game.mailcmd", "ERESSEA");
|
||||
CuAssertStrEquals(tc, "ERESSEA", game_mailcmd());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_config_suite(void)
|
||||
|
|
|
@ -31,6 +31,8 @@ static void test_curse(CuTest * tc)
|
|||
int cid;
|
||||
|
||||
curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL };
|
||||
|
||||
test_setup();
|
||||
c = create_curse(NULL, &attrs, &ct_dummy, 1.0, 1, 1, 1);
|
||||
cid = c->no;
|
||||
result = findcurse(cid);
|
||||
|
@ -38,7 +40,7 @@ static void test_curse(CuTest * tc)
|
|||
a_remove(&attrs, attrs);
|
||||
result = findcurse(cid);
|
||||
CuAssertPtrEquals(tc, NULL, result);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -48,14 +50,14 @@ typedef struct {
|
|||
} curse_fixture;
|
||||
|
||||
static void setup_curse(curse_fixture *fix, const char *name) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
fix->r = test_create_region(0, 0, NULL);
|
||||
fix->u = test_create_unit(test_create_faction(NULL), fix->r);
|
||||
fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0);
|
||||
}
|
||||
|
||||
static void cleanup_curse(curse_fixture *fix) {
|
||||
test_cleanup();
|
||||
static void teardown_curse(curse_fixture *fix) {
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_magicstreet(CuTest *tc) {
|
||||
|
@ -66,7 +68,7 @@ static void test_magicstreet(CuTest *tc) {
|
|||
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
|
||||
CuAssertStrEquals(tc, "curseinfo::magicstreet", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
cleanup_curse(&fix);
|
||||
teardown_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_magicstreet_warning(CuTest *tc) {
|
||||
|
@ -77,7 +79,7 @@ static void test_magicstreet_warning(CuTest *tc) {
|
|||
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
|
||||
CuAssertStrEquals(tc, "curseinfo::magicstreetwarn", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
cleanup_curse(&fix);
|
||||
teardown_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_good_dreams(CuTest *tc) {
|
||||
|
@ -88,7 +90,7 @@ static void test_good_dreams(CuTest *tc) {
|
|||
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
|
||||
CuAssertStrEquals(tc, "curseinfo::gooddream", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
cleanup_curse(&fix);
|
||||
teardown_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_bad_dreams(CuTest *tc) {
|
||||
|
@ -99,7 +101,7 @@ static void test_bad_dreams(CuTest *tc) {
|
|||
msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
|
||||
CuAssertStrEquals(tc, "curseinfo::baddream", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
cleanup_curse(&fix);
|
||||
teardown_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_memstream(CuTest *tc) {
|
||||
|
@ -156,7 +158,7 @@ static void test_write_flag(CuTest *tc) {
|
|||
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
cleanup_curse(&fix);
|
||||
teardown_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_curse_ids(CuTest *tc) {
|
||||
|
@ -172,7 +174,7 @@ static void test_curse_ids(CuTest *tc) {
|
|||
CuAssertTrue(tc, c1->no != c2->no);
|
||||
a_remove(&a1, a1);
|
||||
a_remove(&a2, a2);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_curse_flags(CuTest *tc) {
|
||||
|
@ -193,7 +195,7 @@ static void test_curse_flags(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 2, (int)c1->effect);
|
||||
CuAssertIntEquals(tc, 1, (int)c1->vigour);
|
||||
CuAssertIntEquals(tc, 1, c1->duration);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_curse_suite(void)
|
||||
|
|
|
@ -28,7 +28,7 @@ static void test_save_load_order(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, s, od->_str);
|
||||
odata_release(od);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_db_suite(void)
|
||||
|
|
|
@ -43,7 +43,7 @@ static void test_equipment(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, mage);
|
||||
CuAssertPtrNotNull(tc, mage->spellbook);
|
||||
CuAssertTrue(tc, u_hasspell(u, sp));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_equipment(CuTest * tc)
|
||||
|
@ -66,7 +66,7 @@ static void test_get_equipment(CuTest * tc)
|
|||
eq = get_equipment("catapultammo123");
|
||||
CuAssertPtrNotNull(tc, eq);
|
||||
CuAssertStrEquals(tc, "catapultammo123", equipment_name(eq));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_equipment_suite(void)
|
||||
|
|
|
@ -28,7 +28,7 @@ static void test_destroyfaction_allies(CuTest *tc) {
|
|||
region *r;
|
||||
ally *al;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
f1 = test_create_faction(0);
|
||||
test_create_unit(f1, r);
|
||||
|
@ -40,14 +40,14 @@ static void test_destroyfaction_allies(CuTest *tc) {
|
|||
destroyfaction(&f1->next);
|
||||
CuAssertIntEquals(tc, false, faction_alive(f2));
|
||||
CuAssertIntEquals(tc, 0, alliedgroup(0, f1, f2, f1->allies, HELP_ALL));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_empty_factions_alliance(CuTest *tc) {
|
||||
faction *f;
|
||||
struct alliance *al;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
al = makealliance(0, "Hodor");
|
||||
setalliance(f, al);
|
||||
|
@ -56,14 +56,14 @@ static void test_remove_empty_factions_alliance(CuTest *tc) {
|
|||
remove_empty_factions();
|
||||
CuAssertPtrEquals(tc, 0, al->_leader);
|
||||
CuAssertIntEquals(tc, 0, selist_length(al->members));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_empty_factions(CuTest *tc) {
|
||||
faction *f, *fm;
|
||||
int fno;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
fm = get_or_create_monsters();
|
||||
assert(fm);
|
||||
f = test_create_faction(0);
|
||||
|
@ -74,7 +74,7 @@ static void test_remove_empty_factions(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, NULL, fm->next);
|
||||
CuAssertPtrEquals(tc, 0, findfaction(fno));
|
||||
CuAssertPtrEquals(tc, fm, get_monsters());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_dead_factions(CuTest *tc) {
|
||||
|
@ -82,7 +82,7 @@ static void test_remove_dead_factions(CuTest *tc) {
|
|||
region *r;
|
||||
int fno;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
fm = get_or_create_monsters();
|
||||
f = test_create_faction(0);
|
||||
|
@ -98,7 +98,7 @@ static void test_remove_dead_factions(CuTest *tc) {
|
|||
remove_empty_factions();
|
||||
CuAssertPtrEquals(tc, 0, findfaction(fno));
|
||||
CuAssertPtrEquals(tc, fm, get_monsters());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_addfaction(CuTest *tc) {
|
||||
|
@ -106,7 +106,7 @@ static void test_addfaction(CuTest *tc) {
|
|||
const struct race *rc;
|
||||
const struct locale *lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
rc = rc_get_or_create("human");
|
||||
lang = test_create_locale();
|
||||
f = addfaction("test@eressea.de", "hurrdurr", rc, lang, 1234);
|
||||
|
@ -128,7 +128,7 @@ static void test_addfaction(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, M_GRAY, f->magiegebiet);
|
||||
CuAssertIntEquals(tc, turn, f->lastorders);
|
||||
CuAssertPtrEquals(tc, f, findfaction(f->no));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_check_passwd(CuTest *tc) {
|
||||
|
@ -144,12 +144,12 @@ static void test_check_passwd(CuTest *tc) {
|
|||
static void test_get_monsters(CuTest *tc) {
|
||||
faction *f;
|
||||
|
||||
free_gamedata();
|
||||
test_setup();
|
||||
CuAssertPtrNotNull(tc, (f = get_monsters()));
|
||||
CuAssertPtrEquals(tc, f, get_monsters());
|
||||
CuAssertIntEquals(tc, 666, f->no);
|
||||
CuAssertStrEquals(tc, "Monster", f->name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_set_origin(CuTest *tc) {
|
||||
|
@ -174,7 +174,7 @@ static void test_set_origin(CuTest *tc) {
|
|||
adjust_coordinates(f, &x, &y, 0);
|
||||
CuAssertIntEquals(tc, -10, x);
|
||||
CuAssertIntEquals(tc, -10, y);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_set_origin_bug(CuTest *tc) {
|
||||
|
@ -191,7 +191,7 @@ static void test_set_origin_bug(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, f->ursprung->id);
|
||||
CuAssertIntEquals(tc, -9, x);
|
||||
CuAssertIntEquals(tc, 2, y);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_max_migrants(CuTest *tc) {
|
||||
|
@ -208,7 +208,7 @@ static void test_max_migrants(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
||||
scale_number(u, 250);
|
||||
CuAssertIntEquals(tc, 13, count_maxmigrants(f));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_valid_race(CuTest *tc) {
|
||||
|
@ -224,7 +224,7 @@ static void test_valid_race(CuTest *tc) {
|
|||
rc_set_param(rc1, "other_race", "elf");
|
||||
CuAssertTrue(tc, valid_race(f, rc1));
|
||||
CuAssertTrue(tc, valid_race(f, rc2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_set_email(CuTest *tc) {
|
||||
|
@ -250,7 +250,7 @@ static void test_set_email(CuTest *tc) {
|
|||
faction_setemail(f, NULL);
|
||||
CuAssertPtrEquals(tc, 0, f->email);
|
||||
CuAssertStrEquals(tc, "", faction_getemail(f));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_items_notlost(CuTest *tc) {
|
||||
|
@ -288,7 +288,7 @@ static void test_items_notlost(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 3, i_get(ug->items, itype));
|
||||
CuAssertIntEquals(tc, 5, i_get(u->items, it_horse));
|
||||
CuAssertIntEquals(tc, 10, i_get(u->items, it_silver));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_faction_suite(void)
|
||||
|
|
|
@ -31,7 +31,7 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
|
|||
ally *al;
|
||||
int fno;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
|
@ -66,7 +66,7 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
|
|||
g = get_group(u);
|
||||
CuAssertPtrNotNull(tc, g);
|
||||
CuAssertPtrEquals(tc, 0, g->allies);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_group_readwrite(CuTest * tc)
|
||||
|
@ -78,7 +78,7 @@ static void test_group_readwrite(CuTest * tc)
|
|||
gamedata data;
|
||||
storage store;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
f = test_create_faction(0);
|
||||
|
@ -113,7 +113,7 @@ static void test_group_readwrite(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, g->allies->next);
|
||||
CuAssertPtrEquals(tc, f, g->allies->faction);
|
||||
CuAssertIntEquals(tc, HELP_GIVE, g->allies->status);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_group(CuTest * tc)
|
||||
|
@ -123,7 +123,7 @@ static void test_group(CuTest * tc)
|
|||
faction *f;
|
||||
group *g;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
assert(r && f);
|
||||
|
@ -139,7 +139,7 @@ static void test_group(CuTest * tc)
|
|||
set_group(u, g);
|
||||
CuAssertIntEquals(tc, 1, g->members);
|
||||
CuAssertPtrEquals(tc, g, get_group(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_group_suite(void)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
static void test_resourcename_no_appearance(CuTest *tc) {
|
||||
const resource_type *rtype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
init_resources(); /* creates R_SILVER */
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
|
@ -28,13 +28,13 @@ static void test_resourcename_no_appearance(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "money_p", resourcename(rtype, NMF_PLURAL));
|
||||
CuAssertStrEquals(tc, "money", resourcename(rtype, NMF_APPEARANCE));
|
||||
CuAssertStrEquals(tc, "money_p", resourcename(rtype, NMF_APPEARANCE | NMF_PLURAL));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_resourcename_with_appearance(CuTest *tc) {
|
||||
item_type *itype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
itype = it_get_or_create(rt_get_or_create("foo"));
|
||||
assert(itype && itype->rtype);
|
||||
it_set_appearance(itype, "bar");
|
||||
|
@ -42,7 +42,7 @@ static void test_resourcename_with_appearance(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "foo_p", resourcename(itype->rtype, NMF_PLURAL));
|
||||
CuAssertStrEquals(tc, "bar", resourcename(itype->rtype, NMF_APPEARANCE));
|
||||
CuAssertStrEquals(tc, "bar_p", resourcename(itype->rtype, NMF_APPEARANCE | NMF_PLURAL));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_uchange(CuTest * tc, unit * u, const resource_type * rtype) {
|
||||
|
@ -76,7 +76,8 @@ void test_change_item(CuTest * tc)
|
|||
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
test_uchange(tc, u, get_resourcetype(R_IRON));
|
||||
test_cleanup();
|
||||
test_log_stderr(1);
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_resource_type(CuTest * tc)
|
||||
|
@ -92,7 +93,7 @@ void test_resource_type(CuTest * tc)
|
|||
itype = test_create_itemtype("herp");
|
||||
|
||||
CuAssertPtrEquals(tc, itype->rtype, rt_find("herp"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_finditemtype(CuTest * tc)
|
||||
|
@ -106,7 +107,7 @@ void test_finditemtype(CuTest * tc)
|
|||
locale_setstring(lang, "horse", "Pferd");
|
||||
itype = test_create_itemtype("horse");
|
||||
CuAssertPtrEquals(tc, (void *)itype, (void *)finditemtype("Pferd", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_findresourcetype(CuTest * tc)
|
||||
|
@ -126,7 +127,7 @@ void test_findresourcetype(CuTest * tc)
|
|||
|
||||
CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Holz", lang));
|
||||
CuAssertPtrEquals(tc, (void *)rt_find("peasant"), (void *)findresourcetype("Bauer", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
#include <modules/autoseed.h>
|
||||
|
@ -151,7 +152,7 @@ static void test_fix_demand(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, r->land->demands);
|
||||
CuAssertPtrNotNull(tc, r->land->demands->next);
|
||||
CuAssertPtrNotNull(tc, r_luxury(r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_core_resources(CuTest *tc) {
|
||||
|
@ -170,7 +171,7 @@ static void test_core_resources(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||
CuAssertPtrNotNull(tc, rtype = rt_find("aura"));
|
||||
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_resource(CuTest *tc) {
|
||||
|
@ -188,7 +189,7 @@ static void test_get_resource(CuTest *tc) {
|
|||
rtype = rt_get_or_create("catapult");
|
||||
CuAssertPtrEquals(tc, rtype, rt_find("catapult"));
|
||||
CuAssertStrEquals(tc, "catapult", rtype->_name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_item_suite(void)
|
||||
|
|
|
@ -51,6 +51,7 @@ static void check_flag(CuTest *tc, const char *name, int flag) {
|
|||
}
|
||||
|
||||
static void test_flags(CuTest *tc) {
|
||||
test_setup();
|
||||
check_flag(tc, "npc", RCF_NPC);
|
||||
check_flag(tc, "scarepeasants", RCF_SCAREPEASANTS);
|
||||
check_flag(tc, "nosteal", RCF_NOSTEAL);
|
||||
|
@ -61,7 +62,7 @@ static void test_flags(CuTest *tc) {
|
|||
check_ec_flag(tc, "getitem", ECF_GETITEM);
|
||||
check_ec_flag(tc, "giveperson", ECF_GIVEPERSON);
|
||||
check_ec_flag(tc, "giveunit", ECF_GIVEUNIT);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_settings(CuTest * tc)
|
||||
|
@ -88,7 +89,7 @@ static void test_settings(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 14, config_get_int("integer", 0));
|
||||
CuAssertDblEquals(tc, 1.5f, config_get_flt("float", 0), 0.01);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_prefixes(CuTest * tc)
|
||||
|
@ -107,7 +108,7 @@ static void test_prefixes(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "dark", race_prefixes[2]);
|
||||
CuAssertPtrEquals(tc, 0, race_prefixes[3]);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_disable(CuTest * tc)
|
||||
|
@ -133,7 +134,7 @@ static void test_disable(CuTest * tc)
|
|||
CuAssertTrue(tc, keyword_disabled(K_BESIEGE));
|
||||
CuAssertIntEquals(tc, 0, config_get_int("module.enabled", 1));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_calendar(CuTest * tc)
|
||||
|
@ -158,7 +159,7 @@ static void test_calendar(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, month_season[0]);
|
||||
CuAssertIntEquals(tc, 2, month_season[1]);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_races(CuTest * tc)
|
||||
|
@ -205,7 +206,7 @@ static void test_races(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 5, rc->hitpoints);
|
||||
CuAssertIntEquals(tc, 6, rc->armor);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_findrace(CuTest *tc) {
|
||||
|
@ -225,7 +226,7 @@ static void test_findrace(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, rc);
|
||||
CuAssertStrEquals(tc, "dwarf", rc->_name);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_items(CuTest * tc)
|
||||
|
@ -259,7 +260,7 @@ static void test_items(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, rt_find("axe"));
|
||||
CuAssertPtrNotNull(tc, (void *)get_resourcetype(R_HORSE));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ships(CuTest * tc)
|
||||
|
@ -299,7 +300,7 @@ static void test_ships(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, (void *)st->coasts[1]);
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_castles(CuTest *tc) {
|
||||
|
@ -327,7 +328,7 @@ static void test_castles(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 6, bt->construction->improvement->maxsize);
|
||||
CuAssertPtrEquals(tc, 0, bt->construction->improvement->improvement);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_spells(CuTest * tc)
|
||||
|
@ -347,7 +348,7 @@ static void test_spells(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "u+", sp->syntax);
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
CuAssertPtrEquals(tc, 0, find_spell("fireball"));
|
||||
}
|
||||
|
||||
|
@ -413,7 +414,7 @@ static void test_buildings(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, bt->construction->minskill);
|
||||
CuAssertPtrEquals(tc, 0, bt->construction->improvement);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static const char * building_defaults_data = "{\"buildings\": { "
|
||||
|
@ -438,7 +439,7 @@ static void test_buildings_default(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, (void *)bt, (void *)bt_find("house"));
|
||||
CuAssertIntEquals(tc, 0, memcmp(bt, &clone, sizeof(building_type)));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static const char * ship_defaults_data = "{\"ships\": { "
|
||||
|
@ -463,7 +464,7 @@ static void test_ships_default(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, (void *)st, (void *)st_find("hodor"));
|
||||
CuAssertIntEquals(tc, 0, memcmp(st, &clone, sizeof(ship_type)));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_configs(CuTest * tc)
|
||||
|
@ -485,7 +486,7 @@ static void test_configs(CuTest * tc)
|
|||
errno = 0;
|
||||
}
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_terrains(CuTest * tc)
|
||||
|
@ -527,7 +528,7 @@ static void test_terrains(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, (void *)ter->production[2].type);
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_directions(CuTest * tc)
|
||||
|
@ -549,7 +550,7 @@ static void test_directions(CuTest * tc)
|
|||
CuAssertIntEquals(tc, D_PAUSE, get_direction("pause", lang));
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_skills(CuTest * tc)
|
||||
|
@ -574,7 +575,7 @@ static void test_skills(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "ARMBRUST", LOC(lang, "skill::crossbow"));
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_keywords(CuTest * tc)
|
||||
|
@ -598,7 +599,7 @@ static void test_keywords(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "NACH", LOC(lang, "keyword::move"));
|
||||
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_strings(CuTest * tc)
|
||||
|
@ -617,7 +618,7 @@ static void test_strings(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "NACH", LOC(lang, "move"));
|
||||
CuAssertStrEquals(tc, "LERNEN", LOC(lang, "study"));
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_infinitive_from_config(CuTest *tc) {
|
||||
|
@ -640,7 +641,7 @@ static void test_infinitive_from_config(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "LERNE", get_command(ord, lang, buffer, sizeof(buffer)));
|
||||
free_order(ord);
|
||||
cJSON_Delete(json);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_jsonconf_suite(void)
|
||||
|
|
|
@ -9,18 +9,21 @@
|
|||
|
||||
void test_missing_message(CuTest *tc) {
|
||||
message *msg;
|
||||
|
||||
test_setup();
|
||||
msg = msg_message("unknown", "unit", NULL);
|
||||
CuAssertPtrNotNull(tc, msg);
|
||||
CuAssertPtrNotNull(tc, msg->type);
|
||||
CuAssertStrEquals(tc, msg->type->name, "missing_message");
|
||||
msg_release(msg);
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_message(CuTest *tc) {
|
||||
message *msg;
|
||||
message_type *mtype = mt_new("custom", NULL);
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
mt_register(mtype);
|
||||
CuAssertPtrEquals(tc, mtype, (void *)mt_find("custom"));
|
||||
CuAssertIntEquals(tc, 0, mtype->nparameters);
|
||||
|
@ -37,7 +40,7 @@ void test_message(CuTest *tc) {
|
|||
msg_release(msg);
|
||||
CuAssertIntEquals(tc, 1, msg->refcount);
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_merge_split(CuTest *tc) {
|
||||
|
@ -46,7 +49,7 @@ static void test_merge_split(CuTest *tc) {
|
|||
message_type *mtype = mt_new("custom", NULL);
|
||||
message *msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
mt_register(mtype);
|
||||
add_message(&mlist, msg = msg_message(mtype->name, ""));
|
||||
msg_release(msg);
|
||||
|
@ -68,7 +71,7 @@ static void test_merge_split(CuTest *tc) {
|
|||
free(mlist);
|
||||
free_messagelist(append->begin);
|
||||
free(append);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_noerror(CuTest *tc) {
|
||||
|
@ -83,7 +86,7 @@ static void test_noerror(CuTest *tc) {
|
|||
CuAssertTrue(tc, !is_persistent(u->thisorder));
|
||||
CuAssertPtrEquals(tc, NULL, msg_error(u, u->thisorder, 100));
|
||||
CuAssertPtrEquals(tc, NULL, msg_feedback(u, u->thisorder, "error_unit_not_found", NULL));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_messages_suite(void) {
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_create_order(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_MOVE, init_order_depr(ord));
|
||||
CuAssertStrEquals(tc, "NORTH", getstrtoken());
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_parse_order(CuTest *tc) {
|
||||
|
@ -83,7 +83,7 @@ static void test_parse_order(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST | CMD_QUIET, ord->command);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_parse_make(CuTest *tc) {
|
||||
|
@ -91,7 +91,7 @@ static void test_parse_make(CuTest *tc) {
|
|||
order *ord;
|
||||
struct locale * lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = get_or_create_locale("en");
|
||||
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
|
@ -105,7 +105,7 @@ static void test_parse_make(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_MAKE, init_order_depr(ord));
|
||||
CuAssertStrEquals(tc, "hurrdurr", getstrtoken());
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_parse_make_temp(CuTest *tc) {
|
||||
|
@ -113,7 +113,7 @@ static void test_parse_make_temp(CuTest *tc) {
|
|||
order *ord;
|
||||
struct locale * lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = get_or_create_locale("en");
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
||||
|
@ -128,7 +128,7 @@ static void test_parse_make_temp(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_MAKETEMP, init_order_depr(ord));
|
||||
CuAssertStrEquals(tc, "herp", getstrtoken());
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_parse_maketemp(CuTest *tc) {
|
||||
|
@ -136,7 +136,7 @@ static void test_parse_maketemp(CuTest *tc) {
|
|||
order *ord;
|
||||
struct locale * lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
lang = get_or_create_locale("en");
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
|
@ -151,14 +151,14 @@ static void test_parse_maketemp(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_MAKETEMP, init_order_depr(ord));
|
||||
CuAssertStrEquals(tc, "herp", getstrtoken());
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_init_order(CuTest *tc) {
|
||||
order *ord;
|
||||
struct locale * lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
lang = get_or_create_locale("en");
|
||||
ord = create_order(K_MAKETEMP, lang, "hurr durr");
|
||||
|
@ -166,7 +166,7 @@ static void test_init_order(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "hurr", getstrtoken());
|
||||
CuAssertStrEquals(tc, "durr", getstrtoken());
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_getstrtoken(CuTest *tc) {
|
||||
|
@ -191,7 +191,7 @@ static void test_replace_order(CuTest *tc) {
|
|||
order *orders = 0, *orig, *repl;
|
||||
struct locale * lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = test_create_locale();
|
||||
orig = create_order(K_MAKE, lang, NULL);
|
||||
repl = create_order(K_ALLY, lang, NULL);
|
||||
|
@ -204,7 +204,7 @@ static void test_replace_order(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, getkeyword(repl), getkeyword(orders));
|
||||
free_order(orders);
|
||||
free_order(repl);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_command(CuTest *tc) {
|
||||
|
@ -223,7 +223,7 @@ static void test_get_command(CuTest *tc) {
|
|||
ord->command = K_MAKE | CMD_PERSIST;
|
||||
CuAssertStrEquals(tc, "@make iron", get_command(ord, lang, buf, sizeof(buf)));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_is_persistent(CuTest *tc) {
|
||||
|
@ -263,7 +263,7 @@ static void test_is_persistent(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_KOMMENTAR, ord->command);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,7 +292,7 @@ static void test_is_silent(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_KOMMENTAR, ord->command);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_orders(CuTest *tc) {
|
||||
|
@ -328,7 +328,7 @@ static void test_study_orders(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 100, getint());
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_order_suite(void)
|
||||
|
|
|
@ -38,7 +38,7 @@ static void test_plane(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 60, plane_center_y(pl));
|
||||
CuAssertIntEquals(tc, 5, plane_width(pl));
|
||||
CuAssertIntEquals(tc, 41, plane_height(pl));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_origin(CuTest *tc) {
|
||||
|
@ -56,7 +56,7 @@ static void test_origin(CuTest *tc) {
|
|||
adjust_coordinates(f, &x, &y, 0);
|
||||
CuAssertIntEquals(tc, -10, x);
|
||||
CuAssertIntEquals(tc, -20, y);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_plane_suite(void)
|
||||
|
|
|
@ -19,7 +19,7 @@ void test_reservation(CuTest *tc) {
|
|||
faction *f;
|
||||
region *r;
|
||||
struct resource_type *rtype;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
|
@ -39,7 +39,7 @@ void test_reservation(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 200, get_resource(u, rtype));
|
||||
CuAssertIntEquals(tc, 200, i_get(u->items, rtype->itype));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_pool(CuTest *tc) {
|
||||
|
@ -49,7 +49,7 @@ void test_pool(CuTest *tc) {
|
|||
struct resource_type *rtype;
|
||||
ally *al;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
|
@ -85,6 +85,8 @@ void test_pool(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 100, get_pooled(u1, rtype, GET_ALL, 50));
|
||||
CuAssertIntEquals(tc, 300, get_pooled(u1, rtype, GET_ALL, 150));
|
||||
CuAssertIntEquals(tc, 300, get_pooled(u1, rtype, GET_ALL, INT_MAX));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_pool_bug_2042(CuTest *tc) {
|
||||
|
@ -93,7 +95,7 @@ void test_pool_bug_2042(CuTest *tc) {
|
|||
region *r;
|
||||
struct resource_type *rtype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
|
@ -106,6 +108,8 @@ void test_pool_bug_2042(CuTest *tc) {
|
|||
i_change(&u2->items, rtype->itype, 100);
|
||||
|
||||
CuAssertIntEquals(tc, 100, get_pooled(u1, rtype, GET_SLACK | GET_POOLED_SLACK, 100));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_pool_use(CuTest *tc) {
|
||||
|
@ -115,7 +119,7 @@ void test_pool_use(CuTest *tc) {
|
|||
struct item_type *itype;
|
||||
ally *al;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
itype = it_get_or_create(rt_get_or_create("money"));
|
||||
f = test_create_faction(0);
|
||||
|
@ -151,6 +155,8 @@ void test_pool_use(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 90, get_reservation(u2, itype));
|
||||
CuAssertIntEquals(tc, 90, use_pooled(u1, itype->rtype, GET_POOLED_RESERVE, 100));
|
||||
CuAssertIntEquals(tc, 0, i_get(u2->items, itype));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_change_resource(CuTest * tc)
|
||||
|
@ -161,7 +167,7 @@ void test_change_resource(CuTest * tc)
|
|||
const char * names[] = { "money", "aura", "permaura", "horse", "hp", 0 };
|
||||
int i;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
||||
|
@ -178,7 +184,7 @@ void test_change_resource(CuTest * tc)
|
|||
CuAssertIntEquals(tc, have + 1, change_resource(u, rtype, 1));
|
||||
CuAssertIntEquals(tc, have + 1, get_resource(u, rtype));
|
||||
}
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_pool_suite(void)
|
||||
|
|
|
@ -18,7 +18,7 @@ static void test_rc_name(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "race::human_p", rc_name_s(rc, NAME_PLURAL));
|
||||
CuAssertStrEquals(tc, "race::human_d", rc_name_s(rc, NAME_DEFINITIVE));
|
||||
CuAssertStrEquals(tc, "race::human_x", rc_name_s(rc, NAME_CATEGORY));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rc_defaults(CuTest *tc) {
|
||||
|
@ -44,7 +44,7 @@ static void test_rc_defaults(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, rc->df_bonus);
|
||||
CuAssertIntEquals(tc, 0, rc->battle_flags);
|
||||
CuAssertIntEquals(tc, PERSON_WEIGHT, rc->weight);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rc_find(CuTest *tc) {
|
||||
|
@ -52,7 +52,7 @@ static void test_rc_find(CuTest *tc) {
|
|||
test_setup();
|
||||
rc = test_create_race("hungryhippos");
|
||||
CuAssertPtrEquals(tc, rc, (void *)rc_find("hungryhippos"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_race_get(CuTest *tc) {
|
||||
|
@ -68,7 +68,7 @@ static void test_race_get(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, (void *)rc, (void *)rc_find("elf"));
|
||||
free_races();
|
||||
CuAssertTrue(tc, rc_changed(&cache));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_old_race(CuTest *tc)
|
||||
|
@ -83,7 +83,7 @@ static void test_old_race(CuTest *tc)
|
|||
rc2 = test_create_race("human");
|
||||
CuAssertIntEquals(tc, RC_ELF, old_race(rc1));
|
||||
CuAssertIntEquals(tc, RC_HUMAN, old_race(rc2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rc_set_param(CuTest *tc) {
|
||||
|
@ -100,7 +100,7 @@ static void test_rc_set_param(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 400, rc_scare(rc));
|
||||
rc_set_param(rc, "hunger.damage", "1d10+12");
|
||||
CuAssertStrEquals(tc, "1d10+12", rc_hungerdamage(rc));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rc_can_use(CuTest *tc) {
|
||||
|
@ -148,7 +148,7 @@ static void test_rc_can_use(CuTest *tc) {
|
|||
rc->mask_item = 0;
|
||||
CuAssertTrue(tc, ! rc_can_use(rc, itype));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_race_suite(void)
|
||||
|
|
|
@ -31,7 +31,7 @@ void test_terraform(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, r->land->demands->type->price);
|
||||
terraform_region(r, t_ocean);
|
||||
CuAssertPtrEquals(tc, 0, r->land);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_region_get_owner(CuTest *tc) {
|
||||
|
@ -50,7 +50,7 @@ static void test_region_get_owner(CuTest *tc) {
|
|||
u2 = test_create_unit(test_create_faction(0), r);
|
||||
u_set_building(u2, b2);
|
||||
CuAssertPtrEquals(tc, u2->faction, region_get_owner(r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_region_getset_resource(CuTest *tc) {
|
||||
|
@ -75,7 +75,7 @@ static void test_region_getset_resource(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 10, region_getresource(r, get_resourcetype(R_PEASANT)));
|
||||
CuAssertIntEquals(tc, 10, rpeasants(r));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_trees(CuTest *tc) {
|
||||
|
@ -93,7 +93,7 @@ static void test_trees(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, MAXTREES, rtrees(r, 0));
|
||||
rsettrees(r, 0, MAXTREES+100);
|
||||
CuAssertIntEquals(tc, MAXTREES, rtrees(r, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_region_suite(void)
|
||||
|
|
|
@ -42,7 +42,7 @@ static void test_readwrite_data(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, readgame(filename));
|
||||
join_path(datapath(), filename, path, sizeof(path));
|
||||
CuAssertIntEquals(tc, 0, remove(path));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_unit(CuTest * tc)
|
||||
|
@ -88,7 +88,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
move_unit(u, r, NULL); /* this makes sure that u doesn't leak */
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_faction(CuTest * tc)
|
||||
|
@ -117,7 +117,7 @@ static void test_readwrite_faction(CuTest * tc)
|
|||
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_region(CuTest * tc)
|
||||
|
@ -149,7 +149,7 @@ static void test_readwrite_region(CuTest * tc)
|
|||
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_building(CuTest * tc)
|
||||
|
@ -182,7 +182,7 @@ static void test_readwrite_building(CuTest * tc)
|
|||
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_ship(CuTest * tc)
|
||||
|
@ -215,7 +215,7 @@ static void test_readwrite_ship(CuTest * tc)
|
|||
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_attrib(CuTest *tc) {
|
||||
|
@ -240,7 +240,7 @@ static void test_readwrite_attrib(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 43, key_get(a, 42));
|
||||
a_removeall(&a, NULL);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_dead_faction_group(CuTest *tc) {
|
||||
|
@ -255,7 +255,7 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
|
|||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
|
@ -288,7 +288,7 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, g->allies);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
||||
|
@ -320,7 +320,7 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
|||
r = regions;
|
||||
CuAssertPtrNotNull(tc, r);
|
||||
CuAssertPtrEquals(tc, 0, region_get_owner(r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
||||
|
@ -331,7 +331,7 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
|||
trigger *tr;
|
||||
unit * u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, 0));
|
||||
|
@ -357,7 +357,7 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
|||
u = r->units;
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, 0, a_find(u->attribs, &at_eventhandler));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
||||
|
@ -368,7 +368,7 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
|||
trigger *tr;
|
||||
unit * u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, 0));
|
||||
|
@ -394,7 +394,7 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
|||
u = r->units;
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, 0, a_find(u->attribs, &at_eventhandler));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_read_password(CuTest *tc) {
|
||||
|
@ -413,7 +413,7 @@ static void test_read_password(CuTest *tc) {
|
|||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_read_password_external(CuTest *tc) {
|
||||
|
@ -452,7 +452,7 @@ static void test_read_password_external(CuTest *tc) {
|
|||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
CuAssertIntEquals(tc, 0, remove(pwfile));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_version_no(CuTest *tc) {
|
||||
|
|
|
@ -34,6 +34,7 @@ extern "C" {
|
|||
#define SFL_OPENSEA 0x01
|
||||
#define SFL_FLY 0x02
|
||||
#define SFL_NOCOAST 0x04
|
||||
#define SFL_SPEEDY 0x08
|
||||
|
||||
typedef struct ship_type {
|
||||
char *_name;
|
||||
|
|
|
@ -22,11 +22,12 @@ static void test_register_ship(CuTest * tc)
|
|||
{
|
||||
ship_type *stype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
stype = st_get_or_create("herp");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
CuAssertPtrEquals(tc, stype, (void *)st_find("herp"));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_set_owner(CuTest * tc)
|
||||
|
@ -38,7 +39,7 @@ static void test_ship_set_owner(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -56,6 +57,7 @@ static void test_ship_set_owner(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u1, ship_owner(sh));
|
||||
ship_set_owner(u2);
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_next_when_empty(CuTest * tc)
|
||||
|
@ -67,7 +69,7 @@ static void test_shipowner_goes_to_next_when_empty(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -90,6 +92,7 @@ static void test_shipowner_goes_to_next_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, ship_owner(sh));
|
||||
u->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_other_when_empty(CuTest * tc)
|
||||
|
@ -101,7 +104,7 @@ static void test_shipowner_goes_to_other_when_empty(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -124,6 +127,7 @@ static void test_shipowner_goes_to_other_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, ship_owner(sh));
|
||||
u->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_same_faction_when_empty(CuTest * tc)
|
||||
|
@ -135,7 +139,7 @@ static void test_shipowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -163,6 +167,7 @@ static void test_shipowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u3, ship_owner(sh));
|
||||
u3->number = 0;
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_next_after_leave(CuTest * tc)
|
||||
|
@ -174,7 +179,7 @@ static void test_shipowner_goes_to_next_after_leave(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -197,6 +202,7 @@ static void test_shipowner_goes_to_next_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, ship_owner(sh));
|
||||
leave_ship(u);
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_other_after_leave(CuTest * tc)
|
||||
|
@ -208,7 +214,7 @@ static void test_shipowner_goes_to_other_after_leave(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -231,6 +237,7 @@ static void test_shipowner_goes_to_other_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u, ship_owner(sh));
|
||||
leave_ship(u);
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_goes_to_same_faction_after_leave(CuTest * tc)
|
||||
|
@ -242,7 +249,7 @@ static void test_shipowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -272,6 +279,7 @@ static void test_shipowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
leave_ship(u2);
|
||||
CuAssertPtrEquals(tc, 0, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipowner_resets_when_empty(CuTest * tc)
|
||||
|
@ -283,7 +291,7 @@ static void test_shipowner_resets_when_empty(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -306,6 +314,7 @@ static void test_shipowner_resets_when_empty(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, ship_owner(sh));
|
||||
u->number = 1;
|
||||
CuAssertPtrEquals(tc, u, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
||||
|
@ -317,7 +326,7 @@ void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
|
@ -347,11 +356,12 @@ void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, ship_owner(sh));
|
||||
u2->number = 1;
|
||||
CuAssertPtrEquals(tc, u2, ship_owner(sh));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_stype_defaults(CuTest *tc) {
|
||||
ship_type *stype;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
stype = st_get_or_create("hodor");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
CuAssertStrEquals(tc, "hodor", stype->_name);
|
||||
|
@ -371,7 +381,7 @@ static void test_stype_defaults(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, stype->at_bonus);
|
||||
CuAssertIntEquals(tc, 0, stype->df_bonus);
|
||||
CuAssertIntEquals(tc, 0, stype->flags);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_crew_skill(CuTest *tc) {
|
||||
|
@ -380,9 +390,9 @@ static void test_crew_skill(CuTest *tc) {
|
|||
struct faction *f;
|
||||
int i;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
assert(r && f);
|
||||
sh = test_create_ship(r, st_find("boat"));
|
||||
|
@ -392,7 +402,7 @@ static void test_crew_skill(CuTest *tc) {
|
|||
u->ship = sh;
|
||||
}
|
||||
CuAssertIntEquals(tc, 20, crew_skill(sh));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static ship *setup_ship(void) {
|
||||
|
@ -422,11 +432,32 @@ static void setup_crew(ship *sh, struct faction *f, unit **cap, unit **crew) {
|
|||
set_level(*crew, SK_SAILING, sh->type->sumskill - sh->type->cptskill);
|
||||
}
|
||||
|
||||
static void test_shipspeed_speedy(CuTest *tc) {
|
||||
ship_type *stype;
|
||||
ship *sh;
|
||||
unit *cap, *crw;
|
||||
test_setup();
|
||||
stype = test_create_shiptype("dragonship");
|
||||
stype->range = 2;
|
||||
stype->range_max = -1;
|
||||
stype->flags |= SFL_SPEEDY;
|
||||
cap = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
crw = test_create_unit(cap->faction, cap->region);
|
||||
sh = test_create_ship(cap->region, stype);
|
||||
cap->ship = sh;
|
||||
crw->ship = sh;
|
||||
set_level(cap, SK_SAILING, stype->cptskill);
|
||||
set_level(crw, SK_SAILING, stype->sumskill - stype->cptskill);
|
||||
CuAssertPtrEquals(tc, cap, ship_owner(sh));
|
||||
CuAssertIntEquals(tc, 2, shipspeed(sh, cap));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_stormwind(CuTest *tc) {
|
||||
ship *sh;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
register_shipcurse();
|
||||
|
@ -437,14 +468,14 @@ static void test_shipspeed_stormwind(CuTest *tc) {
|
|||
CuAssertIntEquals_Msg(tc, "stormwind doubles ship range", sh->type->range * 2, shipspeed(sh, cap));
|
||||
a_age(&sh->attribs, sh);
|
||||
CuAssertPtrEquals(tc, NULL, sh->attribs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_nodrift(CuTest *tc) {
|
||||
ship *sh;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
register_shipcurse();
|
||||
|
@ -452,14 +483,14 @@ static void test_shipspeed_nodrift(CuTest *tc) {
|
|||
|
||||
create_curse(0, &sh->attribs, &ct_nodrift, 1, 1, 1, 0);
|
||||
CuAssertIntEquals_Msg(tc, "nodrift adds +1 to range", sh->type->range + 1, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_shipspeedup(CuTest *tc) {
|
||||
ship *sh;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
register_shipcurse();
|
||||
|
@ -467,7 +498,7 @@ static void test_shipspeed_shipspeedup(CuTest *tc) {
|
|||
|
||||
create_curse(0, &sh->attribs, &ct_shipspeedup, 1, 1, 3, 0);
|
||||
CuAssertIntEquals_Msg(tc, "shipspeedup adds effect to range", sh->type->range + 3, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_at_speedup(CuTest *tc) {
|
||||
|
@ -475,7 +506,7 @@ static void test_shipspeed_at_speedup(CuTest *tc) {
|
|||
unit *cap, *crew;
|
||||
attrib *a;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
assert(sh && cap && crew);
|
||||
|
@ -484,7 +515,7 @@ static void test_shipspeed_at_speedup(CuTest *tc) {
|
|||
a->data.i = 3;
|
||||
a_add(&sh->attribs, a);
|
||||
CuAssertIntEquals_Msg(tc, "at_speedup adds value to range", sh->type->range + 3, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_race_bonus(CuTest *tc) {
|
||||
|
@ -492,7 +523,7 @@ static void test_shipspeed_race_bonus(CuTest *tc) {
|
|||
unit *cap, *crew;
|
||||
race *rc;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
assert(sh && cap && crew);
|
||||
|
@ -500,14 +531,14 @@ static void test_shipspeed_race_bonus(CuTest *tc) {
|
|||
rc = rc_get_or_create(cap->_race->_name);
|
||||
rc->flags |= RCF_SHIPSPEED;
|
||||
CuAssertIntEquals_Msg(tc, "captain with RCF_SHIPSPEED adds +1 to range", sh->type->range + 1, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_damage(CuTest *tc) {
|
||||
ship *sh;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
assert(sh && cap && crew);
|
||||
|
@ -518,7 +549,7 @@ static void test_shipspeed_damage(CuTest *tc) {
|
|||
CuAssertIntEquals_Msg(tc, "damaged ships lose range", 1, shipspeed(sh, cap));
|
||||
sh->damage = sh->size * DAMAGE_SCALE;
|
||||
CuAssertIntEquals_Msg(tc, "fully damaged ships have no range", 0, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed(CuTest *tc) {
|
||||
|
@ -526,7 +557,7 @@ static void test_shipspeed(CuTest *tc) {
|
|||
const ship_type *stype;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
stype = sh->type;
|
||||
|
||||
|
@ -549,6 +580,7 @@ static void test_shipspeed(CuTest *tc) {
|
|||
set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 11);
|
||||
set_level(cap, SK_SAILING, stype->cptskill + 10);
|
||||
CuAssertIntEquals_Msg(tc, "regular skills should not exceed sh.range", 2, shipspeed(sh, cap));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shipspeed_max_range(CuTest *tc) {
|
||||
|
@ -558,7 +590,7 @@ static void test_shipspeed_max_range(CuTest *tc) {
|
|||
struct faction *f;
|
||||
unit *cap, *crew;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
sh = setup_ship();
|
||||
setup_crew(sh, 0, &cap, &crew);
|
||||
config_set("movement.shipspeed.skillbonus", "5");
|
||||
|
@ -578,7 +610,7 @@ static void test_shipspeed_max_range(CuTest *tc) {
|
|||
set_level(cap, SK_SAILING, stype->cptskill + 15);
|
||||
set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 15);
|
||||
CuAssertIntEquals_Msg(tc, "skill-bonus cannot exceed max_range", 4, shipspeed(sh, cap));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_ship_suite(void)
|
||||
|
@ -597,6 +629,7 @@ CuSuite *get_ship_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_shipowner_goes_to_empty_unit_after_leave);
|
||||
SUITE_ADD_TEST(suite, test_crew_skill);
|
||||
SUITE_ADD_TEST(suite, test_shipspeed);
|
||||
SUITE_ADD_TEST(suite, test_shipspeed_speedy);
|
||||
SUITE_ADD_TEST(suite, test_shipspeed_stormwind);
|
||||
SUITE_ADD_TEST(suite, test_shipspeed_nodrift);
|
||||
SUITE_ADD_TEST(suite, test_shipspeed_shipspeedup);
|
||||
|
|
|
@ -22,7 +22,7 @@ static void test_create_a_spell(CuTest * tc)
|
|||
sp = create_spell("testspell");
|
||||
CuAssertPtrEquals(tc, sp, find_spell("testspell"));
|
||||
CuAssertPtrNotNull(tc, spells);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_create_duplicate_spell(CuTest * tc)
|
||||
|
@ -32,7 +32,7 @@ static void test_create_duplicate_spell(CuTest * tc)
|
|||
strlist *sl = 0;
|
||||
|
||||
test_setup();
|
||||
test_log_stderr(0);
|
||||
test_log_stderr(0); /* suppress the "duplicate spell" error message */
|
||||
log = test_log_start(LOG_CPERROR, &sl);
|
||||
|
||||
CuAssertPtrEquals(tc, 0, find_spell("testspell"));
|
||||
|
@ -44,7 +44,8 @@ static void test_create_duplicate_spell(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, 0, sl->next);
|
||||
CuAssertPtrEquals(tc, sp, find_spell("testspell"));
|
||||
test_log_stop(log, sl);
|
||||
test_cleanup();
|
||||
test_log_stderr(1); /* or teardown complains that stderr logging is off */
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_spellref(CuTest *tc)
|
||||
|
@ -61,7 +62,7 @@ static void test_spellref(CuTest *tc)
|
|||
CuAssertPtrNotNull(tc, sp);
|
||||
CuAssertPtrEquals(tc, sp, spellref_get(ref));
|
||||
spellref_free(ref);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void fumble_foo(const struct castorder *co) {
|
||||
|
@ -81,7 +82,7 @@ static void test_fumbles(CuTest *tc)
|
|||
CuAssertTrue(tc, fumble_foo==get_fumble("foone"));
|
||||
CuAssertTrue(tc, fumble_bar==get_fumble("foozle"));
|
||||
CuAssertTrue(tc, NULL==get_fumble("foo"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_spell_suite(void)
|
||||
|
|
|
@ -41,7 +41,7 @@ static void test_remove_empty_units(CuTest *tc) {
|
|||
u->number = 0;
|
||||
remove_empty_units();
|
||||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_empty_units_in_region(CuTest *tc) {
|
||||
|
@ -62,7 +62,7 @@ static void test_remove_empty_units_in_region(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
CuAssertPtrEquals(tc, 0, u->nextF);
|
||||
CuAssertPtrEquals(tc, 0, u->region);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_units_without_faction(CuTest *tc) {
|
||||
|
@ -78,7 +78,7 @@ static void test_remove_units_without_faction(CuTest *tc) {
|
|||
remove_empty_units_in_region(u->region);
|
||||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
CuAssertIntEquals(tc, 0, u->number);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_units_with_dead_faction(CuTest *tc) {
|
||||
|
@ -94,7 +94,7 @@ static void test_remove_units_with_dead_faction(CuTest *tc) {
|
|||
remove_empty_units_in_region(u->region);
|
||||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
CuAssertIntEquals(tc, 0, u->number);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_scale_number(CuTest *tc) {
|
||||
|
@ -125,7 +125,7 @@ static void test_scale_number(CuTest *tc) {
|
|||
set_level(u, SK_ALCHEMY, 1);
|
||||
scale_number(u, 0);
|
||||
CuAssertIntEquals(tc, 0, get_level(u, SK_ALCHEMY));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unit_name(CuTest *tc) {
|
||||
|
@ -137,7 +137,7 @@ static void test_unit_name(CuTest *tc) {
|
|||
renumber_unit(u, 666);
|
||||
unit_setname(u, "Hodor");
|
||||
CuAssertStrEquals(tc, "Hodor (ii)", unitname(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unit_name_from_race(CuTest *tc) {
|
||||
|
@ -155,7 +155,7 @@ static void test_unit_name_from_race(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "human_p (ii)", unitname(u));
|
||||
CuAssertStrEquals(tc, "human_p", unit_getname(u));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_update_monster_name(CuTest *tc) {
|
||||
|
@ -181,13 +181,13 @@ static void test_update_monster_name(CuTest *tc) {
|
|||
unit_setname(u, rc_name_s(u->_race, NAME_PLURAL));
|
||||
CuAssertTrue(tc, unit_name_equals_race(u));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_names(CuTest *tc) {
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
|
||||
|
@ -195,7 +195,7 @@ static void test_names(CuTest *tc) {
|
|||
unit_setid(u, 5);
|
||||
CuAssertStrEquals(tc, "Hodor", unit_getname(u));
|
||||
CuAssertStrEquals(tc, "Hodor (5)", unitname(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_default_name(CuTest *tc) {
|
||||
|
@ -215,7 +215,7 @@ static void test_default_name(CuTest *tc) {
|
|||
sprintf(compare, "Zweiheit %s", itoa36(u->no));
|
||||
CuAssertStrEquals(tc, compare, buf);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static int cb_skillmod(const unit *u, const region *r, skill_t sk, int level) {
|
||||
|
@ -229,7 +229,7 @@ static void test_skillmod(CuTest *tc) {
|
|||
unit *u;
|
||||
attrib *a;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
set_level(u, SK_ARMORER, 5);
|
||||
CuAssertIntEquals(tc, 5, effskill(u, SK_ARMORER, 0));
|
||||
|
@ -250,13 +250,13 @@ static void test_skillmod(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 8, effskill(u, SK_ARMORER, 0));
|
||||
a_remove(&u->attribs, a);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_skill_hunger(CuTest *tc) {
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
set_level(u, SK_ARMORER, 6);
|
||||
set_level(u, SK_SAILING, 6);
|
||||
|
@ -265,14 +265,14 @@ static void test_skill_hunger(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 5, effskill(u, SK_SAILING, 0));
|
||||
set_level(u, SK_SAILING, 2);
|
||||
CuAssertIntEquals(tc, 1, effskill(u, SK_SAILING, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_skill_familiar(CuTest *tc) {
|
||||
unit *mag, *fam;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
/* setup two units */
|
||||
mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
|
@ -293,7 +293,7 @@ static void test_skill_familiar(CuTest *tc) {
|
|||
r = test_create_region(3, 0, 0);
|
||||
move_unit(fam, r, &r->units);
|
||||
CuAssertIntEquals(tc, 7, effskill(mag, SK_PERCEPTION, 0));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_inside_building(CuTest *tc) {
|
||||
|
@ -318,7 +318,7 @@ static void test_inside_building(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, inside_building(u));
|
||||
b->size = 3;
|
||||
CuAssertPtrEquals(tc, b, inside_building(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_skills(CuTest *tc) {
|
||||
|
@ -359,11 +359,12 @@ static void test_skills(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, SK_ALCHEMY, u->skills[0].id);
|
||||
CuAssertIntEquals(tc, 1, u->skill_size);
|
||||
CuAssertTrue(tc, !has_skill(u, SK_LONGBOW));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_limited_skills(CuTest *tc) {
|
||||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
|
@ -381,7 +382,7 @@ static void test_limited_skills(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, true, has_limited_skills(u));
|
||||
u->skills->id = SK_TAXING;
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unit_description(CuTest *tc) {
|
||||
|
@ -405,7 +406,7 @@ static void test_unit_description(CuTest *tc) {
|
|||
locale_setstring(lang, "describe_hodor", "HODOR");
|
||||
CuAssertStrEquals(tc, "HODOR", u_description(u, lang));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_remove_unit(CuTest *tc) {
|
||||
|
@ -456,11 +457,12 @@ static void test_remove_unit(CuTest *tc) {
|
|||
/* there are now no more units: */
|
||||
CuAssertPtrEquals(tc, 0, r->units);
|
||||
CuAssertPtrEquals(tc, 0, f->units);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_unit(CuTest *tc) {
|
||||
unit *u1, *u2;
|
||||
|
||||
test_setup();
|
||||
u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
u2 = test_create_unit(u1->faction, u1->region);
|
||||
|
@ -469,7 +471,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
rng_init(0);
|
||||
renumber_unit(u2, 0);
|
||||
CuAssertTrue(tc, u1->no != u2->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void gen_name(unit *u)
|
||||
|
@ -487,7 +489,7 @@ static void test_name_unit(CuTest *tc) {
|
|||
rc->name_unit = gen_name;
|
||||
name_unit(u);
|
||||
CuAssertStrEquals(tc, "Hodor", unit_getname(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_heal_factor(CuTest *tc) {
|
||||
|
@ -513,7 +515,7 @@ static void test_heal_factor(CuTest *tc) {
|
|||
CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0);
|
||||
config_set("healing.forest", "1.5");
|
||||
CuAssertDblEquals(tc, 1.5, u_heal_factor(u), 0.0);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unlimited_units(CuTest *tc) {
|
||||
|
@ -550,7 +552,7 @@ static void test_unlimited_units(CuTest *tc) {
|
|||
remove_unit(&u->region->units, u);
|
||||
CuAssertIntEquals(tc, 0, f->num_units);
|
||||
CuAssertIntEquals(tc, 0, f->num_people);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_clone_men_bug_2386(CuTest *tc) {
|
||||
|
@ -569,13 +571,14 @@ static void test_clone_men_bug_2386(CuTest *tc) {
|
|||
clone_men(u1, u2, 8100);
|
||||
CuAssertIntEquals(tc, 8100, u2->number);
|
||||
CuAssertIntEquals(tc, u2->number * 39, u2->hp);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_clone_men(CuTest *tc) {
|
||||
unit *u1, *u2;
|
||||
region *r;
|
||||
faction *f;
|
||||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
|
@ -592,13 +595,14 @@ static void test_clone_men(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 200, u1->hp);
|
||||
CuAssertIntEquals(tc, 1, u2->number);
|
||||
CuAssertIntEquals(tc, 20, u2->hp);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_transfermen(CuTest *tc) {
|
||||
unit *u1, *u2;
|
||||
region *r;
|
||||
faction *f;
|
||||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
|
@ -613,7 +617,7 @@ static void test_transfermen(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 140000, u2->hp);
|
||||
CuAssertIntEquals(tc, 0, u1->number);
|
||||
CuAssertIntEquals(tc, 0, u1->hp);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_unit_suite(void)
|
||||
|
|
|
@ -421,6 +421,8 @@ static int parse_ships(xmlDocPtr doc)
|
|||
st->flags |= SFL_FLY;
|
||||
if (xml_bvalue(node, "opensea", false))
|
||||
st->flags |= SFL_OPENSEA;
|
||||
if (xml_bvalue(node, "speedy", false))
|
||||
st->flags |= SFL_SPEEDY;
|
||||
st->fishing = xml_ivalue(node, "fishing", st->fishing);
|
||||
st->cptskill = xml_ivalue(node, "cptskill", st->cptskill);
|
||||
st->minskill = xml_ivalue(node, "minskill", st->minskill);
|
||||
|
|
|
@ -13,21 +13,23 @@ static void test_init_keywords(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
lang = get_or_create_locale("en");
|
||||
|
||||
locale_setstring(lang, "keyword::move", "MOVE");
|
||||
init_keywords(lang);
|
||||
CuAssertIntEquals(tc, K_MOVE, get_keyword("move", lang));
|
||||
CuAssertStrEquals(tc, "keyword::move", keyword(K_MOVE));
|
||||
CuAssertPtrEquals(tc, NULL, (void *)keyword(NOKEYWORD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_infinitive(CuTest *tc) {
|
||||
char buffer[32];
|
||||
struct locale *lang;
|
||||
struct order *ord;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
lang = get_or_create_locale("de");
|
||||
|
||||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keyword(lang, K_STUDY, "LERNE");
|
||||
init_keyword(lang, K_STUDY, "LERNEN");
|
||||
|
@ -38,12 +40,13 @@ static void test_infinitive(CuTest *tc) {
|
|||
ord = create_order(K_STUDY, lang, "");
|
||||
CuAssertStrEquals(tc, "LERNE", get_command(ord, lang, buffer, sizeof(buffer)));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_init_keyword(CuTest *tc) {
|
||||
struct locale *lang;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
|
||||
lang = get_or_create_locale("de");
|
||||
init_keyword(lang, K_MOVE, "NACH");
|
||||
|
@ -55,23 +58,23 @@ static void test_init_keyword(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang));
|
||||
CuAssertIntEquals(tc, K_DESTROY, get_keyword("zerst\xC3\xB6ren", lang));
|
||||
CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_findkeyword(CuTest *tc) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
CuAssertIntEquals(tc, K_MOVE, findkeyword("move"));
|
||||
CuAssertIntEquals(tc, K_STUDY, findkeyword("study"));
|
||||
CuAssertIntEquals(tc, NOKEYWORD, findkeyword(""));
|
||||
CuAssertIntEquals(tc, NOKEYWORD, findkeyword("potato"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_shortest_match(CuTest *tc) {
|
||||
struct locale *lang;
|
||||
critbit_tree ** cb;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = get_or_create_locale("en");
|
||||
|
||||
cb = (critbit_tree **)get_translations(lang, UT_KEYWORDS);
|
||||
|
@ -83,7 +86,7 @@ static void test_get_shortest_match(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_STATUS, get_keyword("COM", lang));
|
||||
CuAssertIntEquals(tc, K_STATUS, get_keyword("COMBAT", lang));
|
||||
CuAssertIntEquals(tc, K_COMBATSPELL, get_keyword("COMBATS", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_keyword_suite(void)
|
||||
|
|
143
src/laws.test.c
143
src/laws.test.c
|
@ -43,7 +43,7 @@ static void test_new_building_can_be_renamed(CuTest * tc)
|
|||
|
||||
b = test_create_building(r, NULL);
|
||||
CuAssertTrue(tc, !renamed_building(b));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rename_building(CuTest * tc)
|
||||
|
@ -66,7 +66,7 @@ static void test_rename_building(CuTest * tc)
|
|||
rename_building(u, NULL, b, "Villa Nagel");
|
||||
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
||||
CuAssertTrue(tc, renamed_building(b));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rename_building_twice(CuTest * tc)
|
||||
|
@ -91,7 +91,7 @@ static void test_rename_building_twice(CuTest * tc)
|
|||
|
||||
rename_building(u, NULL, b, "Villa Kunterbunt");
|
||||
CuAssertStrEquals(tc, "Villa Kunterbunt", b->name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_contact(CuTest * tc)
|
||||
|
@ -122,7 +122,7 @@ static void test_contact(CuTest * tc)
|
|||
CuAssertIntEquals(tc, HELP_GIVE, can_contact(r, u1, u2));
|
||||
u_set_building(u2, b);
|
||||
CuAssertIntEquals(tc, 1, can_contact(r, u1, u2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_enter_building(CuTest * tc)
|
||||
|
@ -158,7 +158,7 @@ static void test_enter_building(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, enter_building(u, NULL, b->no, true));
|
||||
CuAssertPtrNotNull(tc, u->faction->msgs);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_enter_ship(CuTest * tc)
|
||||
|
@ -168,7 +168,7 @@ static void test_enter_ship(CuTest * tc)
|
|||
ship *sh;
|
||||
race * rc;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
r = findregion(0, 0);
|
||||
|
@ -200,7 +200,7 @@ static void test_enter_ship(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, enter_ship(u, NULL, sh->no, true));
|
||||
CuAssertPtrNotNull(tc, u->faction->msgs);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_display_cmd(CuTest *tc) {
|
||||
|
@ -209,7 +209,7 @@ static void test_display_cmd(CuTest *tc) {
|
|||
region *r;
|
||||
order *ord;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
f = test_create_faction(0);
|
||||
assert(r && f);
|
||||
|
@ -231,7 +231,7 @@ static void test_display_cmd(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, NULL, r->land->display);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rule_force_leave(CuTest *tc) {
|
||||
|
@ -248,7 +248,7 @@ static void test_rule_force_leave(CuTest *tc) {
|
|||
config_set("rules.owners.force_leave", "3");
|
||||
CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL));
|
||||
CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_force_leave_buildings(CuTest *tc) {
|
||||
|
@ -280,7 +280,7 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
al->status = HELP_GUARD;
|
||||
force_leave(r, NULL);
|
||||
CuAssertPtrEquals_Msg(tc, "allies should not be forced to leave", b, u3->building);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_force_leave_ships(CuTest *tc) {
|
||||
|
@ -301,7 +301,7 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u2->ship);
|
||||
msg = test_get_last_message(u2->faction->msgs);
|
||||
CuAssertStrEquals(tc, "force_leave_ship", test_get_messagetype(msg));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_force_leave_ships_on_ocean(CuTest *tc) {
|
||||
|
@ -319,7 +319,7 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) {
|
|||
ship_set_owner(u1);
|
||||
force_leave(r, NULL);
|
||||
CuAssertPtrEquals_Msg(tc, "no forcing out of ships on oceans", sh, u2->ship);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_fishing_feeds_2_people(CuTest * tc)
|
||||
|
@ -355,7 +355,7 @@ static void test_fishing_feeds_2_people(CuTest * tc)
|
|||
sh->flags |= SF_FISHING;
|
||||
get_food(r);
|
||||
CuAssertIntEquals(tc, 32, i_get(u->items, rtype->itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
||||
|
@ -382,7 +382,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
|||
sh->flags |= SF_FISHING;
|
||||
get_food(r);
|
||||
CuAssertIntEquals(tc, 42, i_get(u->items, rtype->itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_fishing_gets_reset(CuTest * tc)
|
||||
|
@ -412,7 +412,7 @@ static void test_fishing_gets_reset(CuTest * tc)
|
|||
scale_number(u, 1);
|
||||
get_food(r);
|
||||
CuAssertIntEquals(tc, 32, i_get(u->items, rtype->itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unit_limit(CuTest * tc)
|
||||
|
@ -426,7 +426,7 @@ static void test_unit_limit(CuTest * tc)
|
|||
|
||||
config_set("rules.limit.alliance", "250");
|
||||
CuAssertIntEquals(tc, 250, rule_alliance_limit());
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_maketemp(CuTest * tc)
|
||||
|
@ -453,7 +453,7 @@ static void test_maketemp(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, NULL, u->orders->next);
|
||||
CuAssertIntEquals(tc, K_TAX, getkeyword(u->orders));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_maketemp_default_order(CuTest * tc)
|
||||
|
@ -483,7 +483,7 @@ static void test_maketemp_default_order(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, NULL, u->orders->next);
|
||||
CuAssertIntEquals(tc, K_TAX, getkeyword(u->orders));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_limit_new_units(CuTest * tc)
|
||||
|
@ -534,7 +534,7 @@ static void test_limit_new_units(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 2, f->num_units);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "too_many_units_in_alliance"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cannot_create_unit_above_limit(CuTest * tc)
|
||||
|
@ -552,7 +552,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc)
|
|||
config_set("rules.limit.alliance", "3");
|
||||
CuAssertIntEquals(tc, 0, checkunitnumber(f, 3));
|
||||
CuAssertIntEquals(tc, 1, checkunitnumber(f, 4));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_reserve_cmd(CuTest *tc) {
|
||||
|
@ -581,7 +581,7 @@ static void test_reserve_cmd(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 200, i_get(u1->items, rtype->itype));
|
||||
CuAssertIntEquals(tc, 0, i_get(u2->items, rtype->itype));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
struct pay_fixture {
|
||||
|
@ -628,7 +628,7 @@ static void test_pay_cmd(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, pay_cmd(fix.u1, ord));
|
||||
CuAssertIntEquals(tc, BLD_DONTPAY, b->flags&BLD_DONTPAY);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_pay_cmd_other_building(CuTest *tc) {
|
||||
|
@ -652,7 +652,7 @@ static void test_pay_cmd_other_building(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, pay_cmd(fix.u1, ord));
|
||||
CuAssertIntEquals(tc, BLD_DONTPAY, b->flags&BLD_DONTPAY);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_pay_cmd_must_be_owner(CuTest *tc) {
|
||||
|
@ -671,7 +671,7 @@ static void test_pay_cmd_must_be_owner(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, pay_cmd(fix.u2, ord));
|
||||
CuAssertIntEquals(tc, 0, b->flags&BLD_DONTPAY);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_new_units(CuTest *tc) {
|
||||
|
@ -696,7 +696,7 @@ static void test_new_units(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, u->age);
|
||||
CuAssertPtrEquals(tc, f, u->faction);
|
||||
CuAssertStrEquals(tc, "EINHEIT hurr", u->_name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
typedef struct guard_fixture {
|
||||
|
@ -737,7 +737,7 @@ static void test_update_guards(CuTest *tc) {
|
|||
freset(fix.u, UFL_GUARD);
|
||||
update_guards();
|
||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_newbie_cannot_guard(CuTest *tc) {
|
||||
|
@ -749,7 +749,7 @@ static void test_newbie_cannot_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_NEWBIE, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unarmed_cannot_guard(CuTest *tc) {
|
||||
|
@ -759,7 +759,7 @@ static void test_unarmed_cannot_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unarmed_races_can_guard(CuTest *tc) {
|
||||
|
@ -772,7 +772,7 @@ static void test_unarmed_races_can_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_OK, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monsters_can_guard(CuTest *tc) {
|
||||
|
@ -783,7 +783,7 @@ static void test_monsters_can_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_OK, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_unskilled_cannot_guard(CuTest *tc) {
|
||||
|
@ -794,7 +794,7 @@ static void test_unskilled_cannot_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_fleeing_cannot_guard(CuTest *tc) {
|
||||
|
@ -805,7 +805,7 @@ static void test_fleeing_cannot_guard(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_GUARD_FLEEING, can_start_guarding(fix.u));
|
||||
update_guards();
|
||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_reserve_self(CuTest *tc) {
|
||||
|
@ -837,7 +837,7 @@ static void test_reserve_self(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 100, i_get(u1->items, rtype->itype));
|
||||
CuAssertIntEquals(tc, 100, i_get(u2->items, rtype->itype));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void statistic_test(CuTest *tc, int peasants, int luck, int maxp,
|
||||
|
@ -862,7 +862,7 @@ static void test_peasant_luck_effect(CuTest *tc) {
|
|||
|
||||
config_set("rules.peasants.growth.factor", "1");
|
||||
statistic_test(tc, 1000, 1000, 1000, 0, 501, 501);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,7 +900,7 @@ static void test_luck_message(CuTest *tc) {
|
|||
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "peasantluck_success"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static unit * setup_name_cmd(void) {
|
||||
|
@ -929,7 +929,7 @@ static void test_name_unit(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor", u->_name);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_name_region(CuTest *tc) {
|
||||
|
@ -952,7 +952,7 @@ static void test_name_region(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor", u->region->land->name);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_name_building(CuTest *tc) {
|
||||
|
@ -996,7 +996,7 @@ static void test_name_building(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error278"));
|
||||
test_clear_messages(u->faction);
|
||||
name_cmd(u, ord); */
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_name_ship(CuTest *tc) {
|
||||
|
@ -1035,7 +1035,7 @@ static void test_name_ship(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84"));
|
||||
CuAssertStrEquals(tc, "Hodor", u->ship->name);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_normal(CuTest *tc) {
|
||||
|
@ -1055,7 +1055,7 @@ static void test_long_order_normal(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
CuAssertPtrEquals(tc, 0, u->old_orders);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_none(CuTest *tc) {
|
||||
|
@ -1067,7 +1067,7 @@ static void test_long_order_none(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrEquals(tc, 0, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_cast(CuTest *tc) {
|
||||
|
@ -1081,7 +1081,7 @@ static void test_long_order_cast(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_buy_sell(CuTest *tc) {
|
||||
|
@ -1096,7 +1096,7 @@ static void test_long_order_buy_sell(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_multi_long(CuTest *tc) {
|
||||
|
@ -1110,7 +1110,7 @@ static void test_long_order_multi_long(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_multi_buy(CuTest *tc) {
|
||||
|
@ -1124,7 +1124,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_multi_sell(CuTest *tc) {
|
||||
|
@ -1139,7 +1139,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_buy_cast(CuTest *tc) {
|
||||
|
@ -1153,7 +1153,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error52"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_long_order_hungry(CuTest *tc) {
|
||||
|
@ -1169,7 +1169,7 @@ static void test_long_order_hungry(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, K_WORK, getkeyword(u->thisorder));
|
||||
CuAssertPtrNotNull(tc, u->orders);
|
||||
CuAssertPtrEquals(tc, 0, u->faction->msgs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ally_cmd_errors(CuTest *tc) {
|
||||
|
@ -1187,7 +1187,7 @@ static void test_ally_cmd_errors(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error66"));
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_name_cmd(CuTest *tc) {
|
||||
|
@ -1232,7 +1232,7 @@ static void test_name_cmd(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor", al->name);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_name_cmd_2274(CuTest *tc) {
|
||||
|
@ -1263,7 +1263,7 @@ static void test_name_cmd_2274(CuTest *tc) {
|
|||
name_cmd(u1, u1->thisorder);
|
||||
CuAssertStrEquals(tc, "Hodor", r->land->name);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ally_cmd(CuTest *tc) {
|
||||
|
@ -1299,7 +1299,7 @@ static void test_ally_cmd(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, alliedfaction(0, u->faction, f, HELP_ALL));
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_nmr_warnings(CuTest *tc) {
|
||||
|
@ -1319,7 +1319,7 @@ static void test_nmr_warnings(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, f2->msgs->begin);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f2->msgs, "nmr_warning"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f2->msgs, "nmr_warning_final"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static unit * setup_mail_cmd(void) {
|
||||
|
@ -1341,7 +1341,7 @@ static void test_mail_unit(CuTest *tc) {
|
|||
mail_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "unitmessage"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_faction(CuTest *tc) {
|
||||
|
@ -1355,7 +1355,7 @@ static void test_mail_faction(CuTest *tc) {
|
|||
mail_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "regionmessage"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_region(CuTest *tc) {
|
||||
|
@ -1369,7 +1369,7 @@ static void test_mail_region(CuTest *tc) {
|
|||
mail_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->region->msgs, "mail_result"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_unit_no_msg(CuTest *tc) {
|
||||
|
@ -1384,7 +1384,7 @@ static void test_mail_unit_no_msg(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "unitmessage"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_faction_no_msg(CuTest *tc) {
|
||||
|
@ -1399,7 +1399,7 @@ static void test_mail_faction_no_msg(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "regionmessage"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_faction_no_target(CuTest *tc) {
|
||||
|
@ -1414,7 +1414,7 @@ static void test_mail_faction_no_target(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "regionmessage"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error66"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_mail_region_no_msg(CuTest *tc) {
|
||||
|
@ -1429,7 +1429,7 @@ static void test_mail_region_no_msg(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->region->msgs, "mail_result"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30"));
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_show_without_item(CuTest *tc)
|
||||
|
@ -1474,7 +1474,7 @@ static void test_show_without_item(CuTest *tc)
|
|||
test_clear_messages(f);
|
||||
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_show_race(CuTest *tc) {
|
||||
|
@ -1515,7 +1515,7 @@ static void test_show_race(CuTest *tc) {
|
|||
test_clear_messages(u->faction);
|
||||
free_order(ord);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_show_both(CuTest *tc) {
|
||||
|
@ -1525,8 +1525,7 @@ static void test_show_both(CuTest *tc) {
|
|||
struct locale *loc;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("msg_event", "string:string", 0));
|
||||
mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", 0));
|
||||
rc = test_create_race("elf");
|
||||
|
@ -1557,7 +1556,7 @@ static void test_show_both(CuTest *tc) {
|
|||
CuAssertTrue(tc, memcmp("Hiyaa!", msg->parameters[2].v, 4) == 0);
|
||||
test_clear_messages(u->faction);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_immigration(CuTest * tc)
|
||||
|
@ -1587,7 +1586,7 @@ static void test_immigration(CuTest * tc)
|
|||
immigration();
|
||||
CuAssertIntEquals(tc, 2, rpeasants(r));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_demon_hunger(CuTest * tc)
|
||||
|
@ -1627,7 +1626,7 @@ static void test_demon_hunger(CuTest * tc)
|
|||
msg = test_get_last_message(u->faction->msgs);
|
||||
CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_armedmen(CuTest *tc) {
|
||||
|
@ -1658,7 +1657,7 @@ static void test_armedmen(CuTest *tc) {
|
|||
wtype->flags |= WTF_SIEGE;
|
||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
||||
CuAssertIntEquals(tc, 1, armedmen(u, true));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cansee(CuTest *tc) {
|
||||
|
@ -1676,7 +1675,7 @@ static void test_cansee(CuTest *tc) {
|
|||
set_level(u, SK_PERCEPTION, 1);
|
||||
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cansee_ring(CuTest *tc) {
|
||||
|
@ -1709,7 +1708,7 @@ static void test_cansee_ring(CuTest *tc) {
|
|||
i_change(&u->items, itype[1], 1);
|
||||
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cansee_sphere(CuTest *tc) {
|
||||
|
@ -1742,7 +1741,7 @@ static void test_cansee_sphere(CuTest *tc) {
|
|||
scale_number(u2, 99);
|
||||
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_laws_suite(void)
|
||||
|
|
|
@ -49,7 +49,7 @@ static void test_lighthouse_range(CuTest * tc)
|
|||
set_level(u1, SK_PERCEPTION, 9);
|
||||
CuAssertIntEquals(tc, 3, lighthouse_range(b, u1->faction, u1));
|
||||
CuAssertIntEquals(tc, 1, lighthouse_range(b, u2->faction, u2));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_lighthouse_update(CuTest * tc)
|
||||
|
@ -88,7 +88,7 @@ static void test_lighthouse_update(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r2->attribs->type);
|
||||
CuAssertPtrNotNull(tc, r3->attribs);
|
||||
CuAssertPtrEquals(tc, (void *)&at_lighthouse, (void *)r3->attribs->type);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_lighthouse_suite(void)
|
||||
|
|
|
@ -49,7 +49,7 @@ void test_updatespells(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 1, selist_length(f->spellbook->spells));
|
||||
CuAssertPtrNotNull(tc, spellbook_get(f->spellbook, sp));
|
||||
free_spellbook(book);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_spellbook(CuTest * tc)
|
||||
|
@ -60,7 +60,7 @@ static void test_get_spellbook(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, sb = get_spellbook("hodorhodorhodor"));
|
||||
CuAssertPtrEquals(tc, sb, get_spellbook("hodorhodorhodor"));
|
||||
CuAssertTrue(tc, sb != get_spellbook("hodor"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_spellbooks(CuTest * tc)
|
||||
|
@ -87,10 +87,13 @@ static void test_spellbooks(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, entry);
|
||||
CuAssertPtrEquals(tc, sp, entry->sp);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
test_setup();
|
||||
|
||||
herp = get_spellbook("herp");
|
||||
CuAssertPtrNotNull(tc, herp);
|
||||
test_cleanup();
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_pay_spell(CuTest * tc)
|
||||
|
@ -124,7 +127,7 @@ void test_pay_spell(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, get_resource(u, get_resourcetype(R_SILVER)));
|
||||
CuAssertIntEquals(tc, 0, get_resource(u, get_resourcetype(R_AURA)));
|
||||
CuAssertIntEquals(tc, 0, get_resource(u, get_resourcetype(R_HORSE)));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_pay_spell_failure(CuTest * tc)
|
||||
|
@ -162,7 +165,7 @@ void test_pay_spell_failure(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, eff_spelllevel(u, sp, 3, 1));
|
||||
CuAssertIntEquals(tc, 0, change_resource(u, get_resourcetype(R_SILVER), -1));
|
||||
CuAssertIntEquals(tc, 0, eff_spelllevel(u, sp, 2, 1));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_getspell_unit(CuTest * tc)
|
||||
|
@ -190,7 +193,7 @@ void test_getspell_unit(CuTest * tc)
|
|||
|
||||
unit_add_spell(u, 0, sp, 1);
|
||||
CuAssertPtrNotNull(tc, unit_getspell(u, "Herp-a-derp", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_getspell_faction(CuTest * tc)
|
||||
|
@ -220,7 +223,7 @@ void test_getspell_faction(CuTest * tc)
|
|||
f->spellbook = create_spellbook(0);
|
||||
spellbook_add(f->spellbook, sp, 1);
|
||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_getspell_school(CuTest * tc)
|
||||
|
@ -251,7 +254,7 @@ void test_getspell_school(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, book);
|
||||
spellbook_add(book, sp, 1);
|
||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_set_pre_combatspell(CuTest * tc)
|
||||
|
@ -283,7 +286,7 @@ void test_set_pre_combatspell(CuTest * tc)
|
|||
unset_combatspell(u, sp);
|
||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_set_main_combatspell(CuTest * tc)
|
||||
|
@ -315,7 +318,7 @@ void test_set_main_combatspell(CuTest * tc)
|
|||
unset_combatspell(u, sp);
|
||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_set_post_combatspell(CuTest * tc)
|
||||
|
@ -347,7 +350,7 @@ void test_set_post_combatspell(CuTest * tc)
|
|||
unset_combatspell(u, sp);
|
||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_hasspell(CuTest * tc)
|
||||
|
@ -376,7 +379,7 @@ void test_hasspell(CuTest * tc)
|
|||
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
CuAssertTrue(tc, !u_hasspell(u, sp));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static selist * casts;
|
||||
|
@ -412,7 +415,7 @@ void test_multi_cast(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, casts);
|
||||
CuAssertIntEquals(tc, 2, selist_length(casts));
|
||||
selist_free(casts);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_magic_resistance(CuTest *tc) {
|
||||
|
@ -431,7 +434,7 @@ static void test_magic_resistance(CuTest *tc) {
|
|||
CuAssert(tc, "brain eaters outside astral space have 50% magres", frac_equal(magic_resistance(u), frac_make(1, 2)));
|
||||
u->region->_plane = get_astralplane();
|
||||
CuAssert(tc, "brain eaters in astral space have full magres", frac_equal(magic_resistance(u), frac_make(9, 10)));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_max_spellpoints(CuTest *tc) {
|
||||
|
@ -454,7 +457,7 @@ static void test_max_spellpoints(CuTest *tc) {
|
|||
/* permanent aura loss: */
|
||||
CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2));
|
||||
CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_illusioncastle(CuTest *tc)
|
||||
|
@ -475,7 +478,7 @@ static void test_illusioncastle(CuTest *tc)
|
|||
CuAssertStrEquals(tc, "castle", buildingtype(btype, b, b->size));
|
||||
btype->construction->name = strdup("site");
|
||||
CuAssertStrEquals(tc, "site", buildingtype(btype, b, b->size));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_is_mage(CuTest *tc) {
|
||||
|
@ -492,7 +495,7 @@ static void test_is_mage(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, mage = create_mage(u, M_CERDDOR));
|
||||
CuAssertPtrEquals(tc, mage, get_mage(u));
|
||||
CuAssertTrue(tc, is_mage(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_mage(CuTest *tc) {
|
||||
|
@ -509,7 +512,7 @@ static void test_get_mage(CuTest *tc) {
|
|||
set_level(u, SK_MAGIC, 1);
|
||||
CuAssertPtrEquals(tc, mage, get_mage(u));
|
||||
CuAssertPtrEquals(tc, mage, get_mage_depr(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_familiar_set(CuTest *tc) {
|
||||
|
@ -529,7 +532,7 @@ static void test_familiar_set(CuTest *tc) {
|
|||
remove_familiar(mag);
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar(mag));
|
||||
CuAssertPtrEquals(tc, NULL, a_find(mag->attribs, &at_skillmod));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_familiar_age(CuTest *tc) {
|
||||
|
@ -549,7 +552,7 @@ static void test_familiar_age(CuTest *tc) {
|
|||
set_number(fam, 0);
|
||||
a_age(&mag->attribs, mag);
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar(mag));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_familiar_equip(CuTest *tc) {
|
||||
|
@ -586,7 +589,7 @@ static void test_familiar_equip(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, mage, get_mage_depr(u));
|
||||
CuAssertTrue(tc, u_hasspell(u, sp));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_familiar_suite(void)
|
||||
|
|
|
@ -74,7 +74,7 @@ static void test_market_curse(CuTest * tc)
|
|||
|
||||
CuAssertIntEquals(tc, 70, i_get(u->items, htype));
|
||||
CuAssertIntEquals(tc, 35, i_get(u->items, ltype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_rc_trade(CuTest *tc) {
|
||||
|
@ -87,7 +87,7 @@ static void test_rc_trade(CuTest *tc) {
|
|||
rc_set_param(rc, "herb_trade", "50");
|
||||
CuAssertIntEquals(tc, 100, rc_luxury_trade(rc));
|
||||
CuAssertIntEquals(tc, 50, rc_herb_trade(rc));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_market_suite(void)
|
||||
|
|
|
@ -48,8 +48,6 @@ static void create_monsters(unit **up, unit **um) {
|
|||
region *r;
|
||||
faction *fp, *fm;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_create_horse();
|
||||
default_locale = test_create_locale();
|
||||
fp = test_create_faction(NULL);
|
||||
|
@ -74,6 +72,7 @@ static void test_monsters_attack(CuTest * tc)
|
|||
{
|
||||
unit *u, *m;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
setguard(m, true);
|
||||
|
||||
|
@ -82,7 +81,7 @@ static void test_monsters_attack(CuTest * tc)
|
|||
plan_monsters(m->faction);
|
||||
|
||||
CuAssertPtrNotNull(tc, find_order("attack 1", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monsters_attack_ocean(CuTest * tc)
|
||||
|
@ -90,6 +89,7 @@ static void test_monsters_attack_ocean(CuTest * tc)
|
|||
region *r;
|
||||
unit *u, *m;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
r = findregion(-1, 0); /* ocean */
|
||||
u = test_create_unit(u->faction, r);
|
||||
|
@ -102,19 +102,20 @@ static void test_monsters_attack_ocean(CuTest * tc)
|
|||
plan_monsters(m->faction);
|
||||
|
||||
CuAssertPtrNotNull(tc, find_order("attack 2", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monsters_waiting(CuTest * tc)
|
||||
{
|
||||
unit *u, *m;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
setguard(m, true);
|
||||
fset(m, UFL_ISNEW);
|
||||
monster_attacks(m, false);
|
||||
CuAssertPtrEquals(tc, 0, find_order("attack 1", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_seaserpent_piracy(CuTest * tc)
|
||||
|
@ -124,6 +125,7 @@ static void test_seaserpent_piracy(CuTest * tc)
|
|||
race *rc;
|
||||
ship_type * stype;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
stype = test_create_shiptype("yacht");
|
||||
r = findregion(-1, 0); /* ocean */
|
||||
|
@ -145,13 +147,14 @@ static void test_seaserpent_piracy(CuTest * tc)
|
|||
stype->cargo = 50001;
|
||||
plan_monsters(m->faction);
|
||||
CuAssertPtrNotNull(tc, find_order("attack 2", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monsters_attack_not(CuTest * tc)
|
||||
{
|
||||
unit *u, *m;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
|
||||
setguard(m, true);
|
||||
|
@ -162,7 +165,7 @@ static void test_monsters_attack_not(CuTest * tc)
|
|||
plan_monsters(m->faction);
|
||||
|
||||
CuAssertPtrEquals(tc, 0, find_order("attack 1", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_dragon_attacks_the_rich(CuTest * tc)
|
||||
|
@ -170,6 +173,7 @@ static void test_dragon_attacks_the_rich(CuTest * tc)
|
|||
unit *u, *m;
|
||||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
init_resources();
|
||||
|
||||
|
@ -187,7 +191,7 @@ static void test_dragon_attacks_the_rich(CuTest * tc)
|
|||
plan_monsters(m->faction);
|
||||
CuAssertPtrNotNull(tc, find_order("attack 1", m));
|
||||
CuAssertPtrNotNull(tc, find_order("loot", m));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
extern void random_growl(const unit *u, region *tr, int rand);
|
||||
|
@ -198,6 +202,7 @@ static void test_dragon_moves(CuTest * tc)
|
|||
unit *u, *m;
|
||||
struct message *msg;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
rsetmoney(findregion(1, 0), 1000);
|
||||
r = findregion(0, 0); /* plain */
|
||||
|
@ -221,7 +226,7 @@ static void test_dragon_moves(CuTest * tc)
|
|||
assert_pointer_parameter(tc, msg, 2, findregion(1,0));
|
||||
assert_string_parameter(tc, msg, 3, "growl3");
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monsters_learn_exp(CuTest * tc)
|
||||
|
@ -229,6 +234,7 @@ static void test_monsters_learn_exp(CuTest * tc)
|
|||
unit *u, *m;
|
||||
skill* sk;
|
||||
|
||||
test_setup();
|
||||
create_monsters(&u, &m);
|
||||
config_set("study.produceexp", "30");
|
||||
|
||||
|
@ -241,7 +247,7 @@ static void test_monsters_learn_exp(CuTest * tc)
|
|||
sk = unit_skill(m, SK_MELEE);
|
||||
CuAssertTrue(tc, sk && (sk->level > 0 || (sk->level == 0 && sk->weeks > 0)));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_spawn_seaserpent(CuTest *tc) {
|
||||
|
@ -249,7 +255,7 @@ static void test_spawn_seaserpent(CuTest *tc) {
|
|||
unit *u;
|
||||
faction *f;
|
||||
race *rc;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
rc = test_create_race("seaserpent");
|
||||
rc->flags |= RCF_NPC;
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
@ -257,7 +263,7 @@ static void test_spawn_seaserpent(CuTest *tc) {
|
|||
u = spawn_seaserpent(r, f);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, 0, u->_name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_monsters_suite(void)
|
||||
|
|
|
@ -34,7 +34,7 @@ static void test_ship_not_allowed_in_coast(CuTest * tc)
|
|||
terrain_type *ttype, *otype;
|
||||
ship_type *stype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
|
||||
otype = test_create_terrain("ocean", SEA_REGION);
|
||||
stype = test_create_shiptype("derp");
|
||||
|
@ -49,7 +49,7 @@ static void test_ship_not_allowed_in_coast(CuTest * tc)
|
|||
CuAssertIntEquals(tc, SA_NO_COAST, check_ship_allowed(sh, r1));
|
||||
stype->coasts[0] = ttype;
|
||||
CuAssertIntEquals(tc, SA_COAST, check_ship_allowed(sh, r1));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
typedef struct move_fixture {
|
||||
|
@ -67,8 +67,6 @@ static void setup_harbor(move_fixture *mf) {
|
|||
building * b;
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
|
||||
btype = test_create_buildingtype("harbour");
|
||||
|
||||
|
@ -92,15 +90,18 @@ static void test_ship_allowed_without_harbormaster(CuTest * tc)
|
|||
{
|
||||
move_fixture mf;
|
||||
|
||||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(mf.sh, mf.r));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_blocked_by_harbormaster(CuTest * tc) {
|
||||
unit *u;
|
||||
move_fixture mf;
|
||||
|
||||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(0), mf.r);
|
||||
|
@ -108,13 +109,14 @@ static void test_ship_blocked_by_harbormaster(CuTest * tc) {
|
|||
building_set_owner(u);
|
||||
|
||||
CuAssertIntEquals_Msg(tc, "harbor master must contact ship", SA_NO_COAST, check_ship_allowed(mf.sh, mf.r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_has_harbormaster_contact(CuTest * tc) {
|
||||
unit *u;
|
||||
move_fixture mf;
|
||||
|
||||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(0), mf.r);
|
||||
|
@ -123,13 +125,14 @@ static void test_ship_has_harbormaster_contact(CuTest * tc) {
|
|||
usetcontact(mf.b->_owner, mf.sh->_owner);
|
||||
|
||||
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(mf.sh, mf.r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_has_harbormaster_same_faction(CuTest * tc) {
|
||||
unit *u;
|
||||
move_fixture mf;
|
||||
|
||||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(mf.u->faction, mf.r);
|
||||
|
@ -137,7 +140,7 @@ static void test_ship_has_harbormaster_same_faction(CuTest * tc) {
|
|||
building_set_owner(u);
|
||||
|
||||
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(mf.sh, mf.r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
||||
|
@ -145,6 +148,7 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
|||
move_fixture mf;
|
||||
ally *al;
|
||||
|
||||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(0), mf.r);
|
||||
|
@ -154,7 +158,7 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
|||
al->status = HELP_GUARD;
|
||||
|
||||
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(mf.sh, mf.r));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_walkingcapacity(CuTest *tc) {
|
||||
|
@ -196,7 +200,7 @@ static void test_walkingcapacity(CuTest *tc) {
|
|||
config_set("rules.trollbelt.multiplier", "5");
|
||||
CuAssertIntEquals(tc, cap + 4 * u->_race->capacity, walkingcapacity(u));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_trails(CuTest *tc) {
|
||||
|
@ -205,7 +209,7 @@ static void test_ship_trails(CuTest *tc) {
|
|||
terrain_type *otype;
|
||||
region_list *route = 0;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
otype = test_create_terrain("ocean", SEA_REGION);
|
||||
r1 = test_create_region(0, 0, otype);
|
||||
r2 = test_create_region(1, 0, otype);
|
||||
|
@ -227,7 +231,7 @@ static void test_ship_trails(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, a_find(r2->attribs, &at_shiptrail));
|
||||
CuAssertPtrNotNull(tc, a_find(r3->attribs, &at_shiptrail));
|
||||
free_regionlist(route);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_age_trails(CuTest *tc) {
|
||||
|
@ -235,7 +239,7 @@ static void test_age_trails(CuTest *tc) {
|
|||
region *r1, *r2;
|
||||
ship *sh;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
r1 = test_create_region(0, 0, 0);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
sh = test_create_ship(r1, 0);
|
||||
|
@ -249,7 +253,7 @@ static void test_age_trails(CuTest *tc) {
|
|||
a_age(&r1->attribs, r1);
|
||||
CuAssertPtrEquals(tc, 0, r1->attribs);
|
||||
free_regionlist(route);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
struct drift_fixture {
|
||||
|
@ -263,7 +267,6 @@ struct drift_fixture {
|
|||
};
|
||||
|
||||
void setup_drift (struct drift_fixture *fix) {
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
config_set("rules.ship.storms", "0");
|
||||
|
||||
|
@ -281,6 +284,7 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
static void test_ship_no_overload(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 2;
|
||||
|
@ -288,12 +292,13 @@ static void test_ship_no_overload(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, fix.u->region, findregion(-1,0));
|
||||
CuAssertIntEquals(tc, 0, fix.sh->damage);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_empty(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
fix.u->ship = NULL;
|
||||
ship_update_owner(fix.sh);
|
||||
|
@ -303,12 +308,13 @@ static void test_ship_empty(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 2, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(fix.f->msgs, "ship_drift"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_no_drift_damage(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
fix.u->ship = NULL;
|
||||
ship_update_owner(fix.sh);
|
||||
|
@ -319,12 +325,13 @@ static void test_no_drift_damage(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(fix.f->msgs, "ship_drift"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_normal_overload(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 21;
|
||||
|
@ -333,12 +340,13 @@ static void test_ship_normal_overload(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 2, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "ship_drift"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_big_overload(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 22;
|
||||
|
@ -347,12 +355,13 @@ static void test_ship_big_overload(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 5, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_no_real_overload(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 21;
|
||||
|
@ -362,12 +371,13 @@ static void test_ship_no_real_overload(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 82, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_ridiculous_overload(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 500;
|
||||
|
@ -375,12 +385,13 @@ static void test_ship_ridiculous_overload(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 37, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_ridiculous_overload_no_captain(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
set_level(fix.u, SK_SAILING, 0);
|
||||
|
||||
|
@ -389,12 +400,13 @@ static void test_ship_ridiculous_overload_no_captain(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 37, ship_damage_percent(fix.sh));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_ridiculous_overload_bad(CuTest *tc) {
|
||||
struct drift_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_drift(&fix);
|
||||
|
||||
fix.u->number = 500;
|
||||
|
@ -404,7 +416,7 @@ static void test_ship_ridiculous_overload_bad(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "massive_overload"));
|
||||
CuAssertPtrEquals(tc, 0, fix.sh->region);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.f->msgs, "shipsink"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
extern double damage_overload(double overload);
|
||||
|
@ -473,7 +485,7 @@ static void test_follow_ship_msg(CuTest * tc) {
|
|||
CuAssertPtrNotNull(tc, p);
|
||||
CuAssertIntEquals(tc, K_FOLLOW, getkeyword((order *)p));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_drifting_ships(CuTest *tc) {
|
||||
|
@ -481,6 +493,7 @@ static void test_drifting_ships(CuTest *tc) {
|
|||
region *r;
|
||||
terrain_type *t_ocean, *t_plain;
|
||||
ship_type *st_boat;
|
||||
|
||||
test_setup();
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
|
@ -491,7 +504,7 @@ static void test_drifting_ships(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, D_EAST, drift_target(sh));
|
||||
test_create_region(-1, 0, t_plain);
|
||||
CuAssertIntEquals(tc, D_WEST, drift_target(sh));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_ship_leave_trail(CuTest *tc) {
|
||||
|
@ -520,7 +533,7 @@ static void test_ship_leave_trail(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, &at_shiptrail, (void *)r2->attribs->next->type);
|
||||
CuAssertPtrEquals(tc, &at_lighthouse, (void *)r2->attribs->next->next->type);
|
||||
free_regionlist(route);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_movement_speed(CuTest *tc) {
|
||||
|
@ -543,7 +556,7 @@ static void test_movement_speed(CuTest *tc) {
|
|||
i_change(&u->items, it_horse, 1);
|
||||
CuAssertIntEquals(tc, BP_RIDING, movement_speed(u));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_route_cycle(CuTest *tc) {
|
||||
|
@ -566,7 +579,7 @@ static void test_route_cycle(CuTest *tc) {
|
|||
move_cmd(u, u->orders);
|
||||
CuAssertIntEquals(tc, 1, u->region->x);
|
||||
CuAssertStrEquals(tc, "route east nw west", get_command(u->orders, lang, buffer, sizeof(buffer)));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_route_pause(CuTest *tc) {
|
||||
|
@ -589,20 +602,20 @@ static void test_route_pause(CuTest *tc) {
|
|||
move_cmd(u, u->orders);
|
||||
CuAssertIntEquals(tc, 2, u->region->x);
|
||||
CuAssertStrEquals(tc, "route PAUSE EAST NW", get_command(u->orders, lang, buffer, sizeof(buffer)));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_movement_speed_dragon(CuTest *tc) {
|
||||
unit *u;
|
||||
race *rc;
|
||||
test_setup();
|
||||
|
||||
test_setup();
|
||||
rc = test_create_race("dragon");
|
||||
rc->flags |= RCF_DRAGON;
|
||||
rc->speed = 1.5;
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 6, movement_speed(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_move_suite(void)
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_names(CuTest * tc)
|
|||
{
|
||||
unit *u;
|
||||
race *rc;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
register_names();
|
||||
CuAssertPtrNotNull(tc, get_function("name_undead"));
|
||||
CuAssertPtrNotNull(tc, get_function("name_skeleton"));
|
||||
|
@ -34,7 +34,7 @@ static void test_names(CuTest * tc)
|
|||
CuAssertTrue(tc, rc->name_unit == (race_func)get_function("name_undead"));
|
||||
name_unit(u);
|
||||
CuAssertStrEquals(tc, "Graue Kobolde", u->_name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_monster_names(CuTest *tc) {
|
||||
|
@ -58,7 +58,7 @@ static void test_monster_names(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Eisengolem", unit_getname(u));
|
||||
u->number = 2;
|
||||
CuAssertStrEquals(tc, "Eisengolems", unit_getname(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_names_suite(void)
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_read_orders(CuTest *tc) {
|
|||
in.getbuf = getbuf_null;
|
||||
in.data = NULL;
|
||||
CuAssertIntEquals(tc, 0, read_orders(&in));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
typedef struct order_list {
|
||||
|
@ -52,7 +52,7 @@ static void test_faction_password_okay(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, read_orders(&in));
|
||||
CuAssertIntEquals(tc, 2, olist.next);
|
||||
CuAssertIntEquals(tc, turn, f->lastorders);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_faction_password_bad(CuTest *tc) {
|
||||
|
@ -74,7 +74,7 @@ static void test_faction_password_bad(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, read_orders(&in));
|
||||
CuAssertIntEquals(tc, 2, olist.next);
|
||||
CuAssertIntEquals(tc, turn - 1, f->lastorders);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_orderfile_suite(void)
|
||||
|
|
|
@ -21,7 +21,6 @@ static void setup_piracy(void) {
|
|||
struct locale *lang;
|
||||
ship_type *st_boat;
|
||||
|
||||
test_cleanup();
|
||||
config_set("rules.ship.storms", "0");
|
||||
lang = get_or_create_locale("de");
|
||||
locale_setstring(lang, directions[D_EAST], "OSTEN");
|
||||
|
@ -77,9 +76,9 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
terrain_type *t_ocean;
|
||||
ship_type *st_boat;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
setup_piracy();
|
||||
|
||||
t_ocean = get_or_create_terrain("ocean");
|
||||
st_boat = st_get_or_create("boat");
|
||||
u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean));
|
||||
|
@ -101,7 +100,7 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(f->msgs, "piratesawvictim"));
|
||||
CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(f->msgs, "shipsail"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_piracy_cmd_errors(CuTest * tc) {
|
||||
|
@ -110,9 +109,9 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
unit *u, *u2;
|
||||
ship_type *st_boat;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
setup_piracy();
|
||||
|
||||
st_boat = st_get_or_create("boat");
|
||||
r = test_create_race("pirates");
|
||||
u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
|
@ -149,15 +148,14 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
CuAssertPtrNotNullMsg(tc, "must specify target for PIRACY", test_find_messagetype(f->msgs, "piratenovictim"));
|
||||
CuAssertPtrNotNull(tc, u->thisorder);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_piracy_cmd_walking(CuTest * tc) {
|
||||
unit *pirate, *victim;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
setup_pirate(&pirate, 0, 0, NULL, &victim, SWIM_INTO | SEA_REGION, "boat");
|
||||
/* fset(rc, RCF_SWIM); */
|
||||
r = pirate->region;
|
||||
|
@ -167,7 +165,7 @@ static void test_piracy_cmd_walking(CuTest * tc) {
|
|||
CuAssertTrue(tc, pirate->region == r);
|
||||
CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(pirate->faction->msgs, "error144"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
||||
|
@ -178,8 +176,7 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
|||
const terrain_type *t_plain;
|
||||
const ship_type *stype;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
setup_piracy();
|
||||
t_plain = get_or_create_terrain("plain");
|
||||
stype = test_create_shiptype("boat");
|
||||
|
@ -203,15 +200,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
|||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
CuAssertPtrEquals(tc, r, u->region);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_piracy_cmd_swimmer(CuTest * tc) {
|
||||
unit *pirate, *victim;
|
||||
region *r;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
setup_pirate(&pirate, 0, RCF_SWIM, NULL, &victim, SWIM_INTO | SEA_REGION, "boat");
|
||||
r = pirate->region;
|
||||
|
||||
|
@ -222,7 +218,7 @@ static void test_piracy_cmd_swimmer(CuTest * tc) {
|
|||
CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(pirate->faction->msgs, "piratesawvictim"));
|
||||
CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(pirate->faction->msgs, "travel"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_piracy_suite(void)
|
||||
|
|
|
@ -18,7 +18,7 @@ static void test_add_prefix(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, race_prefixes[2]);
|
||||
free_prefixes();
|
||||
CuAssertPtrEquals(tc, 0, race_prefixes);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_prefix_suite(void)
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_renumber_faction(CuTest *tc) {
|
|||
renumber_cmd(u, u->thisorder);
|
||||
renumber_factions();
|
||||
CuAssertIntEquals(tc, uno, u->faction->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_faction_duplicate(CuTest *tc) {
|
||||
|
@ -46,7 +46,7 @@ static void test_renumber_faction_duplicate(CuTest *tc) {
|
|||
renumber_factions();
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "renumber_inuse"));
|
||||
CuAssertIntEquals(tc, no, u->faction->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_building(CuTest *tc) {
|
||||
|
@ -63,7 +63,7 @@ static void test_renumber_building(CuTest *tc) {
|
|||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
|
||||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertIntEquals(tc, uno, u->building->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_building_duplicate(CuTest *tc) {
|
||||
|
@ -83,7 +83,7 @@ static void test_renumber_building_duplicate(CuTest *tc) {
|
|||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||
CuAssertIntEquals(tc, no, u->building->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_ship(CuTest *tc) {
|
||||
|
@ -100,7 +100,7 @@ static void test_renumber_ship(CuTest *tc) {
|
|||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
|
||||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertIntEquals(tc, uno, u->ship->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_ship_twice(CuTest *tc) {
|
||||
|
@ -121,7 +121,7 @@ static void test_renumber_ship_twice(CuTest *tc) {
|
|||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(no));
|
||||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertIntEquals(tc, no, u->ship->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_ship_duplicate(CuTest *tc) {
|
||||
|
@ -141,7 +141,7 @@ static void test_renumber_ship_duplicate(CuTest *tc) {
|
|||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||
CuAssertIntEquals(tc, no, u->ship->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_unit(CuTest *tc) {
|
||||
|
@ -158,7 +158,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
renumber_cmd(u, u->thisorder);
|
||||
CuAssertIntEquals(tc, uno, u->no);
|
||||
CuAssertIntEquals(tc, -no, ualias(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_unit_duplicate(CuTest *tc) {
|
||||
|
@ -177,7 +177,7 @@ static void test_renumber_unit_duplicate(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, no, u->no);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||
CuAssertIntEquals(tc, 0, ualias(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_unit_limit(CuTest *tc) {
|
||||
|
@ -195,7 +195,7 @@ static void test_renumber_unit_limit(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, no, u->no);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error114"));
|
||||
CuAssertIntEquals(tc, 0, ualias(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_renumber_unit_invalid(CuTest *tc) {
|
||||
|
@ -213,7 +213,7 @@ static void test_renumber_unit_invalid(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, no, u->no);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error116"));
|
||||
CuAssertIntEquals(tc, 0, ualias(u));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_renumber_suite(void)
|
||||
|
|
|
@ -138,7 +138,7 @@ static void test_report_region(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 1 Stein/1, 1 Bauer, 1 Silber, 1 Pferd.\n", buf);
|
||||
|
||||
mstream_done(&out);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_report_travelthru(CuTest *tc) {
|
||||
|
@ -185,7 +185,7 @@ static void test_report_travelthru(CuTest *tc) {
|
|||
CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len);
|
||||
|
||||
mstream_done(&out);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -219,7 +219,6 @@ static void setup_spell_fixture(spell_fixture * spf) {
|
|||
static void cleanup_spell_fixture(spell_fixture *spf) {
|
||||
spellbook_clear(spf->spb);
|
||||
free(spf->spb);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void set_parameter(spell_fixture spell, char *value) {
|
||||
|
@ -259,7 +258,7 @@ static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char
|
|||
static void test_write_spell_syntax(CuTest *tc) {
|
||||
spell_fixture spell;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
setup_spell_fixture(&spell);
|
||||
|
||||
check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\"");
|
||||
|
@ -312,6 +311,7 @@ static void test_write_spell_syntax(CuTest *tc) {
|
|||
" ZAUBERE \"Testzauber\" ( REGION | EINHEIT <enr> [<enr> ...] | SCHIFF <snr>\n [<snr> ...] | BURG <bnr> [<bnr> ...] )");
|
||||
|
||||
cleanup_spell_fixture(&spell);
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_report_suite(void)
|
||||
|
|
|
@ -76,7 +76,7 @@ static void test_reorder_units(CuTest * tc)
|
|||
CuAssertPtrEquals(tc, u1, u2->next);
|
||||
CuAssertPtrEquals(tc, u0, u1->next);
|
||||
CuAssertPtrEquals(tc, 0, u0->next);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_regionid(CuTest * tc) {
|
||||
|
@ -85,7 +85,7 @@ static void test_regionid(CuTest * tc) {
|
|||
struct region * r;
|
||||
char buffer[64];
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
plain = test_create_terrain("plain", 0);
|
||||
r = test_create_region(0, 0, plain);
|
||||
|
||||
|
@ -99,14 +99,14 @@ static void test_regionid(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, 10, (int)len);
|
||||
CuAssertStrEquals(tc, "plain (0,0", buffer);
|
||||
CuAssertIntEquals(tc, 0x7d, buffer[11]);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_seen_faction(CuTest *tc) {
|
||||
faction *f1, *f2;
|
||||
race *rc;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
f1 = test_create_faction(rc);
|
||||
f2 = test_create_faction(rc);
|
||||
|
@ -120,7 +120,7 @@ static void test_seen_faction(CuTest *tc) {
|
|||
f2 = (faction *)selist_get(f1->seen_factions, 1);
|
||||
f1 = (faction *)selist_get(f1->seen_factions, 0);
|
||||
CuAssertTrue(tc, f1->no < f2->no);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_sparagraph(CuTest *tc) {
|
||||
|
@ -252,7 +252,7 @@ static void test_bufunit_fstealth(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_bufunit(CuTest *tc) {
|
||||
|
@ -294,7 +294,7 @@ static void test_bufunit(CuTest *tc) {
|
|||
bufunit(f, u, 0, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_arg_resources(CuTest *tc) {
|
||||
|
@ -327,7 +327,7 @@ static void test_arg_resources(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 5, res->number);
|
||||
CuAssertPtrEquals(tc, 0, res->next);
|
||||
atype->release(v2);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_newbie_password_message(CuTest *tc) {
|
||||
|
@ -345,7 +345,7 @@ static void test_newbie_password_message(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, FFL_PWMSG, f->flags&FFL_PWMSG);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd"));
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_prepare_travelthru(CuTest *tc) {
|
||||
|
@ -382,7 +382,7 @@ static void test_prepare_travelthru(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_addresses(CuTest *tc) {
|
||||
|
@ -408,7 +408,7 @@ static void test_get_addresses(CuTest *tc) {
|
|||
CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertIntEquals(tc, 3, selist_length(ctx.addresses));
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_addresses_fstealth(CuTest *tc) {
|
||||
|
@ -436,7 +436,7 @@ static void test_get_addresses_fstealth(CuTest *tc) {
|
|||
CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertIntEquals(tc, 2, selist_length(ctx.addresses));
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_addresses_travelthru(CuTest *tc) {
|
||||
|
@ -467,7 +467,7 @@ static void test_get_addresses_travelthru(CuTest *tc) {
|
|||
CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertIntEquals(tc, 2, selist_length(ctx.addresses));
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_prepare_lighthouse_capacity(CuTest *tc) {
|
||||
|
@ -524,7 +524,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_prepare_lighthouse(CuTest *tc) {
|
||||
|
@ -558,7 +558,7 @@ static void test_prepare_lighthouse(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -603,7 +603,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
|
|||
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_prepare_report(CuTest *tc) {
|
||||
|
@ -636,7 +636,7 @@ static void test_prepare_report(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, r, ctx.last);
|
||||
CuAssertIntEquals(tc, seen_none, r->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_seen_neighbours(CuTest *tc) {
|
||||
|
@ -656,7 +656,7 @@ static void test_seen_neighbours(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_seen_travelthru(CuTest *tc) {
|
||||
|
@ -684,7 +684,7 @@ static void test_seen_travelthru(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_travel, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_region_distance_max(CuTest *tc) {
|
||||
|
@ -704,7 +704,7 @@ static void test_region_distance_max(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 7, get_regions_distance_arr(r, 1, result, 64));
|
||||
CuAssertIntEquals(tc, 19, get_regions_distance_arr(r, 2, result, 64));
|
||||
CuAssertIntEquals(tc, 37, get_regions_distance_arr(r, 3, result, 64));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_region_distance(CuTest *tc) {
|
||||
|
@ -720,7 +720,7 @@ static void test_region_distance(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, get_regions_distance_arr(r, 0, result, 8));
|
||||
CuAssertIntEquals(tc, 3, get_regions_distance_arr(r, 1, result, 8));
|
||||
CuAssertIntEquals(tc, 3, get_regions_distance_arr(r, 2, result, 8));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_region_distance_ql(CuTest *tc) {
|
||||
|
@ -740,7 +740,7 @@ static void test_region_distance_ql(CuTest *tc) {
|
|||
ql = get_regions_distance(r, 2);
|
||||
CuAssertIntEquals(tc, 3, selist_length(ql));
|
||||
selist_free(ql);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_report_far_vision(CuTest *tc) {
|
||||
|
@ -761,7 +761,7 @@ static void test_report_far_vision(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_spell, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_stealth_modifier(CuTest *tc) {
|
||||
|
@ -779,7 +779,7 @@ static void test_stealth_modifier(CuTest *tc) {
|
|||
set_observer(r, f, 10, 1);
|
||||
CuAssertIntEquals(tc, 10, stealth_modifier(r, f, seen_spell));
|
||||
CuAssertIntEquals(tc, -1, stealth_modifier(r, NULL, seen_spell));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_insect_warnings(CuTest *tc) {
|
||||
|
@ -798,7 +798,7 @@ static void test_insect_warnings(CuTest *tc) {
|
|||
gd.season = 0;
|
||||
report_warnings(f, &gd);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "nr_insectwinter"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_newbie_warning(CuTest *tc) {
|
||||
|
@ -818,7 +818,7 @@ static void test_newbie_warning(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "newbieimmunity"));
|
||||
test_clear_messages(f);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cansee_spell(CuTest *tc) {
|
||||
|
@ -839,7 +839,7 @@ static void test_cansee_spell(CuTest *tc) {
|
|||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_battle));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_reports_suite(void)
|
||||
|
|
|
@ -8,31 +8,34 @@
|
|||
static void test_init_skills(CuTest *tc) {
|
||||
struct locale *lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = get_or_create_locale("de");
|
||||
|
||||
init_skill(lang, SK_ALCHEMY, "Alchemie");
|
||||
CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_init_skill(CuTest *tc) {
|
||||
struct locale *lang;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
lang = get_or_create_locale("de");
|
||||
|
||||
init_skill(lang, SK_ALCHEMY, "Alchemie");
|
||||
CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));
|
||||
CuAssertIntEquals(tc, NOSKILL, get_skill("east", lang));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_get_skill(CuTest *tc) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
CuAssertIntEquals(tc, SK_ALCHEMY, findskill("alchemy"));
|
||||
CuAssertIntEquals(tc, SK_MAGIC, findskill("magic"));
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, findskill("crossbow"));
|
||||
CuAssertIntEquals(tc, NOSKILL, findskill(""));
|
||||
CuAssertIntEquals(tc, NOSKILL, findskill("potato"));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_skill_suite(void)
|
||||
|
|
|
@ -54,7 +54,7 @@ static void test_good_dreams(CuTest *tc) {
|
|||
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));
|
||||
free_castorder(&co);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_dreams(CuTest *tc) {
|
||||
|
@ -63,9 +63,8 @@ static void test_dreams(CuTest *tc) {
|
|||
unit *u1, *u2;
|
||||
castorder co;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
@ -80,7 +79,7 @@ static void test_dreams(CuTest *tc) {
|
|||
CuAssertIntEquals_Msg(tc, "bad dreams in same region as good dreams", -1, get_modifier(u2, SK_MELEE, 11, r, false));
|
||||
|
||||
free_castorder(&co);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_bad_dreams(CuTest *tc) {
|
||||
|
@ -112,7 +111,7 @@ static void test_bad_dreams(CuTest *tc) {
|
|||
CuAssertIntEquals_Msg(tc, "bad dreams give -1 to non-allies", -1, get_modifier(u2, SK_MELEE, 11, r, false));
|
||||
|
||||
free_castorder(&co);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_view_reality(CuTest *tc) {
|
||||
|
@ -146,7 +145,7 @@ static void test_view_reality(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(ra->individual_messages->msgs, "viewreality_effect"));
|
||||
free_castorder(&co);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_watch_region(CuTest *tc) {
|
||||
|
@ -162,7 +161,7 @@ static void test_watch_region(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 10, get_observer(r, f));
|
||||
CuAssertIntEquals(tc, RF_OBSERVER, fval(r, RF_OBSERVER));
|
||||
CuAssertPtrNotNull(tc, r->attribs);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_spells_suite(void)
|
||||
|
|
|
@ -26,7 +26,7 @@ static void test_flyingship(CuTest * tc)
|
|||
ship_type *shipType1, *shipType2;
|
||||
ship *sh1, *sh2;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
par.param = &par_data_ptr;
|
||||
par_data.typ = SPP_SHIP;
|
||||
|
@ -61,7 +61,7 @@ static void test_flyingship(CuTest * tc)
|
|||
CuAssertTrue(tc, !flying_ship(sh2));
|
||||
co.par = 0;
|
||||
free_castorder(&co);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_flyingship_suite(void)
|
||||
|
|
|
@ -44,7 +44,7 @@ static void test_magicresistance_unit(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "curseinfo::magicresistance_unit", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_magicresistance_building(CuTest *tc) {
|
||||
|
@ -69,7 +69,7 @@ static void test_magicresistance_building(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, msg);
|
||||
CuAssertStrEquals(tc, "curseinfo::magicresistance_building", test_get_messagetype(msg));
|
||||
msg_release(msg);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_magicresistance_suite(void)
|
||||
|
|
|
@ -48,7 +48,7 @@ static void test_simple_spy_message(CuTest *tc) {
|
|||
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_all_spy_message(CuTest *tc) {
|
||||
|
@ -75,7 +75,7 @@ static void test_all_spy_message(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_faction"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.spy->faction->msgs, "spyreport_items"));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_sabotage_self(CuTest *tc) {
|
||||
|
@ -95,7 +95,7 @@ static void test_sabotage_self(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, sabotage_cmd(u, ord));
|
||||
CuAssertPtrEquals(tc, 0, r->ships);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "destroy_ship_3", test_get_messagetype(msg));
|
||||
CuAssertPtrNotNull(tc, r->ships);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_setstealth_cmd(CuTest *tc) {
|
||||
|
@ -146,7 +146,7 @@ static void test_setstealth_cmd(CuTest *tc) {
|
|||
LOC(lang, parameters[P_FACTION]));
|
||||
setstealth_cmd(u, u->thisorder);
|
||||
CuAssertIntEquals(tc, UFL_SIEGE | UFL_ANON_FACTION, u->flags);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_setstealth_demon(CuTest *tc) {
|
||||
|
@ -163,7 +163,7 @@ static void test_setstealth_demon(CuTest *tc) {
|
|||
u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
|
||||
setstealth_cmd(u, u->thisorder);
|
||||
CuAssertPtrEquals(tc, (void *)rc, (void *)u->irace);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_setstealth_demon_bad(CuTest *tc) {
|
||||
|
@ -180,7 +180,7 @@ static void test_setstealth_demon_bad(CuTest *tc) {
|
|||
u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
|
||||
setstealth_cmd(u, u->thisorder);
|
||||
CuAssertPtrEquals(tc, NULL, (void *)u->irace);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_sabotage_other_success(CuTest *tc) {
|
||||
|
@ -205,7 +205,7 @@ static void test_sabotage_other_success(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, sabotage_cmd(u2, ord));
|
||||
CuAssertPtrEquals(tc, 0, r->ships);
|
||||
free_order(ord);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_spy_suite(void)
|
||||
|
|
|
@ -102,7 +102,7 @@ static void test_study_no_teacher(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, sv->level);
|
||||
CuAssertIntEquals(tc, 2, sv->weeks);
|
||||
CuAssertPtrEquals(tc, 0, test_get_last_message(fix.u->faction->msgs));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_with_teacher(CuTest *tc) {
|
||||
|
@ -117,7 +117,7 @@ static void test_study_with_teacher(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, sv = unit_skill(fix.u, SK_CROSSBOW));
|
||||
CuAssertIntEquals(tc, 1, sv->level);
|
||||
CuAssertIntEquals(tc, 1, sv->weeks);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_with_bad_teacher(CuTest *tc) {
|
||||
|
@ -131,7 +131,7 @@ static void test_study_with_bad_teacher(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, sv = unit_skill(fix.u, SK_CROSSBOW));
|
||||
CuAssertIntEquals(tc, 1, sv->level);
|
||||
CuAssertIntEquals(tc, 2, sv->weeks);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_bug_2194(CuTest *tc) {
|
||||
|
@ -177,7 +177,7 @@ static void test_study_bug_2194(CuTest *tc) {
|
|||
teach_cmd(u, u->thisorder);
|
||||
learn_reset();
|
||||
CuAssertIntEquals(tc, 0, log_size);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static CuTest *g_tc;
|
||||
|
@ -202,7 +202,7 @@ static void test_produceexp(CuTest *tc) {
|
|||
config_set("study.produceexp", "20");
|
||||
produceexp_ex(u, SK_ALCHEMY, 1, cb_learn_one);
|
||||
produceexp_ex(u, SK_ALCHEMY, 2, cb_learn_two);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_academy_building(CuTest *tc) {
|
||||
|
@ -248,7 +248,7 @@ static void test_academy_building(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, u1->number, log_learners[0].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -311,7 +311,7 @@ static void test_academy_bonus(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u3, log_learners[3].u);
|
||||
CuAssertIntEquals(tc, 160, log_learners[3].days);
|
||||
learn_reset();
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_learn_skill_single(CuTest *tc) {
|
||||
|
@ -330,7 +330,7 @@ void test_learn_skill_single(CuTest *tc) {
|
|||
learn_skill(u, SK_ALCHEMY, STUDYDAYS * 2);
|
||||
CuAssertIntEquals(tc, 2, sv->level);
|
||||
CuAssertIntEquals(tc, 2, sv->weeks);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_learn_skill_multi(CuTest *tc) {
|
||||
|
@ -350,7 +350,7 @@ void test_learn_skill_multi(CuTest *tc) {
|
|||
learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number * 2);
|
||||
CuAssertIntEquals(tc, 2, sv->level);
|
||||
CuAssertIntEquals(tc, 2, sv->weeks);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_demon_skillchanges(CuTest *tc) {
|
||||
|
@ -364,7 +364,7 @@ static void test_demon_skillchanges(CuTest *tc) {
|
|||
set_level(u, SK_CROSSBOW, 1);
|
||||
demon_skillchange(u);
|
||||
/* TODO: sensing here */
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_cmd(CuTest *tc) {
|
||||
|
@ -379,7 +379,7 @@ static void test_study_cmd(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS, log_learners[0].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_magic(CuTest *tc) {
|
||||
|
@ -421,7 +421,7 @@ static void test_study_magic(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error65"));
|
||||
*/
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_study_cost(CuTest *tc) {
|
||||
|
@ -442,7 +442,7 @@ static void test_study_cost(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, SK_ALCHEMY, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * u->number, log_learners[0].days);
|
||||
CuAssertIntEquals(tc, 0, i_get(u->items, itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_magic(CuTest *tc) {
|
||||
|
@ -470,7 +470,7 @@ static void test_teach_magic(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, SK_MAGIC, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * 2, log_learners[0].days);
|
||||
CuAssertIntEquals(tc, 0, i_get(u->items, itype));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_cmd(CuTest *tc) {
|
||||
|
@ -490,7 +490,7 @@ static void test_teach_cmd(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * 2 * u->number, log_learners[0].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_two(CuTest *tc) {
|
||||
|
@ -517,7 +517,7 @@ static void test_teach_two(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u2, log_learners[1].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[1].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * 2 * u2->number, log_learners[1].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_two_skills(CuTest *tc) {
|
||||
|
@ -550,7 +550,7 @@ static void test_teach_two_skills(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u2, log_learners[1].u);
|
||||
CuAssertIntEquals(tc, SK_ENTERTAINMENT, log_learners[1].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * 2 * u2->number, log_learners[1].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_one_to_many(CuTest *tc) {
|
||||
|
@ -570,7 +570,7 @@ static void test_teach_one_to_many(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, STUDYDAYS * 10 + STUDYDAYS * u->number, log_learners[0].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_many_to_one(CuTest *tc) {
|
||||
|
@ -595,7 +595,7 @@ static void test_teach_many_to_one(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u, log_learners[0].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[0].sk);
|
||||
CuAssertIntEquals(tc, 2 * STUDYDAYS * u->number, log_learners[0].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_message(CuTest *tc) {
|
||||
|
@ -636,7 +636,7 @@ static void test_teach_message(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "teach_student"));
|
||||
a = a_find(u->attribs, &at_learning);
|
||||
CuAssertPtrEquals(tc, NULL, a);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_teach_many_to_many(CuTest *tc) {
|
||||
|
@ -674,7 +674,7 @@ static void test_teach_many_to_many(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, s2, log_learners[1].u);
|
||||
CuAssertIntEquals(tc, SK_CROSSBOW, log_learners[1].sk);
|
||||
CuAssertIntEquals(tc, 2 * STUDYDAYS * s2->number, log_learners[1].days);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_study_suite(void)
|
||||
|
|
|
@ -20,7 +20,7 @@ static void test_summary(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, remove("datum"));
|
||||
CuAssertIntEquals(tc, 0, remove("turn"));
|
||||
free_summary(sum);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_summary_suite(void)
|
||||
|
|
|
@ -178,7 +178,7 @@ void test_log_stderr(int flags) {
|
|||
static struct log_t *stderrlog;
|
||||
if (flags) {
|
||||
if (stderrlog) {
|
||||
log_error("stderr logging is still active. did you call test_cleanup?");
|
||||
log_error("stderr logging is still active. did you call test_teardown?");
|
||||
log_destroy(stderrlog);
|
||||
}
|
||||
stderrlog = log_to_file(flags, stderr);
|
||||
|
@ -188,7 +188,7 @@ void test_log_stderr(int flags) {
|
|||
log_destroy(stderrlog);
|
||||
}
|
||||
else {
|
||||
log_warning("stderr logging is inactive. did you call test_cleanup twice?");
|
||||
log_warning("stderr logging is inactive. did you call test_teardown twice?");
|
||||
}
|
||||
stderrlog = 0;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ void test_setup_test(CuTest *tc, const char *file, int line) {
|
|||
}
|
||||
}
|
||||
|
||||
void test_cleanup(void)
|
||||
void test_teardown(void)
|
||||
{
|
||||
test_reset();
|
||||
test_log_stderr(0);
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
#define test_setup() test_setup_test(NULL, __FILE__, __LINE__)
|
||||
#define test_setup_ex(tc) test_setup_test(tc, __FILE__, __LINE__)
|
||||
|
||||
void test_cleanup(void);
|
||||
void test_teardown(void);
|
||||
void test_log_stderr(int on);
|
||||
struct log_t * test_log_start(int flags, struct strlist **slist);
|
||||
void test_log_stop(struct log_t *log, struct strlist *slist);
|
||||
|
|
|
@ -32,7 +32,7 @@ static void test_resources(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, 0, rt_find("peasant"));
|
||||
rtype = rt_get_or_create("stone");
|
||||
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_tests_suite(void)
|
||||
|
|
|
@ -28,7 +28,6 @@ static void setup_travelthru(travel_fixture *fix, int nunits) {
|
|||
region *r;
|
||||
faction *f;
|
||||
|
||||
test_cleanup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
while (r->attribs) {
|
||||
a_remove(&r->attribs, r->attribs);
|
||||
|
@ -44,6 +43,8 @@ static void setup_travelthru(travel_fixture *fix, int nunits) {
|
|||
|
||||
static void test_travelthru_count(CuTest *tc) {
|
||||
travel_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_travelthru(&fix, 0);
|
||||
CuAssertIntEquals(tc, 0, count_travelthru(fix.r, fix.f));
|
||||
|
||||
|
@ -53,13 +54,14 @@ static void test_travelthru_count(CuTest *tc) {
|
|||
setup_travelthru(&fix, 2);
|
||||
CuAssertIntEquals(tc, 2, count_travelthru(fix.r, fix.f));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_travelthru_map(CuTest *tc) {
|
||||
int n = 0;
|
||||
travel_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_travelthru(&fix, 0);
|
||||
travelthru_map(fix.r, count_travelers, &n);
|
||||
CuAssertIntEquals(tc, 0, n);
|
||||
|
@ -68,7 +70,7 @@ static void test_travelthru_map(CuTest *tc) {
|
|||
travelthru_map(fix.r, count_travelers, &n);
|
||||
CuAssertIntEquals(tc, 1, n);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_travelthru_suite(void)
|
||||
|
|
|
@ -26,7 +26,7 @@ static void test_shock(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "shock"));
|
||||
t_free(tt);
|
||||
free(tt);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_shock_low(CuTest *tc) {
|
||||
|
@ -45,7 +45,7 @@ static void test_shock_low(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, get_spellpoints(u));
|
||||
t_free(tt);
|
||||
free(tt);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_shock_suite(void)
|
||||
|
|
|
@ -39,7 +39,7 @@ void test_upkeep_default(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, fval(u1, UFL_HUNGER));
|
||||
CuAssertIntEquals(tc, UFL_HUNGER, fval(u2, UFL_HUNGER));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_upkeep_hunger_damage(CuTest * tc)
|
||||
|
@ -65,7 +65,7 @@ void test_upkeep_hunger_damage(CuTest * tc)
|
|||
/* since u1 and u2 are not allied, u1 should not help u2 with upkeep */
|
||||
CuAssertTrue(tc, u1->hp < 100);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_upkeep_from_pool(CuTest * tc)
|
||||
|
@ -97,7 +97,7 @@ void test_upkeep_from_pool(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, fval(u1, UFL_HUNGER));
|
||||
CuAssertIntEquals(tc, UFL_HUNGER, fval(u2, UFL_HUNGER));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ void test_upkeep_from_friend(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, fval(u1, UFL_HUNGER));
|
||||
CuAssertIntEquals(tc, UFL_HUNGER, fval(u2, UFL_HUNGER));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
void test_upkeep_free(CuTest * tc)
|
||||
|
@ -156,7 +156,7 @@ void test_upkeep_free(CuTest * tc)
|
|||
CuAssertIntEquals(tc, 0, i_get(u->items, i_silver));
|
||||
CuAssertIntEquals(tc, 0, fval(u, UFL_HUNGER));
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_upkeep_suite(void)
|
||||
|
|
|
@ -130,7 +130,7 @@ static void test_attrib_rwstring(CuTest *tc) {
|
|||
a_finalizestring(&a);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_attrib_rwint(CuTest *tc) {
|
||||
|
@ -149,7 +149,7 @@ static void test_attrib_rwint(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 42, a.data.i);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_attrib_rwchars(CuTest *tc) {
|
||||
|
@ -170,7 +170,7 @@ static void test_attrib_rwchars(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 42, a.data.ca[3]);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_attrib_rwshorts(CuTest *tc) {
|
||||
|
@ -191,7 +191,7 @@ static void test_attrib_rwshorts(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 42, a.data.sa[1]);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_attrib_suite(void)
|
||||
|
|
|
@ -13,7 +13,7 @@ static void test_language(CuTest *tc)
|
|||
default_locale = test_create_locale();
|
||||
str = directions[1];
|
||||
CuAssertStrEquals(tc, str, locale_getstring(default_locale, str));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_make_locales(CuTest *tc)
|
||||
|
@ -23,7 +23,7 @@ static void test_make_locales(CuTest *tc)
|
|||
CuAssertPtrNotNull(tc, get_locale("aa"));
|
||||
CuAssertPtrNotNull(tc, get_locale("bb"));
|
||||
CuAssertPtrNotNull(tc, get_locale("cc"));
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_language_suite(void)
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_mt_new(CuTest *tc)
|
|||
CuAssertPtrNotNull(tc, mt->types);
|
||||
CuAssertStrEquals(tc, "string", mt->types[0]->name);
|
||||
CuAssertStrEquals(tc, "int", mt->types[1]->name);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_message_suite(void)
|
||||
|
|
|
@ -31,7 +31,7 @@ static void test_volcano_update(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, r, m->parameters[0].v);
|
||||
CuAssertPtrEquals(tc, (void *)t_volcano, (void *)r->terrain);
|
||||
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_volcano_outbreak(CuTest *tc) {
|
||||
|
@ -78,7 +78,7 @@ static void test_volcano_outbreak(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, u2, m->parameters[0].v);
|
||||
CuAssertPtrEquals(tc, r, m->parameters[1].v);
|
||||
CuAssertIntEquals(tc, 1, m->parameters[2].i);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_volcano_suite(void)
|
||||
|
|
|
@ -35,7 +35,7 @@ static void test_move_to_vortex(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, E_MOVE_NOREGION, movewhere(u, "barf", r1, &r));
|
||||
CuAssertIntEquals(tc, E_MOVE_OK, movewhere(u, "wirbel", r1, &r));
|
||||
CuAssertPtrEquals(tc, r2, r);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_vortex_suite(void)
|
||||
|
|
|
@ -36,7 +36,7 @@ static void test_make_wormholes(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, (void *)r2->buildings->type, (void *)btype);
|
||||
CuAssertPtrEquals(tc, (void *)r1->buildings->attribs->type, (void *)r2->buildings->attribs->type);
|
||||
CuAssertStrEquals(tc, r1->buildings->attribs->type->name, "wormhole");
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_sort_wormhole_regions(CuTest *tc) {
|
||||
|
@ -56,7 +56,7 @@ static void test_sort_wormhole_regions(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, r2, match[0]);
|
||||
CuAssertPtrEquals(tc, r1, match[1]);
|
||||
selist_free(rlist);
|
||||
test_cleanup();
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_wormhole_suite(void)
|
||||
|
|
Loading…
Add table
Reference in a new issue