forked from github/server
test that attackers do not get a building bonus
This commit is contained in:
parent
89b3b3161f
commit
3493c651f7
|
@ -13,7 +13,7 @@ static int add_two(building * b, unit * u) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
static void test_building_bonus(CuTest * tc)
|
||||
static void test_defenders_get_building_bonus(CuTest * tc)
|
||||
{
|
||||
unit *du, *au;
|
||||
region *r;
|
||||
|
@ -34,17 +34,16 @@ static void test_building_bonus(CuTest * tc)
|
|||
bld->size = 10;
|
||||
|
||||
du = test_create_unit(test_create_faction(rc_find("human")), r);
|
||||
du->building = bld;
|
||||
|
||||
au = test_create_unit(test_create_faction(rc_find("human")), r);
|
||||
du->building = bld;
|
||||
|
||||
b = make_battle(r);
|
||||
ds = make_side(b, du->faction, 0, 0, 0);
|
||||
df = make_fighter(b, du, ds, false);
|
||||
CuAssertPtrEquals(tc, bld, df->building);
|
||||
|
||||
as = make_side(b, au->faction, 0, 0, 0);
|
||||
af = make_fighter(b, au, as, true);
|
||||
|
||||
CuAssertPtrEquals(tc, bld, df->building);
|
||||
CuAssertPtrEquals(tc, 0, af->building);
|
||||
|
||||
dt.fighter = df;
|
||||
|
@ -54,11 +53,44 @@ static void test_building_bonus(CuTest * tc)
|
|||
|
||||
diff = skilldiff(at, dt, 0);
|
||||
CuAssertIntEquals(tc, -2, diff);
|
||||
|
||||
diff = skilldiff(dt, at, 0);
|
||||
CuAssertIntEquals(tc, 0, diff);
|
||||
}
|
||||
|
||||
static void test_attackers_get_no_building_bonus(CuTest * tc)
|
||||
{
|
||||
unit *au;
|
||||
region *r;
|
||||
building * bld;
|
||||
fighter *af;
|
||||
battle *b;
|
||||
side *as;
|
||||
building_type * btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
btype = bt_find("castle");
|
||||
btype->protection = &add_two;
|
||||
bld = test_create_building(r, btype);
|
||||
bld->size = 10;
|
||||
|
||||
au = test_create_unit(test_create_faction(rc_find("human")), r);
|
||||
au->building = bld;
|
||||
|
||||
|
||||
b = make_battle(r);
|
||||
as = make_side(b, au->faction, 0, 0, 0);
|
||||
af = make_fighter(b, au, as, true);
|
||||
|
||||
CuAssertPtrEquals(tc, 0, af->building);
|
||||
}
|
||||
|
||||
CuSuite *get_battle_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_building_bonus);
|
||||
SUITE_ADD_TEST(suite, test_defenders_get_building_bonus);
|
||||
SUITE_ADD_TEST(suite, test_attackers_get_no_building_bonus);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue