From a86c2d88ab3495e74d47a9b3706ef0c307ab76ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 17 Oct 2014 19:56:26 +0200 Subject: [PATCH] Test: After a faction is eliminated, nobody should have it as an ally. --- src/kernel/faction.test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 08c2df891..31747bd6c 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -13,6 +14,21 @@ #include #include +static void test_remove_empty_factions_allies(CuTest *tc) { + faction *f1, *f2; + region *r; + + 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); + test_cleanup(); +} + static void test_remove_empty_factions(CuTest *tc) { faction *f, *fm; int fno; @@ -95,6 +111,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_remove_dead_factions); SUITE_ADD_TEST(suite, test_get_monsters); return suite;