forked from github/server
fix tests
This commit is contained in:
parent
b57db72396
commit
ee2709e021
2 changed files with 27 additions and 14 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
static void market_curse(CuTest * tc)
|
||||
static void test_market_curse(CuTest * tc)
|
||||
{
|
||||
region *r;
|
||||
building *b;
|
||||
|
@ -26,16 +26,21 @@ static void market_curse(CuTest * tc)
|
|||
faction *f;
|
||||
int x, y;
|
||||
const char *names[4] = { "herb", "herbs", "balm", "balms" };
|
||||
terrain_type *terrain;
|
||||
resource_type *hres = new_resourcetype(names, 0, RTF_ITEM | RTF_POOLED);
|
||||
item_type *htype = new_itemtype(hres, ITF_HERB, 0, 0);
|
||||
resource_type *lres = new_resourcetype(names + 2, 0, RTF_ITEM | RTF_POOLED);
|
||||
item_type *ltype = new_itemtype(lres, ITF_NONE, 0, 0);
|
||||
luxury_type *lux = new_luxurytype(ltype, 0);
|
||||
const terrain_type *terrain;
|
||||
resource_type *hres, *lres;
|
||||
item_type *htype, *ltype;
|
||||
luxury_type *lux;
|
||||
building_type *btype;
|
||||
race *rc = rc_add(rc_new("human"));
|
||||
|
||||
free_gamedata();
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
hres = new_resourcetype(names, 0, RTF_ITEM | RTF_POOLED);
|
||||
htype = new_itemtype(hres, ITF_HERB, 0, 0);
|
||||
lres = new_resourcetype(names + 2, 0, RTF_ITEM | RTF_POOLED);
|
||||
ltype = new_itemtype(lres, ITF_NONE, 0, 0);
|
||||
lux = new_luxurytype(ltype, 0);
|
||||
|
||||
set_param(&global.parameters, "rules.region_owners", "1");
|
||||
|
||||
|
@ -43,12 +48,16 @@ static void market_curse(CuTest * tc)
|
|||
btype->_name = "market";
|
||||
bt_register(btype);
|
||||
|
||||
terrain = test_create_terrain("plain", LAND_REGION | WALK_INTO);
|
||||
terrain = get_terrain("plain");
|
||||
|
||||
for (x = 0; x != 3; ++x) {
|
||||
for (y = 0; y != 3; ++y) {
|
||||
r = new_region(x, y, NULL, 0);
|
||||
terraform_region(r, terrain);
|
||||
r = findregion(x, y);
|
||||
if (!r) {
|
||||
r = test_create_region(x, y, terrain);
|
||||
} else {
|
||||
terraform_region(r, terrain);
|
||||
}
|
||||
rsetpeasants(r, 5000);
|
||||
r_setdemand(r, lux, 0);
|
||||
rsetherbtype(r, htype);
|
||||
|
@ -59,8 +68,8 @@ static void market_curse(CuTest * tc)
|
|||
b->flags |= BLD_WORKING;
|
||||
b->size = b->type->maxsize;
|
||||
|
||||
f = addfaction("nobody@eressea.de", NULL, rc, default_locale, 0);
|
||||
u = create_unit(r, f, 1, f->race, 0, 0, 0);
|
||||
f = test_create_faction(0);
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
do_markets();
|
||||
|
@ -72,6 +81,6 @@ static void market_curse(CuTest * tc)
|
|||
CuSuite *get_market_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, market_curse);
|
||||
SUITE_ADD_TEST(suite, test_market_curse);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -1201,6 +1201,10 @@ void test_clear_resources(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
memset((void *)olditemtype, 0, sizeof(olditemtype));
|
||||
memset((void *)oldresourcetype, 0, sizeof(oldresourcetype));
|
||||
memset((void *)oldpotiontype, 0, sizeof(oldpotiontype));
|
||||
|
||||
for (i=0;i!=IMAXHASH;++i) {
|
||||
item_type * itype = itemtypes[i];
|
||||
if (itype) {
|
||||
|
|
Loading…
Reference in a new issue