2020-05-03 16:52:40 +02:00
|
|
|
local tcname = 'tests.faction'
|
|
|
|
local lunit = require('lunit')
|
2020-04-19 21:35:48 +02:00
|
|
|
if _VERSION >= 'Lua 5.2' then
|
2020-05-03 16:52:40 +02:00
|
|
|
_ENV = module(tcname, 'seeall')
|
2020-04-19 21:35:48 +02:00
|
|
|
else
|
2020-05-03 16:52:40 +02:00
|
|
|
module(tcname, lunit.testcase, package.seeall)
|
2020-04-19 21:35:48 +02:00
|
|
|
end
|
2014-08-07 13:19:19 +02:00
|
|
|
|
|
|
|
local f
|
|
|
|
|
|
|
|
function setup()
|
2015-03-07 14:11:32 +01:00
|
|
|
conf = [[{
|
|
|
|
"races": {
|
|
|
|
"human" : {}
|
|
|
|
}
|
|
|
|
}]]
|
|
|
|
eressea.config.reset()
|
|
|
|
assert(eressea.config.parse(conf)==0)
|
2017-03-17 22:31:59 +01:00
|
|
|
f = faction.create("human", "faction@eressea.de", "de")
|
2015-03-07 13:56:31 +01:00
|
|
|
assert(f~=nil)
|
2014-08-07 13:19:19 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function test_faction_flags()
|
2017-01-22 18:51:20 +01:00
|
|
|
assert_equal(6, f.flags) -- FFL_ISNEW|FFL_PWMSG
|
2015-02-20 20:35:02 +01:00
|
|
|
f.flags = 42
|
|
|
|
assert_equal(42, f.flags)
|
2014-08-07 13:19:19 +02:00
|
|
|
end
|
2014-11-26 18:37:07 +01:00
|
|
|
|
|
|
|
function test_get_faction()
|
2015-02-20 20:35:02 +01:00
|
|
|
assert_equal(f, get_faction(f.id))
|
|
|
|
assert_equal(f, faction.get(f.id))
|
|
|
|
local nf = f.id
|
|
|
|
if nf>1 then nf = nf - 1 else nf = 1 end
|
|
|
|
assert_equal(nil, faction.get(nf))
|
2014-11-26 18:37:07 +01:00
|
|
|
end
|