forked from github/server
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
18179a550d
|
@ -128,12 +128,9 @@ static struct unit *create_recruiter(void) {
|
|||
unit *u;
|
||||
const resource_type* rtype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
r=findregion(0, 0);
|
||||
r=test_create_region(0, 0, NULL);
|
||||
rsetpeasants(r, 999);
|
||||
f = test_create_faction(rc_find("human"));
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(f, r);
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
change_resource(u, rtype, 1000);
|
||||
|
@ -143,9 +140,10 @@ static struct unit *create_recruiter(void) {
|
|||
static void test_heroes_dont_recruit(CuTest * tc) {
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
u = create_recruiter();
|
||||
|
||||
fset(u, UFL_HERO);
|
||||
unit_addorder(u, create_order(K_RECRUIT, default_locale, "1"));
|
||||
|
||||
|
@ -160,8 +158,8 @@ static void test_heroes_dont_recruit(CuTest * tc) {
|
|||
static void test_normals_recruit(CuTest * tc) {
|
||||
unit *u;
|
||||
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
u = create_recruiter();
|
||||
unit_addorder(u, create_order(K_RECRUIT, default_locale, "1"));
|
||||
|
||||
|
@ -193,11 +191,11 @@ static void test_tax_cmd(CuTest *tc) {
|
|||
request *taxorders = 0;
|
||||
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
init_resources();
|
||||
config_set("taxing.perlevel", "20");
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
||||
|
@ -210,7 +208,7 @@ static void test_tax_cmd(CuTest *tc) {
|
|||
|
||||
silver = get_resourcetype(R_SILVER)->itype;
|
||||
|
||||
sword = it_get_or_create(rt_get_or_create("sword"));
|
||||
sword = test_create_itemtype("sword");
|
||||
new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 1);
|
||||
i_change(&u->items, sword, 1);
|
||||
set_level(u, SK_MELEE, 1);
|
||||
|
|
|
@ -324,8 +324,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
struct order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
test_create_world();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
setup_give(&env);
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ typedef struct alliance_fixture {
|
|||
} alliance_fixture;
|
||||
|
||||
static void setup_alliance(alliance_fixture *fix) {
|
||||
test_create_world();
|
||||
test_setup();
|
||||
fix->rc = test_create_race("human");
|
||||
fix->f1 = test_create_faction(fix->rc);
|
||||
fix->f2 = test_create_faction(fix->rc);
|
||||
|
@ -49,7 +49,6 @@ static void test_alliance_join(CuTest *tc) {
|
|||
alliance_fixture fix;
|
||||
alliance * al;
|
||||
|
||||
test_setup();
|
||||
setup_alliance(&fix);
|
||||
CuAssertPtrEquals(tc, 0, fix.f1->alliance);
|
||||
CuAssertPtrEquals(tc, 0, fix.f2->alliance);
|
||||
|
|
|
@ -40,18 +40,13 @@ static void test_building_set_owner(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u1, *u2;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
btype = bt_find("castle");
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
u_set_building(u1, bld);
|
||||
CuAssertPtrEquals(tc, u1, building_owner(bld));
|
||||
|
@ -70,22 +65,13 @@ static void test_buildingowner_goes_to_next_when_empty(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -105,22 +91,13 @@ static void test_buildingowner_goes_to_other_when_empty(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -141,23 +118,14 @@ static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
@ -181,22 +149,12 @@ static void test_buildingowner_goes_to_next_after_leave(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -216,22 +174,13 @@ static void test_buildingowner_goes_to_other_after_leave(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -251,23 +200,14 @@ static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
@ -293,22 +233,13 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u;
|
||||
struct faction *f;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -328,22 +259,13 @@ void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
struct building *bld;
|
||||
struct unit *u1, *u2, *u3;
|
||||
struct faction *f1;
|
||||
const struct building_type *btype;
|
||||
const struct race *human;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
f1 = test_create_faction(NULL);
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
btype = bt_find("castle");
|
||||
CuAssertPtrNotNull(tc, btype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
r = findregion(0, 0);
|
||||
|
||||
bld = test_create_building(r, btype);
|
||||
bld = test_create_building(r, NULL);
|
||||
CuAssertPtrNotNull(tc, bld);
|
||||
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
@ -394,16 +316,15 @@ static void test_buildingtype_exists(CuTest * tc)
|
|||
building *b;
|
||||
building_type *btype, *btype2;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
btype2 = bt_get_or_create("castle");
|
||||
btype2 = test_create_buildingtype("castle");
|
||||
assert(btype2);
|
||||
btype = test_create_buildingtype("Hodor");
|
||||
btype = test_create_buildingtype("lighhouse");
|
||||
btype->maxsize = 10;
|
||||
|
||||
r = findregion(-1, 0);
|
||||
b = new_building(btype, r, default_locale);
|
||||
r = test_create_plain(0, 0);
|
||||
b = test_create_building(r, btype);
|
||||
CuAssertPtrNotNull(tc, b);
|
||||
b->size = 10;
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ static void test_set_origin(CuTest *tc) {
|
|||
int x = 0, y = 0;
|
||||
plane *pl;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(0);
|
||||
CuAssertPtrEquals(tc, 0, f->ursprung);
|
||||
|
@ -179,8 +178,7 @@ static void test_set_origin_bug(CuTest *tc) {
|
|||
plane *pl;
|
||||
int x = 17, y = 10;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(0);
|
||||
faction_setorigin(f, 0, -10, 3);
|
||||
|
|
|
@ -981,6 +981,7 @@ void init_resources(void)
|
|||
rtype->flags |= RTF_ITEM | RTF_POOLED;
|
||||
rtype->uchange = res_changeitem;
|
||||
rtype->itype = it_get_or_create(rtype);
|
||||
rtype->itype->weight = 1;
|
||||
rtype->itype->give = give_money;
|
||||
|
||||
rtype = rt_get_or_create(resourcenames[R_HORSE]);
|
||||
|
|
|
@ -225,12 +225,12 @@ static void test_default_name(CuTest *tc) {
|
|||
struct locale* lang;
|
||||
char buf[32], compare[32];
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
lang = get_or_create_locale("de");
|
||||
test_setup();
|
||||
|
||||
lang = test_create_locale();
|
||||
locale_setstring(lang, "unitdefault", "Zweiheit");
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
|
||||
default_name(u, buf, sizeof(buf));
|
||||
|
||||
|
|
174
src/laws.test.c
174
src/laws.test.c
|
@ -34,16 +34,14 @@ static void test_new_building_can_be_renamed(CuTest * tc)
|
|||
{
|
||||
region *r;
|
||||
building *b;
|
||||
building_type *btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
||||
btype = bt_get_or_create("castle");
|
||||
r = findregion(-1, 0);
|
||||
|
||||
b = new_building(btype, r, default_locale);
|
||||
b = test_create_building(r, NULL);
|
||||
CuAssertTrue(tc, !renamed_building(b));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_rename_building(CuTest * tc)
|
||||
|
@ -54,12 +52,10 @@ static void test_rename_building(CuTest * tc)
|
|||
faction *f;
|
||||
building_type *btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
btype = bt_get_or_create("castle");
|
||||
|
||||
r = findregion(-1, 0);
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, 0);
|
||||
b = new_building(btype, r, default_locale);
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -68,6 +64,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();
|
||||
}
|
||||
|
||||
static void test_rename_building_twice(CuTest * tc)
|
||||
|
@ -78,12 +75,10 @@ static void test_rename_building_twice(CuTest * tc)
|
|||
building *b;
|
||||
building_type *btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
btype = bt_get_or_create("castle");
|
||||
|
||||
r = findregion(-1, 0);
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, 0);
|
||||
b = new_building(btype, r, default_locale);
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -94,6 +89,7 @@ static void test_rename_building_twice(CuTest * tc)
|
|||
|
||||
rename_building(u, NULL, b, "Villa Kunterbunt");
|
||||
CuAssertStrEquals(tc, "Villa Kunterbunt", b->name);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_contact(CuTest * tc)
|
||||
|
@ -104,11 +100,10 @@ static void test_contact(CuTest * tc)
|
|||
building_type *btype;
|
||||
ally *al;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
btype = bt_get_or_create("castle");
|
||||
r = findregion(0, 0);
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, 0);
|
||||
b = new_building(btype, r, default_locale);
|
||||
u1 = test_create_unit(test_create_faction(0), r);
|
||||
u2 = test_create_unit(test_create_faction(0), r);
|
||||
|
@ -125,6 +120,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();
|
||||
}
|
||||
|
||||
static void test_enter_building(CuTest * tc)
|
||||
|
@ -134,13 +130,12 @@ static void test_enter_building(CuTest * tc)
|
|||
building *b;
|
||||
race * rc;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
r = findregion(0, 0);
|
||||
rc = rc_get_or_create("human");
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
r = test_create_region(0, 0, 0);
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
b = test_create_building(r, bt_get_or_create("castle"));
|
||||
b = test_create_building(r, test_create_buildingtype("castle"));
|
||||
|
||||
rc->flags = RCF_WALK;
|
||||
u->building = 0;
|
||||
|
@ -238,6 +233,7 @@ static void test_display_cmd(CuTest *tc) {
|
|||
}
|
||||
|
||||
static void test_rule_force_leave(CuTest *tc) {
|
||||
test_setup();
|
||||
config_set("rules.owners.force_leave", "0");
|
||||
CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL));
|
||||
CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT));
|
||||
|
@ -250,6 +246,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();
|
||||
}
|
||||
|
||||
static void test_force_leave_buildings(CuTest *tc) {
|
||||
|
@ -258,7 +255,8 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
unit *u1, *u2, *u3;
|
||||
building * b;
|
||||
message *msg;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
|
@ -288,7 +286,8 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
unit *u1, *u2;
|
||||
ship *sh;
|
||||
message *msg;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -307,7 +306,8 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) {
|
|||
region *r;
|
||||
unit *u1, *u2;
|
||||
ship *sh;
|
||||
test_cleanup();
|
||||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("ocean", SEA_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -328,7 +328,7 @@ static void test_fishing_feeds_2_people(CuTest * tc)
|
|||
unit *u;
|
||||
ship *sh;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(-1, 0);
|
||||
CuAssertStrEquals(tc, "ocean", r->terrain->_name); /* test_create_world needs coverage */
|
||||
|
@ -353,6 +353,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();
|
||||
}
|
||||
|
||||
static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
||||
|
@ -363,7 +364,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
|||
unit *u;
|
||||
ship *sh;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
|
||||
|
@ -379,6 +380,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();
|
||||
}
|
||||
|
||||
static void test_fishing_gets_reset(CuTest * tc)
|
||||
|
@ -389,7 +391,7 @@ static void test_fishing_gets_reset(CuTest * tc)
|
|||
unit *u;
|
||||
ship *sh;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
r = findregion(-1, 0);
|
||||
|
@ -408,10 +410,12 @@ 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();
|
||||
}
|
||||
|
||||
static void test_unit_limit(CuTest * tc)
|
||||
{
|
||||
test_setup();
|
||||
config_set("rules.limit.faction", "250");
|
||||
CuAssertIntEquals(tc, 250, rule_faction_limit());
|
||||
|
||||
|
@ -420,7 +424,7 @@ static void test_unit_limit(CuTest * tc)
|
|||
|
||||
config_set("rules.limit.alliance", "250");
|
||||
CuAssertIntEquals(tc, 250, rule_alliance_limit());
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
extern int checkunitnumber(const faction * f, int add);
|
||||
|
@ -428,7 +432,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc)
|
|||
{
|
||||
faction *f;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
config_set("rules.limit.faction", "4");
|
||||
|
@ -439,6 +443,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();
|
||||
}
|
||||
|
||||
static void test_reserve_cmd(CuTest *tc) {
|
||||
|
@ -448,7 +453,7 @@ static void test_reserve_cmd(CuTest *tc) {
|
|||
order *ord;
|
||||
const resource_type *rtype;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
|
@ -489,7 +494,7 @@ static void setup_pay_cmd(struct pay_fixture *fix) {
|
|||
f = test_create_faction(NULL);
|
||||
r = findregion(0, 0);
|
||||
assert(r && f);
|
||||
btcastle = bt_get_or_create("castle");
|
||||
btcastle = test_create_buildingtype("castle");
|
||||
btcastle->taxes = level_taxes;
|
||||
b = test_create_building(r, btcastle);
|
||||
assert(b);
|
||||
|
@ -508,7 +513,7 @@ static void test_pay_cmd(CuTest *tc) {
|
|||
faction *f;
|
||||
building *b;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
setup_pay_cmd(&fix);
|
||||
b = fix.u1->building;
|
||||
f = fix.u1->faction;
|
||||
|
@ -530,7 +535,8 @@ static void test_pay_cmd_other_building(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_pay_cmd(&fix);
|
||||
f = fix.u1->faction;
|
||||
b = test_create_building(fix.u1->region, bt_get_or_create("lighthouse"));
|
||||
/* lighthouse is not in the test locale, so we're using castle */
|
||||
b = test_create_building(fix.u1->region, test_create_buildingtype("lighthouse"));
|
||||
config_set("rules.region_owners", "1");
|
||||
config_set("rules.region_owner_pay_building", "lighthouse");
|
||||
update_owners(b->region);
|
||||
|
@ -550,7 +556,7 @@ static void test_pay_cmd_must_be_owner(CuTest *tc) {
|
|||
faction *f;
|
||||
building *b;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
setup_pay_cmd(&fix);
|
||||
b = fix.u1->building;
|
||||
f = fix.u1->faction;
|
||||
|
@ -569,14 +575,13 @@ static void test_new_units(CuTest *tc) {
|
|||
region *r;
|
||||
const struct locale *loc;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
assert(u && !u->next);
|
||||
loc = get_locale("de");
|
||||
loc = test_create_locale();
|
||||
assert(loc);
|
||||
u->orders = create_order(K_MAKETEMP, loc, "hurr");
|
||||
new_units();
|
||||
|
@ -598,11 +603,10 @@ void setup_guard(guard_fixture *fix, bool armed) {
|
|||
faction *f;
|
||||
unit * u;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
fset(u, UFL_GUARD);
|
||||
|
@ -707,18 +711,18 @@ static void test_reserve_self(CuTest *tc) {
|
|||
const resource_type *rtype;
|
||||
const struct locale *loc;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
init_resources();
|
||||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
f = test_create_faction(NULL);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r && f);
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
assert(u1 && u2);
|
||||
loc = get_locale("de");
|
||||
loc = test_create_locale();
|
||||
assert(loc);
|
||||
ord = create_order(K_RESERVE, loc, "200 SILBER");
|
||||
assert(ord);
|
||||
|
@ -741,7 +745,7 @@ static void statistic_test(CuTest *tc, int peasants, int luck, int maxp,
|
|||
}
|
||||
|
||||
static void test_peasant_luck_effect(CuTest *tc) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
config_set("rules.peasants.peasantluck.factor", "10");
|
||||
config_set("rules.peasants.growth.factor", "0.001");
|
||||
|
@ -891,7 +895,7 @@ static void test_long_order_normal(CuTest *tc) {
|
|||
unit *u;
|
||||
order *ord;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
fset(u, UFL_MOVED);
|
||||
fset(u, UFL_LONGACTION);
|
||||
|
@ -909,7 +913,7 @@ static void test_long_order_normal(CuTest *tc) {
|
|||
static void test_long_order_none(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
update_long_order(u);
|
||||
CuAssertPtrEquals(tc, 0, u->thisorder);
|
||||
|
@ -921,7 +925,7 @@ static void test_long_order_none(CuTest *tc) {
|
|||
static void test_long_order_cast(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
|
||||
|
@ -935,7 +939,7 @@ static void test_long_order_cast(CuTest *tc) {
|
|||
static void test_long_order_buy_sell(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
|
@ -950,7 +954,7 @@ static void test_long_order_buy_sell(CuTest *tc) {
|
|||
static void test_long_order_multi_long(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0));
|
||||
|
@ -964,7 +968,7 @@ static void test_long_order_multi_long(CuTest *tc) {
|
|||
static void test_long_order_multi_buy(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
|
@ -978,7 +982,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
|
|||
static void test_long_order_multi_sell(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
|
@ -993,7 +997,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
|
|||
static void test_long_order_buy_cast(CuTest *tc) {
|
||||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
|
||||
|
@ -1006,7 +1010,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
|
|||
|
||||
static void test_long_order_hungry(CuTest *tc) {
|
||||
unit *u;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
config_set("hunger.long", "1");
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
fset(u, UFL_HUNGER);
|
||||
|
@ -1145,7 +1149,7 @@ static void test_ally_cmd(CuTest *tc) {
|
|||
|
||||
static void test_nmr_warnings(CuTest *tc) {
|
||||
faction *f1, *f2;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
config_set("nmr.timeout", "3");
|
||||
f1 = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
|
@ -1166,7 +1170,7 @@ static void test_nmr_warnings(CuTest *tc) {
|
|||
static unit * setup_mail_cmd(void) {
|
||||
faction *f;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
return test_create_unit(f, test_create_region(0, 0, 0));
|
||||
}
|
||||
|
@ -1280,10 +1284,9 @@ static void test_show_without_item(CuTest *tc)
|
|||
unit *u;
|
||||
order *ord;
|
||||
item_type *itype;
|
||||
item *i;
|
||||
struct locale *loc;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
loc = get_or_create_locale("de");
|
||||
locale_setstring(loc, parameters[P_ANY], "ALLE");
|
||||
|
@ -1293,26 +1296,26 @@ static void test_show_without_item(CuTest *tc)
|
|||
f = test_create_faction(test_create_race("human"));
|
||||
u = test_create_unit(f, r);
|
||||
|
||||
itype = it_get_or_create(rt_get_or_create("testitem"));
|
||||
|
||||
ord = create_order(K_RESHOW, f->locale, "testname");
|
||||
|
||||
itype = it_get_or_create(rt_get_or_create("testitem"));
|
||||
i = i_new(itype, 1);
|
||||
|
||||
reshow_cmd(u, ord);
|
||||
CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") != NULL);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error21"));
|
||||
test_clear_messages(f);
|
||||
|
||||
locale_setstring(loc, "testitem", "testname");
|
||||
locale_setstring(loc, "iteminfo::testitem", "testdescription");
|
||||
|
||||
reshow_cmd(u, ord);
|
||||
CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL);
|
||||
CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") != NULL);
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error21"));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error36"));
|
||||
test_clear_messages(f);
|
||||
|
||||
i_add(&(u->items), i);
|
||||
i_add(&(u->items), i_new(itype, 1));
|
||||
reshow_cmd(u, ord);
|
||||
CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL);
|
||||
CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") == NULL);
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error21"));
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error36"));
|
||||
test_clear_messages(f);
|
||||
|
||||
free_order(ord);
|
||||
|
@ -1326,13 +1329,13 @@ static void test_show_elf(CuTest *tc) {
|
|||
struct locale *loc;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
mt_register(mt_new_va("msg_event", "string:string", 0));
|
||||
rc = test_create_race("elf");
|
||||
test_create_itemtype("elvenhorse");
|
||||
|
||||
loc = get_or_create_locale("de");
|
||||
loc = test_create_locale();
|
||||
locale_setstring(loc, "elvenhorse", "Elfenpferd");
|
||||
locale_setstring(loc, "elvenhorse_p", "Elfenpferde");
|
||||
locale_setstring(loc, "race::elf_p", "Elfen");
|
||||
|
@ -1362,7 +1365,7 @@ static void test_show_race(CuTest *tc) {
|
|||
struct locale *loc;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
|
||||
mt_register(mt_new_va("msg_event", "string:string", 0));
|
||||
test_create_race("human");
|
||||
|
@ -1406,9 +1409,8 @@ static void test_immigration(CuTest * tc)
|
|||
double inject[] = { 1 };
|
||||
int (*old_wage)(const region*, const faction*, const race*, int) = global.functions.wage;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
|
||||
rsetpeasants(r, 0);
|
||||
config_set("rules.economy.repopulate_maximum", 0);
|
||||
|
@ -1442,9 +1444,9 @@ static void test_demon_hunger(CuTest * tc)
|
|||
unit *u;
|
||||
message* msg;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_region(0, 0, 0);
|
||||
rc = test_create_race("demon");
|
||||
f = test_create_faction(rc);
|
||||
u = test_create_unit(f, r);
|
||||
|
|
|
@ -87,8 +87,8 @@ void test_pay_spell(CuTest * tc)
|
|||
int level;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
init_resources();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -121,8 +121,8 @@ void test_pay_spell_failure(CuTest * tc)
|
|||
int level;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
init_resources();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -159,8 +159,7 @@ void test_getspell_unit(CuTest * tc)
|
|||
struct locale * lang;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, M_GRAY);
|
||||
|
@ -168,7 +167,7 @@ void test_getspell_unit(CuTest * tc)
|
|||
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
||||
lang = get_locale("de");
|
||||
lang = test_create_locale();
|
||||
sp = create_spell("testspell", 0);
|
||||
locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp");
|
||||
|
||||
|
@ -188,8 +187,7 @@ void test_getspell_faction(CuTest * tc)
|
|||
struct locale * lang;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -198,7 +196,7 @@ void test_getspell_faction(CuTest * tc)
|
|||
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
||||
lang = get_locale("de");
|
||||
lang = test_create_locale();
|
||||
sp = create_spell("testspell", 0);
|
||||
locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp");
|
||||
|
||||
|
@ -220,8 +218,7 @@ void test_getspell_school(CuTest * tc)
|
|||
struct spellbook * book;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -229,7 +226,7 @@ void test_getspell_school(CuTest * tc)
|
|||
enable_skill(SK_MAGIC, true);
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
||||
lang = get_locale("de");
|
||||
lang = test_create_locale();
|
||||
sp = create_spell("testspell", 0);
|
||||
locale_setstring(lang, mkname("spell", sp->sname), "Herp-a-derp");
|
||||
|
||||
|
@ -251,8 +248,7 @@ void test_set_pre_combatspell(CuTest * tc)
|
|||
const int index = 0;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -284,8 +280,7 @@ void test_set_main_combatspell(CuTest * tc)
|
|||
const int index = 1;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -317,8 +312,7 @@ void test_set_post_combatspell(CuTest * tc)
|
|||
const int index = 2;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -349,8 +343,7 @@ void test_hasspell(CuTest * tc)
|
|||
struct region * r;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(0);
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
|
|
|
@ -31,9 +31,7 @@ static void test_market_curse(CuTest * tc)
|
|||
luxury_type *lux;
|
||||
building_type *btype;
|
||||
|
||||
free_gamedata();
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
|
||||
htype = test_create_itemtype("herb");
|
||||
htype->flags |= ITF_HERB;
|
||||
|
@ -78,6 +76,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();
|
||||
}
|
||||
|
||||
static void test_rc_trade(CuTest *tc) {
|
||||
|
|
|
@ -158,16 +158,14 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
|||
}
|
||||
|
||||
static void test_walkingcapacity(CuTest *tc) {
|
||||
region *r;
|
||||
unit *u;
|
||||
int cap;
|
||||
const struct item_type *itype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
test_setup();
|
||||
init_resources();
|
||||
|
||||
r = findregion(0, 0);
|
||||
u = test_create_unit(test_create_faction(0), r);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
cap = u->number * (u->_race->capacity + u->_race->weight);
|
||||
CuAssertIntEquals(tc, cap, walkingcapacity(u));
|
||||
scale_number(u, 2);
|
||||
|
@ -183,7 +181,7 @@ static void test_walkingcapacity(CuTest *tc) {
|
|||
cap += itype->capacity;
|
||||
CuAssertIntEquals(tc, cap, walkingcapacity(u));
|
||||
|
||||
itype = it_find("cart");
|
||||
itype = test_create_itemtype("cart");
|
||||
assert(itype);
|
||||
i_change(&u->items, itype, 1);
|
||||
CuAssertIntEquals(tc, cap, walkingcapacity(u));
|
||||
|
@ -265,15 +263,15 @@ struct drift_fixture {
|
|||
};
|
||||
|
||||
void setup_drift (struct drift_fixture *fix) {
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_locale();
|
||||
config_set("rules.ship.storms", "0");
|
||||
|
||||
test_create_world();
|
||||
test_create_shiptype("drifter");
|
||||
fix->st_boat = st_get_or_create("drifter");
|
||||
fix->st_boat = test_create_shiptype("boat");
|
||||
fix->st_boat->cabins = 20000;
|
||||
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
|
||||
test_create_ocean(0, 0);
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r = test_create_ocean(-1, 0));
|
||||
assert(fix->r && fix->u && fix->f);
|
||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||
|
@ -437,9 +435,11 @@ static void test_follow_ship_msg(CuTest * tc) {
|
|||
void *p;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
f = test_create_faction(0);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_plain(0, 0);
|
||||
test_create_ocean(-1, 1); /* D_NORTHWEST */
|
||||
|
||||
stype = st_find("boat");
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -452,7 +452,7 @@ static void test_follow_ship_msg(CuTest * tc) {
|
|||
assert(ord);
|
||||
unit_addorder(u, ord);
|
||||
|
||||
set_money(u, 999999);
|
||||
set_money(u, 999999); /* overloaded ship */
|
||||
|
||||
a = a_add(&(r->attribs), a_new(&at_shiptrail));
|
||||
td = (traveldir *)a->data.v;
|
||||
|
|
|
@ -116,7 +116,7 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
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")));
|
||||
f->locale = get_or_create_locale("de");
|
||||
f->locale = test_create_locale();
|
||||
u->thisorder = create_order(K_PIRACY, f->locale, "");
|
||||
assert(u && u->thisorder);
|
||||
|
||||
|
|
|
@ -45,18 +45,11 @@ static void test_reorder_units(CuTest * tc)
|
|||
ship * s;
|
||||
unit *u0, *u1, *u2, *u3, *u4;
|
||||
struct faction * f;
|
||||
const building_type *btype;
|
||||
const ship_type *stype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
btype = bt_find("castle");
|
||||
stype = st_find("boat");
|
||||
|
||||
r = findregion(-1, 0);
|
||||
b = test_create_building(r, btype);
|
||||
s = test_create_ship(r, stype);
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = test_create_building(r, NULL);
|
||||
s = test_create_ship(r, NULL);
|
||||
f = test_create_faction(0);
|
||||
|
||||
u0 = test_create_unit(f, r);
|
||||
|
|
|
@ -28,13 +28,12 @@ static void test_magicresistance_unit(CuTest *tc) {
|
|||
message *msg;
|
||||
curse *c;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r=findregion(0, 0);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
f2 = test_create_faction(NULL);
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
c = create_curse(u1, &u2->attribs, ct_find("magicresistance"), 10, 20, 30, u2->number);
|
||||
|
@ -56,13 +55,12 @@ static void test_magicresistance_building(CuTest *tc) {
|
|||
message *msg;
|
||||
curse *c;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
||||
b1 = test_create_building(r, test_create_buildingtype("castle"));
|
||||
b1 = test_create_building(r, NULL);
|
||||
|
||||
c = create_curse(u1, &b1->attribs, ct_find("magicresistance"), 10, 20, 30, 0);
|
||||
CuAssertPtrNotNull(tc, b1->attribs);
|
||||
|
|
|
@ -77,23 +77,12 @@ static void test_all_spy_message(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void setup_sabotage(void) {
|
||||
struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
lang = get_or_create_locale("de");
|
||||
locale_setstring(lang, parameters[P_SHIP], "SCHIFF");
|
||||
locale_setstring(lang, parameters[P_ANY], "ALLE");
|
||||
init_parameters(lang);
|
||||
init_locales();
|
||||
}
|
||||
|
||||
static void test_sabotage_self(CuTest *tc) {
|
||||
unit *u;
|
||||
region *r;
|
||||
order *ord;
|
||||
|
||||
setup_sabotage();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -115,7 +104,7 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
|||
order *ord;
|
||||
message *msg;
|
||||
|
||||
setup_sabotage();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -164,7 +153,7 @@ static void test_sabotage_other_success(CuTest *tc) {
|
|||
region *r;
|
||||
order *ord;
|
||||
|
||||
setup_sabotage();
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
|
|
@ -63,8 +63,6 @@ static void setup_locale(struct locale *lang) {
|
|||
if (!locale_getstring(lang, mkname("skill", skillnames[i])))
|
||||
locale_setstring(lang, mkname("skill", skillnames[i]), skillnames[i]);
|
||||
}
|
||||
locale_setstring(lang, parameters[P_ANY], "ALLE");
|
||||
init_parameters(lang);
|
||||
init_skills(lang);
|
||||
}
|
||||
|
||||
|
@ -76,10 +74,9 @@ static void setup_study(study_fixture *fix, skill_t sk) {
|
|||
assert(fix);
|
||||
test_setup();
|
||||
config_set("study.random_progress", "0");
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
lang = get_or_create_locale(locale_name(f->locale));
|
||||
f->locale = lang = test_create_locale();
|
||||
setup_locale(lang);
|
||||
fix->u = test_create_unit(f, r);
|
||||
assert(fix->u);
|
||||
|
@ -145,7 +142,7 @@ static void test_study_bug_2194(CuTest *tc) {
|
|||
test_setup();
|
||||
random_source_inject_constant(0.0);
|
||||
init_resources();
|
||||
loc = get_or_create_locale("de");
|
||||
loc = test_create_locale();
|
||||
setup_locale(loc);
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
scale_number(u, 2);
|
||||
|
@ -219,7 +216,7 @@ static void test_academy_building(CuTest *tc) {
|
|||
|
||||
random_source_inject_constant(0.0);
|
||||
init_resources();
|
||||
loc = get_or_create_locale("de");
|
||||
loc = test_create_locale();
|
||||
setup_locale(loc);
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
scale_number(u, 2);
|
||||
|
|
46
src/tests.c
46
src/tests.c
|
@ -53,9 +53,7 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain)
|
|||
r = new_region(x, y, findplane(x, y), 0);
|
||||
}
|
||||
if (!terrain) {
|
||||
terrain_type *t = get_or_create_terrain("plain");
|
||||
t->size = 1000;
|
||||
fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION|FLY_INTO|WALK_INTO);
|
||||
terrain_type *t = test_create_terrain("plain", LAND_REGION | CAVALRY_REGION | FOREST_REGION | FLY_INTO | WALK_INTO);
|
||||
terraform_region(r, t);
|
||||
}
|
||||
else {
|
||||
|
@ -69,12 +67,37 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain)
|
|||
return r;
|
||||
}
|
||||
|
||||
region *test_create_ocean(int x, int y)
|
||||
{
|
||||
terrain_type *ter = test_create_terrain("ocean", SEA_REGION | FLY_INTO | SWIM_INTO);
|
||||
return test_create_region(x, y, ter);
|
||||
}
|
||||
|
||||
region *test_create_plain(int x, int y) {
|
||||
return test_create_region(x, y, NULL);
|
||||
}
|
||||
|
||||
struct locale * test_create_locale(void) {
|
||||
struct locale *loc = get_locale("test");
|
||||
if (!loc) {
|
||||
int i;
|
||||
loc = get_or_create_locale("test");
|
||||
locale_setstring(loc, "factiondefault", parameters[P_FACTION]);
|
||||
locale_setstring(loc, "unitdefault", parameters[P_UNIT]);
|
||||
locale_setstring(loc, "money", "Silber");
|
||||
locale_setstring(loc, "money_p", "Silber");
|
||||
locale_setstring(loc, "cart", "Wagen");
|
||||
locale_setstring(loc, "cart_p", "Wagen");
|
||||
locale_setstring(loc, "horse", "Pferd");
|
||||
locale_setstring(loc, "horse_p", "Pferde");
|
||||
locale_setstring(loc, "iron", "Eisen");
|
||||
locale_setstring(loc, "iron_p", "Eisen");
|
||||
locale_setstring(loc, "stone", "Stein");
|
||||
locale_setstring(loc, "stone_p", "Steine");
|
||||
locale_setstring(loc, "plain", "Ebene");
|
||||
locale_setstring(loc, "ocean", "Ozean");
|
||||
locale_setstring(loc, "race::human", "Mensch");
|
||||
locale_setstring(loc, "race::human_p", "Menschen");
|
||||
for (i = 0; i < MAXSKILLS; ++i) {
|
||||
if (!locale_getstring(loc, mkname("skill", skillnames[i])))
|
||||
locale_setstring(loc, mkname("skill", skillnames[i]), skillnames[i]);
|
||||
|
@ -314,7 +337,7 @@ void test_create_castorder(castorder *co, unit *u, int level, float force, int r
|
|||
struct locale * lang;
|
||||
order *ord;
|
||||
|
||||
lang = get_or_create_locale("en");
|
||||
lang = test_create_locale();
|
||||
create_castorder(co, u, NULL, NULL, u->region, level, force, range, ord = create_order(K_CAST, lang, ""), par);
|
||||
free_order(ord);
|
||||
}
|
||||
|
@ -373,7 +396,7 @@ void test_create_world(void)
|
|||
item_type * itype;
|
||||
struct locale * loc;
|
||||
|
||||
loc = get_or_create_locale("de");
|
||||
loc = test_create_locale();
|
||||
|
||||
locale_setstring(loc, parameters[P_SHIP], "SCHIFF");
|
||||
locale_setstring(loc, parameters[P_ANY], "ALLE");
|
||||
|
@ -381,7 +404,18 @@ void test_create_world(void)
|
|||
|
||||
locale_setstring(loc, "status_aggressive", "aggressiv");
|
||||
locale_setstring(loc, keyword(K_RESERVE), "RESERVIEREN");
|
||||
locale_setstring(loc, "money", "SILBER");
|
||||
locale_setstring(loc, "money", "Silber");
|
||||
locale_setstring(loc, "money_p", "Silber");
|
||||
locale_setstring(loc, "cart", "Wagen");
|
||||
locale_setstring(loc, "cart_p", "Wagen");
|
||||
locale_setstring(loc, "horse", "Pferd");
|
||||
locale_setstring(loc, "horse_p", "Pferde");
|
||||
locale_setstring(loc, "iron", "Eisen");
|
||||
locale_setstring(loc, "iron_p", "Eisen");
|
||||
locale_setstring(loc, "stone", "Stein");
|
||||
locale_setstring(loc, "stone_p", "Steine");
|
||||
locale_setstring(loc, "plain", "Ebene");
|
||||
locale_setstring(loc, "ocean", "Ozean");
|
||||
init_resources();
|
||||
get_resourcetype(R_SILVER)->itype->weight = 1;
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@ extern "C" {
|
|||
struct locale * test_create_locale(void);
|
||||
struct terrain_type * test_create_terrain(const char * name, unsigned int flags);
|
||||
struct race *test_create_race(const char *name);
|
||||
struct region *test_create_region(int x, int y,
|
||||
const struct terrain_type *terrain);
|
||||
struct region *test_create_region(int x, int y, const struct terrain_type *terrain);
|
||||
struct region *test_create_ocean(int x, int y);
|
||||
struct region *test_create_plain(int x, int y);
|
||||
struct faction *test_create_faction(const struct race *rc);
|
||||
struct unit *test_create_unit(struct faction *f, struct region *r);
|
||||
void test_create_world(void);
|
||||
|
|
|
@ -34,46 +34,9 @@ static void test_resources(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
||||
}
|
||||
|
||||
static void test_recreate_world(CuTest * tc)
|
||||
{
|
||||
test_setup();
|
||||
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
||||
CuAssertPtrEquals(tc, 0, (void *)rt_find("horse"));
|
||||
|
||||
test_create_world();
|
||||
CuAssertPtrEquals(tc, default_locale, get_locale("de"));
|
||||
CuAssertPtrNotNull(tc, default_locale);
|
||||
CuAssertPtrNotNull(tc, findregion(0, 0));
|
||||
CuAssertPtrNotNull(tc, get_terrain("plain"));
|
||||
CuAssertPtrNotNull(tc, get_terrain("ocean"));
|
||||
CuAssertPtrNotNull(tc, (void *)rt_find("horse"));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE));
|
||||
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
|
||||
CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT));
|
||||
|
||||
test_cleanup();
|
||||
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
||||
CuAssertPtrEquals(tc, 0, (void*)get_terrain("plain"));
|
||||
CuAssertPtrEquals(tc, 0, (void*)get_terrain("ocean"));
|
||||
CuAssertPtrEquals(tc, 0, (void*)rt_find("horse"));
|
||||
CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE));
|
||||
CuAssertPtrEquals(tc, 0, (void *)rt_find("money"));
|
||||
CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_LIFE));
|
||||
CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_SILVER));
|
||||
CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_AURA));
|
||||
CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_PERMAURA));
|
||||
CuAssertPtrEquals(tc, 0, (void *)get_resourcetype(R_PEASANT));
|
||||
CuAssertPtrEquals(tc, 0, findregion(0, 0));
|
||||
}
|
||||
|
||||
CuSuite *get_tests_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_resources);
|
||||
SUITE_ADD_TEST(suite, test_recreate_world);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,10 @@ void test_upkeep_default(CuTest * tc)
|
|||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
init_resources();
|
||||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
assert(f1 && f2);
|
||||
|
@ -51,11 +50,11 @@ void test_upkeep_hunger_damage(CuTest * tc)
|
|||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
u1 = test_create_unit(f1, r);
|
||||
assert(r && u1);
|
||||
|
@ -76,11 +75,11 @@ void test_upkeep_from_pool(CuTest * tc)
|
|||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r);
|
||||
u1 = test_create_unit(test_create_faction(test_create_race("human")), r);
|
||||
assert(u1);
|
||||
|
@ -110,11 +109,11 @@ void test_upkeep_from_friend(CuTest * tc)
|
|||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
assert(f1 && f2);
|
||||
|
@ -144,11 +143,11 @@ void test_upkeep_free(CuTest * tc)
|
|||
const item_type *i_silver;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), r);
|
||||
assert(r && u);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ static void test_move_to_vortex(CuTest *tc) {
|
|||
struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
lang = get_or_create_locale("en");
|
||||
lang = test_create_locale();
|
||||
locale_setstring(lang, "vortex", "wirbel");
|
||||
init_locale(lang);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION);
|
||||
|
|
|
@ -9,5 +9,5 @@ IF exist build-vs%VSVERSION% goto HAVEDIR
|
|||
mkdir build-vs%VSVERSION%
|
||||
:HAVEDIR
|
||||
cd build-vs%VSVERSION%
|
||||
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
||||
"%ProgramFiles%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
||||
PAUSE
|
||||
|
|
Loading…
Reference in New Issue