stop using test_create_world, use test_setup.

This commit is contained in:
Enno Rehling 2017-03-11 14:22:21 +01:00
parent 41c6793964
commit cdf13c9fec
5 changed files with 26 additions and 40 deletions

View File

@ -128,12 +128,9 @@ static struct unit *create_recruiter(void) {
unit *u; unit *u;
const resource_type* rtype; const resource_type* rtype;
test_cleanup(); r=test_create_region(0, 0, NULL);
test_create_world();
r=findregion(0, 0);
rsetpeasants(r, 999); rsetpeasants(r, 999);
f = test_create_faction(rc_find("human")); f = test_create_faction(NULL);
u = test_create_unit(f, r); u = test_create_unit(f, r);
rtype = get_resourcetype(R_SILVER); rtype = get_resourcetype(R_SILVER);
change_resource(u, rtype, 1000); change_resource(u, rtype, 1000);
@ -143,9 +140,10 @@ static struct unit *create_recruiter(void) {
static void test_heroes_dont_recruit(CuTest * tc) { static void test_heroes_dont_recruit(CuTest * tc) {
unit *u; unit *u;
test_cleanup(); test_setup();
init_resources();
u = create_recruiter(); u = create_recruiter();
fset(u, UFL_HERO); fset(u, UFL_HERO);
unit_addorder(u, create_order(K_RECRUIT, default_locale, "1")); 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) { static void test_normals_recruit(CuTest * tc) {
unit *u; unit *u;
test_cleanup(); test_setup();
init_resources();
u = create_recruiter(); u = create_recruiter();
unit_addorder(u, create_order(K_RECRUIT, default_locale, "1")); unit_addorder(u, create_order(K_RECRUIT, default_locale, "1"));
@ -193,11 +191,11 @@ static void test_tax_cmd(CuTest *tc) {
request *taxorders = 0; request *taxorders = 0;
test_cleanup(); test_setup();
init_resources();
config_set("taxing.perlevel", "20"); config_set("taxing.perlevel", "20");
test_create_world();
f = test_create_faction(NULL); f = test_create_faction(NULL);
r = findregion(0, 0); r = test_create_region(0, 0, NULL);
assert(r && f); assert(r && f);
u = test_create_unit(f, r); u = test_create_unit(f, r);
@ -210,7 +208,7 @@ static void test_tax_cmd(CuTest *tc) {
silver = get_resourcetype(R_SILVER)->itype; 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); new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 1);
i_change(&u->items, sword, 1); i_change(&u->items, sword, 1);
set_level(u, SK_MELEE, 1); set_level(u, SK_MELEE, 1);

View File

@ -324,8 +324,7 @@ static void test_give_herbs(CuTest * tc) {
struct order *ord; struct order *ord;
test_setup_ex(tc); test_setup_ex(tc);
test_create_world(); env.f2 = env.f1 = test_create_faction(NULL);
env.f2 = env.f1 = test_create_faction(0);
setup_give(&env); setup_give(&env);
i_change(&env.src->items, env.itype, 10); i_change(&env.src->items, env.itype, 10);

View File

@ -153,8 +153,7 @@ static void test_set_origin(CuTest *tc) {
int x = 0, y = 0; int x = 0, y = 0;
plane *pl; plane *pl;
test_cleanup(); test_setup();
test_create_world();
pl = create_new_plane(0, "", 0, 19, 0, 19, 0); pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
f = test_create_faction(0); f = test_create_faction(0);
CuAssertPtrEquals(tc, 0, f->ursprung); CuAssertPtrEquals(tc, 0, f->ursprung);
@ -179,8 +178,7 @@ static void test_set_origin_bug(CuTest *tc) {
plane *pl; plane *pl;
int x = 17, y = 10; int x = 17, y = 10;
test_cleanup(); test_setup();
test_create_world();
pl = create_new_plane(0, "", 0, 19, 0, 19, 0); pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
f = test_create_faction(0); f = test_create_faction(0);
faction_setorigin(f, 0, -10, 3); faction_setorigin(f, 0, -10, 3);

View File

@ -45,18 +45,11 @@ static void test_reorder_units(CuTest * tc)
ship * s; ship * s;
unit *u0, *u1, *u2, *u3, *u4; unit *u0, *u1, *u2, *u3, *u4;
struct faction * f; struct faction * f;
const building_type *btype;
const ship_type *stype;
test_cleanup(); test_setup();
test_create_world(); r = test_create_region(0, 0, NULL);
b = test_create_building(r, NULL);
btype = bt_find("castle"); s = test_create_ship(r, NULL);
stype = st_find("boat");
r = findregion(-1, 0);
b = test_create_building(r, btype);
s = test_create_ship(r, stype);
f = test_create_faction(0); f = test_create_faction(0);
u0 = test_create_unit(f, r); u0 = test_create_unit(f, r);

View File

@ -28,13 +28,12 @@ static void test_magicresistance_unit(CuTest *tc) {
message *msg; message *msg;
curse *c; curse *c;
test_cleanup(); test_setup();
test_create_world(); r = test_create_plain(0, 0);
r=findregion(0, 0); f1 = test_create_faction(NULL);
f1 = test_create_faction(test_create_race("human"));
u1 = test_create_unit(f1, r); 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); u2 = test_create_unit(f2, r);
c = create_curse(u1, &u2->attribs, ct_find("magicresistance"), 10, 20, 30, u2->number); 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; message *msg;
curse *c; curse *c;
test_cleanup(); test_setup();
test_create_world(); r = test_create_plain(0, 0);
r = findregion(0, 0); f1 = test_create_faction(NULL);
f1 = test_create_faction(test_create_race("human"));
u1 = test_create_unit(f1, r); 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); c = create_curse(u1, &b1->attribs, ct_find("magicresistance"), 10, 20, 30, 0);
CuAssertPtrNotNull(tc, b1->attribs); CuAssertPtrNotNull(tc, b1->attribs);