test: cannot join an alliance if not invited

This commit is contained in:
Enno Rehling 2016-04-09 11:43:47 +02:00
parent 8801d88554
commit 4b6445dbf3
1 changed files with 21 additions and 0 deletions

View File

@ -113,6 +113,26 @@ static void test_alliance_cmd(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
static void test_alliance_no_invite(CuTest *tc) {
unit *u1, *u2;
struct region *r;
test_cleanup();
r = test_create_region(0, 0, 0);
u1 = test_create_unit(test_create_faction(0), r);
u2 = test_create_unit(test_create_faction(0), r);
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
CuAssertPtrEquals(tc, 0, f_get_alliance(u1->faction));
alliance_cmd();
CuAssertPtrNotNull(tc, f_get_alliance(u1->faction));
CuAssertPtrEquals(tc, 0, f_get_alliance(u2->faction));
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
test_cleanup();
}
CuSuite *get_alliance_suite(void) CuSuite *get_alliance_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -120,6 +140,7 @@ CuSuite *get_alliance_suite(void)
SUITE_ADD_TEST(suite, test_alliance_make); SUITE_ADD_TEST(suite, test_alliance_make);
SUITE_ADD_TEST(suite, test_alliance_join); SUITE_ADD_TEST(suite, test_alliance_join);
SUITE_ADD_TEST(suite, test_alliance_cmd); SUITE_ADD_TEST(suite, test_alliance_cmd);
SUITE_ADD_TEST(suite, test_alliance_no_invite);
return suite; return suite;
} }