diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index a94a907e8..9c85884b7 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -16,18 +16,23 @@ #include #include -static void test_remove_empty_factions_allies(CuTest *tc) { +static void test_destroyfaction_allies(CuTest *tc) { faction *f1, *f2; region *r; + ally *al; test_cleanup(); r = test_create_region(0, 0, 0); f1 = test_create_faction(0); test_create_unit(f1, r); f2 = test_create_faction(0); - ally_add(&f1->allies, f2); - remove_empty_factions(); - CuAssertPtrEquals(tc, 0, f1->allies); + al = ally_add(&f1->allies, f2); + al->status = HELP_FIGHT; + CuAssertIntEquals(tc, HELP_FIGHT, alliedgroup(0, f1, f2, f1->allies, HELP_ALL)); + CuAssertPtrEquals(tc, f2, f1->next); + destroyfaction(&f1->next); + CuAssertIntEquals(tc, false, faction_alive(f2)); + CuAssertIntEquals(tc, 0, alliedgroup(0, f1, f2, f1->allies, HELP_ALL)); test_cleanup(); } @@ -174,7 +179,7 @@ CuSuite *get_faction_suite(void) CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_remove_empty_factions); - SUITE_ADD_TEST(suite, test_remove_empty_factions_allies); + SUITE_ADD_TEST(suite, test_destroyfaction_allies); SUITE_ADD_TEST(suite, test_remove_empty_factions_alliance); SUITE_ADD_TEST(suite, test_remove_dead_factions); SUITE_ADD_TEST(suite, test_get_monsters);