This commit is contained in:
Enno Rehling 2017-02-22 19:38:56 +01:00
commit 807fe607e7
1 changed files with 26 additions and 0 deletions

View File

@ -514,6 +514,31 @@ static void test_cmp_castle_size(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
static void test_building_effsize(CuTest *tc) {
building *b;
building_type *btype;
construction *cons;
test_setup();
btype = bt_get_or_create("castle");
cons = btype->construction = calloc(1, sizeof(construction));
cons->maxsize = 5;
cons = cons->improvement = calloc(1, sizeof(construction));
cons->maxsize = 5;
cons = cons->improvement = calloc(1, sizeof(construction));
cons->maxsize = -1;
b = test_create_building(test_create_region(0,0,0), btype);
b->size = 1;
CuAssertIntEquals(tc, 0, buildingeffsize(b, false));
b->size = 5;
CuAssertIntEquals(tc, 1, buildingeffsize(b, false));
b->size = 10;
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
b->size = 20;
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
test_cleanup();
}
CuSuite *get_building_suite(void) CuSuite *get_building_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -521,6 +546,7 @@ CuSuite *get_building_suite(void)
SUITE_ADD_TEST(suite, test_register_building); SUITE_ADD_TEST(suite, test_register_building);
SUITE_ADD_TEST(suite, test_btype_defaults); SUITE_ADD_TEST(suite, test_btype_defaults);
SUITE_ADD_TEST(suite, test_building_set_owner); SUITE_ADD_TEST(suite, test_building_set_owner);
SUITE_ADD_TEST(suite, test_building_effsize);
SUITE_ADD_TEST(suite, test_buildingowner_resets_when_empty); SUITE_ADD_TEST(suite, test_buildingowner_resets_when_empty);
SUITE_ADD_TEST(suite, test_buildingowner_goes_to_next_when_empty); SUITE_ADD_TEST(suite, test_buildingowner_goes_to_next_when_empty);
SUITE_ADD_TEST(suite, test_buildingowner_goes_to_other_when_empty); SUITE_ADD_TEST(suite, test_buildingowner_goes_to_other_when_empty);