forked from github/server
refactor original trade test to use shared setup function.
This commit is contained in:
parent
12646f726a
commit
3fdde8a4aa
1 changed files with 10 additions and 16 deletions
|
@ -202,17 +202,15 @@ static void test_trade_insect(CuTest *tc) {
|
||||||
region *r;
|
region *r;
|
||||||
const item_type *it_luxury;
|
const item_type *it_luxury;
|
||||||
const item_type *it_silver;
|
const item_type *it_silver;
|
||||||
struct locale *lang;
|
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
init_resources();
|
init_resources();
|
||||||
|
test_create_locale();
|
||||||
lang = test_create_locale();
|
|
||||||
it_silver = get_resourcetype(R_SILVER)->itype;
|
|
||||||
|
|
||||||
r = setup_trade_region(tc, get_terrain("swamp"));
|
r = setup_trade_region(tc, get_terrain("swamp"));
|
||||||
it_luxury = r_luxury(r);
|
it_luxury = r_luxury(r);
|
||||||
CuAssertPtrNotNull(tc, it_luxury);
|
CuAssertPtrNotNull(tc, it_luxury);
|
||||||
|
it_silver = get_resourcetype(R_SILVER)->itype;
|
||||||
|
|
||||||
u = setup_trade_unit(tc, r, test_create_race("insect"));
|
u = setup_trade_unit(tc, r, test_create_race("insect"));
|
||||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s",
|
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s",
|
||||||
|
@ -229,24 +227,20 @@ static void test_buy_cmd(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
building *b;
|
building *b;
|
||||||
const resource_type *rt_silver;
|
const resource_type *rt_silver;
|
||||||
const resource_type *rt_luxury;
|
const item_type *it_luxury;
|
||||||
test_setup();
|
test_setup();
|
||||||
|
|
||||||
init_resources();
|
init_resources();
|
||||||
rt_luxury = get_resourcetype(R_HORSE);
|
test_create_locale();
|
||||||
CuAssertPtrNotNull(tc, rt_luxury);
|
|
||||||
CuAssertPtrNotNull(tc, rt_luxury->itype);
|
r = setup_trade_region(tc, get_terrain("swamp"));
|
||||||
new_luxurytype(rt_luxury->itype, 5);
|
it_luxury = r_luxury(r);
|
||||||
CuAssertPtrNotNull(tc, rt_luxury->ltype);
|
CuAssertPtrNotNull(tc, it_luxury);
|
||||||
rt_silver = get_resourcetype(R_SILVER);
|
rt_silver = get_resourcetype(R_SILVER);
|
||||||
CuAssertPtrNotNull(tc, rt_silver);
|
CuAssertPtrNotNull(tc, rt_silver);
|
||||||
CuAssertPtrNotNull(tc, rt_silver->itype);
|
CuAssertPtrNotNull(tc, rt_silver->itype);
|
||||||
|
|
||||||
r = test_create_region(0, 0, NULL);
|
|
||||||
fix_demand(r);
|
|
||||||
CuAssertPtrEquals(tc, rt_luxury->itype, (void *)r_luxury(r));
|
|
||||||
u = test_create_unit(test_create_faction(NULL), r);
|
u = test_create_unit(test_create_faction(NULL), r);
|
||||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(rt_luxury, 0))));
|
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0))));
|
||||||
set_item(u, rt_silver->itype, 1000);
|
set_item(u, rt_silver->itype, 1000);
|
||||||
|
|
||||||
produce(r);
|
produce(r);
|
||||||
|
@ -272,7 +266,7 @@ static void test_buy_cmd(CuTest *tc) {
|
||||||
produce(r);
|
produce(r);
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "buy"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "buy"));
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "buyamount"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "buyamount"));
|
||||||
CuAssertIntEquals(tc, 1, get_item(u, rt_luxury->itype));
|
CuAssertIntEquals(tc, 1, get_item(u, it_luxury));
|
||||||
CuAssertIntEquals(tc, 995, get_item(u, rt_silver->itype));
|
CuAssertIntEquals(tc, 995, get_item(u, rt_silver->itype));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue