forked from github/server
eliminate use of test_create_world
This commit is contained in:
parent
1182ccf139
commit
318820fb00
5 changed files with 26 additions and 16 deletions
|
@ -25,8 +25,8 @@ static void test_make_fighter(CuTest * tc)
|
|||
const resource_type *rtype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
test_create_horse();
|
||||
r = test_create_region(0, 0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
au = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -75,8 +75,7 @@ static void test_defenders_get_building_bonus(CuTest * tc)
|
|||
building_type * btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
btype = bt_get_or_create("castle");
|
||||
btype->protection = &add_two;
|
||||
bld = test_create_building(r, btype);
|
||||
|
@ -120,8 +119,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc)
|
|||
building_type * btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
btype = bt_get_or_create("castle");
|
||||
btype->protection = &add_two;
|
||||
bld = test_create_building(r, btype);
|
||||
|
@ -151,8 +149,7 @@ static void test_building_bonus_respects_size(CuTest * tc)
|
|||
faction * f;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
btype = bt_get_or_create("castle");
|
||||
btype->protection = &add_two;
|
||||
bld = test_create_building(r, btype);
|
||||
|
|
|
@ -819,7 +819,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
|||
/* gebäude fertig */
|
||||
new_order = default_order(lang);
|
||||
}
|
||||
else if (want != INT_MAX) {
|
||||
else if (want != INT_MAX && btname) {
|
||||
/* reduzierte restgröße */
|
||||
const char *hasspace = strchr(btname, ' ');
|
||||
if (hasspace) {
|
||||
|
|
|
@ -27,10 +27,14 @@ typedef struct build_fixture {
|
|||
|
||||
static unit * setup_build(build_fixture *bf) {
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
init_resources();
|
||||
|
||||
test_create_itemtype("stone");
|
||||
test_create_buildingtype("castle");
|
||||
bf->rc = test_create_race("human");
|
||||
bf->r = findregion(0, 0);
|
||||
bf->r = test_create_region(0, 0, 0);
|
||||
bf->f = test_create_faction(bf->rc);
|
||||
bf->f->locale = get_or_create_locale("de");
|
||||
assert(bf->rc && bf->f && bf->r);
|
||||
bf->u = test_create_unit(bf->f, bf->r);
|
||||
assert(bf->u);
|
||||
|
@ -134,6 +138,7 @@ static void test_build_limits(CuTest *tc) {
|
|||
|
||||
u = setup_build(&bf);
|
||||
rtype = bf.cons.materials[0].rtype;
|
||||
assert(rtype);
|
||||
i_change(&u->items, rtype->itype, 1);
|
||||
set_level(u, SK_ARMORER, bf.cons.minskill);
|
||||
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 10));
|
||||
|
|
17
src/tests.c
17
src/tests.c
|
@ -45,7 +45,7 @@ struct region *test_create_region(int x, int y, const terrain_type *terrain)
|
|||
if (!terrain) {
|
||||
terrain_type *t = get_or_create_terrain("plain");
|
||||
t->size = 1000;
|
||||
fset(t, LAND_REGION);
|
||||
fset(t, LAND_REGION|CAVALRY_REGION|FOREST_REGION);
|
||||
terraform_region(r, t);
|
||||
} else
|
||||
terraform_region(r, terrain);
|
||||
|
@ -196,6 +196,16 @@ void test_translate_param(const struct locale *lang, param_t param, const char *
|
|||
add_translation(cb, text, param);
|
||||
}
|
||||
|
||||
|
||||
item_type *test_create_horse(void) {
|
||||
item_type * itype;
|
||||
itype = test_create_itemtype("horse");
|
||||
itype->flags |= ITF_BIG | ITF_ANIMAL;
|
||||
itype->weight = 5000;
|
||||
itype->capacity = 7000;
|
||||
return itype;
|
||||
}
|
||||
|
||||
/** creates a small world and some stuff in it.
|
||||
* two terrains: 'plain' and 'ocean'
|
||||
* one race: 'human'
|
||||
|
@ -216,10 +226,7 @@ void test_create_world(void)
|
|||
locale_setstring(loc, "money", "SILBER");
|
||||
init_resources();
|
||||
|
||||
itype = test_create_itemtype("horse");
|
||||
itype->flags |= ITF_BIG | ITF_ANIMAL;
|
||||
itype->weight = 5000;
|
||||
itype->capacity = 7000;
|
||||
test_create_horse();
|
||||
|
||||
itype = test_create_itemtype("cart");
|
||||
itype->flags |= ITF_BIG | ITF_VEHICLE;
|
||||
|
|
|
@ -34,6 +34,7 @@ extern "C" {
|
|||
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);
|
||||
struct item_type * test_create_horse(void);
|
||||
struct building * test_create_building(struct region * r, const struct building_type * btype);
|
||||
struct ship * test_create_ship(struct region * r, const struct ship_type * stype);
|
||||
struct item_type * test_create_itemtype(const char * name);
|
||||
|
|
Loading…
Reference in a new issue