From 14b4ae5859245151c3416051a3c2e09c3749f968 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 Nov 2016 22:31:06 +0100 Subject: [PATCH] set volcano acitvation chance to 0 during test. should fix issue #606 for good. also: additional tests for renumbering ships, Xolgrim is wrong. --- scripts/tests/common.lua | 15 +++++++++++++++ scripts/tests/xmas.lua | 2 +- src/renumber.test.c | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index c39f2ce30..670060816 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -380,6 +380,21 @@ function test_events() assert(fail==0) end +function test_renumber_ship() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply4@eressea.de", "human", "de") + local u = unit.create(f, r) + local s = ship.create(r, config.ships[1]) + u.ship = s + u:add_order("NUMMER SCHIFF 1") + process_orders() + assert_equal(1, s.id) + u:clear_orders() + u:add_order("NUMMER SCHIFF 2") + process_orders() + assert_equal(2, s.id) +end + function test_recruit2() local r = region.create(0, 0, "plain") local f = faction.create("noreply4@eressea.de", "human", "de") diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 153052d5a..7ac4ce731 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -7,7 +7,7 @@ function setup() eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") - eressea.settings.set("volcano.active.percent", "4") + eressea.settings.set("volcano.active.percent", "0") end function test_snowglobe_fail() diff --git a/src/renumber.test.c b/src/renumber.test.c index 9ab6b1e7b..6c3f0f17b 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -102,6 +102,27 @@ static void test_renumber_ship(CuTest *tc) { test_cleanup(); } +static void test_renumber_ship_twice(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); + free_order(u->thisorder); + u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(no)); + renumber_cmd(u, u->thisorder); + CuAssertIntEquals(tc, no, u->ship->no); + test_cleanup(); +} + static void test_renumber_ship_duplicate(CuTest *tc) { unit *u; faction *f; @@ -204,6 +225,7 @@ CuSuite *get_renumber_suite(void) SUITE_ADD_TEST(suite, test_renumber_building); SUITE_ADD_TEST(suite, test_renumber_building_duplicate); SUITE_ADD_TEST(suite, test_renumber_ship); + SUITE_ADD_TEST(suite, test_renumber_ship_twice); SUITE_ADD_TEST(suite, test_renumber_ship_duplicate); SUITE_ADD_TEST(suite, test_renumber_faction); SUITE_ADD_TEST(suite, test_renumber_faction_duplicate);