testin building_is_active

testing multiple units in one building
This commit is contained in:
Enno Rehling 2015-11-02 15:05:54 +01:00
parent 4bf2509fb3
commit 072bfd3912
2 changed files with 19 additions and 0 deletions

View File

@ -382,6 +382,19 @@ static void test_btype_defaults(CuTest *tc) {
test_cleanup();
}
static void test_active_building(CuTest *tc) {
building *b;
test_cleanup();
b = test_create_building(test_create_region(0,0,0), 0);
CuAssertIntEquals(tc, false, building_is_active(b));
b->flags |= BLD_WORKING;
CuAssertIntEquals(tc, true, building_is_active(b));
b->flags &= ~BLD_WORKING;
CuAssertIntEquals(tc, false, building_is_active(b));
test_cleanup();
}
CuSuite *get_building_suite(void)
{
CuSuite *suite = CuSuiteNew();
@ -396,5 +409,6 @@ CuSuite *get_building_suite(void)
SUITE_ADD_TEST(suite, test_buildingowner_goes_to_other_after_leave);
SUITE_ADD_TEST(suite, test_buildingowner_goes_to_same_faction_after_leave);
SUITE_ADD_TEST(suite, test_buildingowner_goes_to_empty_unit_after_leave);
SUITE_ADD_TEST(suite, test_active_building);
return suite;
}

View File

@ -394,6 +394,11 @@ static void test_inside_building(CuTest *tc) {
CuAssertPtrEquals(tc, 0, inside_building(u));
b->size = 2;
CuAssertPtrEquals(tc, b, inside_building(u));
u = test_create_unit(u->faction, u->region);
u->building = b;
CuAssertPtrEquals(tc, 0, inside_building(u));
b->size = 3;
CuAssertPtrEquals(tc, b, inside_building(u));
test_cleanup();
}