From 4a667326371761c32ff0a9a1ec78f759727f5e2f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 Nov 2016 20:41:48 +0100 Subject: [PATCH] renumber tests for building, ship --- src/renumber.test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/renumber.test.c b/src/renumber.test.c index 5b8dc5e2c..3fabaf4c1 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,6 +29,40 @@ static void test_renumber_faction(CuTest *tc) { test_cleanup(); } +static void test_renumber_building(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->building = test_create_building(u->region, 0); + no = u->building->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->building->no); + test_cleanup(); +} + +static void test_renumber_ship(CuTest *tc) { + unit *u; + int uno, no; + const struct locale *lang; + + test_setup_ex(tc); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->ship = test_create_ship(u->region, 0); + no = u->ship->no; + uno = (no > 1) ? no - 1 : no + 1; + lang = u->faction->locale; + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, uno, u->ship->no); + test_cleanup(); +} + static void test_renumber_unit(CuTest *tc) { unit *u; int uno, no; @@ -48,6 +84,8 @@ CuSuite *get_renumber_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_renumber_unit); + SUITE_ADD_TEST(suite, test_renumber_building); + SUITE_ADD_TEST(suite, test_renumber_ship); SUITE_ADD_TEST(suite, test_renumber_faction); return suite; }