#include #include "region.h" #include "building.h" #include "unit.h" #include "terrain.h" #include "item.h" #include #include void test_terraform(CuTest *tc) { region *r; terrain_type *t_plain, *t_ocean; item_type *itype; test_setup(); itype = test_create_itemtype("ointment"); itype->rtype->flags |= (RTF_ITEM | RTF_POOLED); new_luxurytype(itype, 0); t_plain = test_create_terrain("plain", LAND_REGION); t_ocean = test_create_terrain("ocean", SEA_REGION); r = test_create_region(0, 0, t_ocean); CuAssertPtrEquals(tc, 0, r->land); terraform_region(r, t_plain); CuAssertPtrNotNull(tc, r->land); CuAssertPtrNotNull(tc, r->land->demands); CuAssertPtrEquals(tc, itype, (void *)r->land->demands->type->itype); CuAssertIntEquals(tc, 0, r->land->demands->type->price); terraform_region(r, t_ocean); CuAssertPtrEquals(tc, 0, r->land); test_cleanup(); } static void test_region_get_owner(CuTest *tc) { region *r; building *b1, *b2; unit *u1, *u2; test_setup(); r = test_create_region(0, 0, 0); b1 = test_create_building(r, NULL); b2 = test_create_building(r, NULL); b1->size = 5; b2->size = 10; u1 = test_create_unit(test_create_faction(0), r); u_set_building(u1, b1); u2 = test_create_unit(test_create_faction(0), r); u_set_building(u2, b2); CuAssertPtrEquals(tc, u2->faction, region_get_owner(r)); test_cleanup(); } CuSuite *get_region_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_terraform); SUITE_ADD_TEST(suite, test_region_get_owner); return suite; }