forked from github/server
testing destroy_road by way of destroy_cmd.
two simple cases only.
This commit is contained in:
parent
cf96013e0b
commit
1e04e20671
|
@ -130,7 +130,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||||
if (willdo == 0) {
|
if (willdo == 0) {
|
||||||
/* TODO: error message */
|
/* TODO: error message */
|
||||||
}
|
}
|
||||||
if (willdo > SHRT_MAX)
|
else if (willdo > SHRT_MAX)
|
||||||
road = 0;
|
road = 0;
|
||||||
else
|
else
|
||||||
road = (short)(road - willdo);
|
road = (short)(road - willdo);
|
||||||
|
|
|
@ -265,6 +265,30 @@ static void test_build_building_success(CuTest *tc) {
|
||||||
teardown_build(&bf);
|
teardown_build(&bf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_build_destroy_road(CuTest *tc)
|
||||||
|
{
|
||||||
|
region *r;
|
||||||
|
faction *f;
|
||||||
|
unit *u;
|
||||||
|
order *ord;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_region(1, 0, 0);
|
||||||
|
r = test_create_region(0, 0, 0);
|
||||||
|
rsetroad(r, D_EAST, 100);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), r);
|
||||||
|
ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
|
||||||
|
CuAssertIntEquals(tc, 100, rroad(r, D_EAST));
|
||||||
|
|
||||||
|
set_level(u, SK_ROAD_BUILDING, 1);
|
||||||
|
CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
|
||||||
|
CuAssertIntEquals(tc, 99, rroad(r, D_EAST));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_build_suite(void)
|
CuSuite *get_build_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -279,6 +303,7 @@ CuSuite *get_build_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_build_building_success);
|
SUITE_ADD_TEST(suite, test_build_building_success);
|
||||||
SUITE_ADD_TEST(suite, test_build_building_with_golem);
|
SUITE_ADD_TEST(suite, test_build_building_with_golem);
|
||||||
SUITE_ADD_TEST(suite, test_build_building_no_materials);
|
SUITE_ADD_TEST(suite, test_build_building_no_materials);
|
||||||
|
SUITE_ADD_TEST(suite, test_build_destroy_road);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue