fix recruiting tests. peasant growth is too random to calculate.

add current critbit module
This commit is contained in:
Enno Rehling 2014-03-17 06:46:31 +01:00
parent edae097591
commit 0a0d70bb1d
2 changed files with 41 additions and 36 deletions

View File

@ -934,6 +934,46 @@ function test_walk_and_carry_the_cart()
assert_equal(1, u.region.x) assert_equal(1, u.region.x)
end end
module("tests.recruit", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("rules.economy.food", "4")
eressea.settings.set("rules.peasants.growth", "0")
end
function test_bug_1795_limit()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u1 = one_unit(r,f)
u1:add_item("money", 100000000)
u1:add_order("REKRUTIEREN 9999")
r:set_resource("peasant", 2000) -- no fractional growth!
local peasants = r:get_resource("peasant")
local limit,frac = math.modf(peasants/40) -- one day this should be a parameter
process_orders()
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
assert_equal(peasants-limit, r:get_resource("peasant"))
end
function test_bug_1795_demons()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "demon", "de")
local u1 = one_unit(r,f)
r:set_resource("peasant", 2000)
local peasants = r:get_resource("peasant")
local limit,frac = math.modf(peasants/40)
u1:add_item("money", 100000000)
u1:add_order("REKRUTIEREN 9999")
process_orders()
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
assert_equal(peasants, r:get_resource("peasant"))
end
module("tests.report", package.seeall, lunit.testcase) module("tests.report", package.seeall, lunit.testcase)
function setup() function setup()
@ -1386,41 +1426,6 @@ function test_bug_1870_leave_enter_e3()
assert_equal(u1.building.id, mine.id) assert_equal(u1.building.id, mine.id)
end end
function test_bug_1795_limit()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u1 = one_unit(r,f)
u1:add_item("money", 100000000)
u1:add_order("REKRUTIEREN 9999")
r:set_resource("peasant", 2000) -- no fractional growth!
local peasants = r:get_resource("peasant")
local limit,frac = math.modf(peasants/40) -- one day this should be a parameter
local growth = peasants * 0.001
process_orders()
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
assert_equal(peasants+growth-limit, r:get_resource("peasant"))
end
function test_bug_1795_demons()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "demon", "de")
local u1 = one_unit(r,f)
r:set_resource("peasant", 2000)
local peasants = r:get_resource("peasant")
local limit,frac = math.modf(peasants/40)
local growth = peasants * 0.001
u1:add_item("money", 100000000)
u1:add_order("REKRUTIEREN 9999")
process_orders()
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
assert_equal(peasants+growth, r:get_resource("peasant"))
end
function test_faction_flags() function test_faction_flags()
f = faction.create("noreply@eressea.de", "human", "de") f = faction.create("noreply@eressea.de", "human", "de")
assert_equal(0, f.flags) assert_equal(0, f.flags)

@ -1 +1 @@
Subproject commit 9e186825e0809dc2edde007799637716265f1e77 Subproject commit 2a7af5e2347217ea4efcf7fb3f0bc9c2681d1a17