diff --git a/src/economy.test.c b/src/economy.test.c index 481758891..460ebb5fb 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -206,8 +206,9 @@ static void test_trade_insect(CuTest *tc) { test_setup(); init_resources(); 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); CuAssertPtrNotNull(tc, it_luxury); it_silver = get_resourcetype(R_SILVER)->itype; @@ -220,6 +221,7 @@ static void test_trade_insect(CuTest *tc) { produce(u->region); CuAssertIntEquals(tc, 1, get_item(u, it_luxury)); CuAssertIntEquals(tc, 5, get_item(u, it_silver)); + test_cleanup(); } static void test_buy_cmd(CuTest *tc) { @@ -231,8 +233,9 @@ static void test_buy_cmd(CuTest *tc) { test_setup(); init_resources(); 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); CuAssertPtrNotNull(tc, it_luxury); rt_silver = get_resourcetype(R_SILVER); diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index e9f448f97..8c7ab8878 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -132,6 +132,10 @@ const struct terrain_type *newterrain(terrain_t t) return NULL; assert(t >= 0); assert(t < MAXTERRAINS); + if (!newterrains[t]) { + log_warning("did you call init_terrains?"); + newterrains[t] = get_terrain(terraindata[t]); + } return newterrains[t]; } diff --git a/src/tests.c b/src/tests.c index 770d2853c..d07124af3 100644 --- a/src/tests.c +++ b/src/tests.c @@ -122,10 +122,10 @@ struct locale * test_create_locale(void) { for (i = 0; i != MAXDIRECTIONS; ++i) { locale_setstring(loc, directions[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) { - locale_setstring(loc, combatstatus[i], combatstatus[i]+7); + locale_setstring(loc, combatstatus[i], combatstatus[i] + 7); } for (i = 0; i != MAXKEYWORDS; ++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("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->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; 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) { 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) { 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) { 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; fprintf(stderr, "%s: SKIP\n", name); }