new test suite, moving to new directory.

This commit is contained in:
Enno Rehling 2014-06-13 17:35:43 -07:00
parent e27bde06ac
commit 2033aabf60
7 changed files with 135 additions and 8 deletions

View File

@ -15,8 +15,7 @@ if [ ! -d $ROOT/$BIN_DIR ]; then
exit
fi
echo $ROOT
$ROOT/$BIN_DIR/eressea/test_eressea
cd $ROOT/scripts
$ROOT/$BIN_DIR/eressea/eressea -v0 runtests.lua
cd $ROOT
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/runtests.lua
cd -

View File

@ -1,9 +1,6 @@
-- new tests 2014-06-11
require "lunit"
require "tests.settings"
require "tests.config"
-- require "tests.ships"
require "tests"
lunit.main()

39
tests/config.lua Normal file
View File

@ -0,0 +1,39 @@
require "lunit"
module("tests.eressea.config", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_read_race()
local f
eressea.free_game()
f = faction.create("orc@example.com", "orc", "en")
assert_equal(nil, f)
assert_not_nil(eressea.config)
eressea.config.parse('{ "races": { "orc" : {}}}')
f = faction.create("orc@example.com", "orc", "en")
assert_not_nil(f)
end
function test_read_ship()
local s
eressea.free_game()
s = ship.create(nil, "boat")
assert_equal(nil, s)
assert_not_nil(eressea.config)
conf = [[{
"ships": {
"boat" : {
"construction" : {
"maxsize" : 20
}
}
}
}]]
eressea.config.parse(conf);
s = ship.create(nil, "boat")
assert_not_nil(s)
end

5
tests/init.lua Normal file
View File

@ -0,0 +1,5 @@
-- new tests 2014-06-11
require "tests.settings"
require "tests.config"
require "tests.regions"
--require "tests.ships"

22
tests/regions.lua Normal file
View File

@ -0,0 +1,22 @@
require "lunit"
module("tests.regions", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
conf = [[{
"terrains" : {
"ocean": {},
"plain": {}
}
}]]
eressea.config.parse(conf)
end
function test_create()
local r
r = region.create(0, 0, "ocean")
assert_not_nil(r)
end

13
tests/settings.lua Normal file
View File

@ -0,0 +1,13 @@
require "lunit"
module("tests.eressea.settings", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_settings()
assert_equal(nil, eressea.settings.get("foo"))
eressea.settings.set("foo", "bar")
assert_equal("bar", eressea.settings.get("foo"))
end

52
tests/ships.lua Normal file
View File

@ -0,0 +1,52 @@
require "lunit"
module("tests.ships", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
conf = [[{
"races": {
"human" : {},
"insect" : {}
},
"ships" : {
"boat" : {},
"longboat" : {}
},
"buildings" : {
"harbour" : {}
},
"terrains" : {
"ocean": {},
"plain": {}
}
}]]
eressea.config.parse(conf)
end
function test_landing1()
local ocean = region.create(1, 0, "ocean")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "insect", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de")
local s = ship.create(ocean, "longboat")
local u1 = unit.create(f, ocean, 1)
local u2 = unit.create(f2, r, 1)
assert_not_nil(u2)
u1:add_item("money", 1000)
u2:add_item("money", 1000)
u1.ship = s
u1:set_skill("sailing", 10)
u1:clear_orders()
u1:add_order("NACH w")
process_orders()
assert_equal(r, u1.region) -- the plain case: okay
end