From 3368ad51bd1969e44d810aef34c1838e09b36bd3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 8 Apr 2016 21:33:18 +0200 Subject: [PATCH] test for alliance join/invite happy case --- src/kernel/alliance.test.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c index 99a8e3384..0112f99d0 100644 --- a/src/kernel/alliance.test.c +++ b/src/kernel/alliance.test.c @@ -89,24 +89,27 @@ static void test_alliance_dead_faction(CuTest *tc) { static void test_alliance_cmd(CuTest *tc) { unit *u1, *u2; struct region *r; + struct alliance *al; 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); - u1->orders = create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)); - // TODO: INVITE - u2->orders = create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)); + unit_addorder(u1, 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_INVITE], itoa36(u2->faction->no))); + 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, u1->faction->alliance); - CuAssertIntEquals(tc, 42, u1->faction->alliance->id); - CuAssertPtrNotNull(tc, u1->faction->alliance->members); - CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(u1->faction->alliance)); - CuAssertPtrEquals(tc, u1->faction->alliance, findalliance(42)); -// CuAssertTrue(tc, is_allied(u1->faction, u1->faction)); -// CuAssertPtrNotNull(tc, u2->faction->alliance); + al = f_get_alliance(u1->faction); + CuAssertPtrNotNull(tc, al); + CuAssertIntEquals(tc, 42, al->id); + CuAssertPtrNotNull(tc, al->members); + CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(al)); + CuAssertPtrEquals(tc, al, findalliance(42)); + CuAssertTrue(tc, is_allied(u1->faction, u1->faction)); + CuAssertPtrEquals(tc, al, u2->faction->alliance); test_cleanup(); }