use the correct swamp terrain, still failing. newterrain is a plague.

This commit is contained in:
Enno Rehling 2017-11-05 16:43:01 +01:00
parent 3fdde8a4aa
commit 2b81334ba2
3 changed files with 17 additions and 10 deletions

View File

@ -206,8 +206,9 @@ static void test_trade_insect(CuTest *tc) {
test_setup(); test_setup();
init_resources(); init_resources();
test_create_locale(); test_create_locale();
r = setup_trade_region(tc, test_create_terrain("swamp", LAND_REGION));
init_terrains();
r = setup_trade_region(tc, get_terrain("swamp"));
it_luxury = r_luxury(r); it_luxury = r_luxury(r);
CuAssertPtrNotNull(tc, it_luxury); CuAssertPtrNotNull(tc, it_luxury);
it_silver = get_resourcetype(R_SILVER)->itype; it_silver = get_resourcetype(R_SILVER)->itype;
@ -220,6 +221,7 @@ static void test_trade_insect(CuTest *tc) {
produce(u->region); produce(u->region);
CuAssertIntEquals(tc, 1, get_item(u, it_luxury)); CuAssertIntEquals(tc, 1, get_item(u, it_luxury));
CuAssertIntEquals(tc, 5, get_item(u, it_silver)); CuAssertIntEquals(tc, 5, get_item(u, it_silver));
test_cleanup();
} }
static void test_buy_cmd(CuTest *tc) { static void test_buy_cmd(CuTest *tc) {
@ -231,8 +233,9 @@ static void test_buy_cmd(CuTest *tc) {
test_setup(); test_setup();
init_resources(); init_resources();
test_create_locale(); test_create_locale();
r = setup_trade_region(tc, test_create_terrain("swamp", LAND_REGION));
init_terrains();
r = setup_trade_region(tc, get_terrain("swamp"));
it_luxury = r_luxury(r); it_luxury = r_luxury(r);
CuAssertPtrNotNull(tc, it_luxury); CuAssertPtrNotNull(tc, it_luxury);
rt_silver = get_resourcetype(R_SILVER); rt_silver = get_resourcetype(R_SILVER);

View File

@ -132,6 +132,10 @@ const struct terrain_type *newterrain(terrain_t t)
return NULL; return NULL;
assert(t >= 0); assert(t >= 0);
assert(t < MAXTERRAINS); assert(t < MAXTERRAINS);
if (!newterrains[t]) {
log_warning("did you call init_terrains?");
newterrains[t] = get_terrain(terraindata[t]);
}
return newterrains[t]; return newterrains[t];
} }

View File

@ -122,10 +122,10 @@ struct locale * test_create_locale(void) {
for (i = 0; i != MAXDIRECTIONS; ++i) { for (i = 0; i != MAXDIRECTIONS; ++i) {
locale_setstring(loc, directions[i], directions[i]); locale_setstring(loc, directions[i], directions[i]);
init_direction(loc, i, directions[i]); init_direction(loc, i, directions[i]);
init_direction(loc, i, coasts[i]+7); init_direction(loc, i, coasts[i] + 7);
} }
for (i = 0; i <= ST_FLEE; ++i) { for (i = 0; i <= ST_FLEE; ++i) {
locale_setstring(loc, combatstatus[i], combatstatus[i]+7); locale_setstring(loc, combatstatus[i], combatstatus[i] + 7);
} }
for (i = 0; i != MAXKEYWORDS; ++i) { for (i = 0; i != MAXKEYWORDS; ++i) {
locale_setstring(loc, mkname("keyword", keywords[i]), keywords[i]); locale_setstring(loc, mkname("keyword", keywords[i]), keywords[i]);
@ -446,10 +446,10 @@ void test_create_world(void)
test_create_itemtype("iron"); test_create_itemtype("iron");
test_create_itemtype("stone"); test_create_itemtype("stone");
t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO); t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO);
t_plain->size = 1000; t_plain->size = 1000;
t_plain->max_road = 100; t_plain->max_road = 100;
t_ocean = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO); t_ocean = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO);
t_ocean->size = 0; t_ocean->size = 0;
island[0] = test_create_region(0, 0, t_plain); island[0] = test_create_region(0, 0, t_plain);
@ -545,20 +545,20 @@ void assert_message(CuTest * tc, message *msg, char *name, int numpar) {
void assert_pointer_parameter(CuTest * tc, message *msg, int index, void *arg) { void assert_pointer_parameter(CuTest * tc, message *msg, int index, void *arg) {
const message_type *mtype = (msg)->type; const message_type *mtype = (msg)->type;
CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertPtrEquals((tc), (arg), msg->parameters[(index)].v); CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype); CuAssertPtrEquals((tc), (arg), msg->parameters[(index)].v);
} }
void assert_int_parameter(CuTest * tc, message *msg, int index, int arg) { void assert_int_parameter(CuTest * tc, message *msg, int index, int arg) {
const message_type *mtype = (msg)->type; const message_type *mtype = (msg)->type;
CuAssertIntEquals((tc), VAR_INT, mtype->types[(index)]->vtype);CuAssertIntEquals((tc), (arg), msg->parameters[(index)].i); CuAssertIntEquals((tc), VAR_INT, mtype->types[(index)]->vtype); CuAssertIntEquals((tc), (arg), msg->parameters[(index)].i);
} }
void assert_string_parameter(CuTest * tc, message *msg, int index, const char *arg) { void assert_string_parameter(CuTest * tc, message *msg, int index, const char *arg) {
const message_type *mtype = (msg)->type; const message_type *mtype = (msg)->type;
CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertStrEquals((tc), (arg), msg->parameters[(index)].v); CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype); CuAssertStrEquals((tc), (arg), msg->parameters[(index)].v);
} }
void disabled_test(void *suite, void (*test)(CuTest *), const char *name) { void disabled_test(void *suite, void(*test)(CuTest *), const char *name) {
(void)test; (void)test;
fprintf(stderr, "%s: SKIP\n", name); fprintf(stderr, "%s: SKIP\n", name);
} }