test for alliance join/invite happy case

This commit is contained in:
Enno Rehling 2016-04-08 21:33:18 +02:00
parent 80b14048be
commit 3368ad51bd
1 changed files with 13 additions and 10 deletions

View File

@ -89,24 +89,27 @@ static void test_alliance_dead_faction(CuTest *tc) {
static void test_alliance_cmd(CuTest *tc) { static void test_alliance_cmd(CuTest *tc) {
unit *u1, *u2; unit *u1, *u2;
struct region *r; struct region *r;
struct alliance *al;
test_cleanup(); test_cleanup();
r = test_create_region(0, 0, 0); r = test_create_region(0, 0, 0);
u1 = test_create_unit(test_create_faction(0), r); u1 = test_create_unit(test_create_faction(0), r);
u2 = test_create_unit(test_create_faction(0), r); u2 = test_create_unit(test_create_faction(0), r);
u1->orders = create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)); unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
// TODO: INVITE unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_INVITE], itoa36(u2->faction->no)));
u2->orders = create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], 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, u1->faction));
CuAssertTrue(tc, !is_allied(u1->faction, u2->faction)); CuAssertTrue(tc, !is_allied(u1->faction, u2->faction));
CuAssertPtrEquals(tc, 0, f_get_alliance(u1->faction));
alliance_cmd(); alliance_cmd();
CuAssertPtrNotNull(tc, u1->faction->alliance); al = f_get_alliance(u1->faction);
CuAssertIntEquals(tc, 42, u1->faction->alliance->id); CuAssertPtrNotNull(tc, al);
CuAssertPtrNotNull(tc, u1->faction->alliance->members); CuAssertIntEquals(tc, 42, al->id);
CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(u1->faction->alliance)); CuAssertPtrNotNull(tc, al->members);
CuAssertPtrEquals(tc, u1->faction->alliance, findalliance(42)); CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(al));
// CuAssertTrue(tc, is_allied(u1->faction, u1->faction)); CuAssertPtrEquals(tc, al, findalliance(42));
// CuAssertPtrNotNull(tc, u2->faction->alliance); CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
CuAssertPtrEquals(tc, al, u2->faction->alliance);
test_cleanup(); test_cleanup();
} }