delete old tests folder (moved to scripts/)

This commit is contained in:
Enno Rehling 2014-08-07 13:24:46 +02:00
parent 91eead0993
commit 1af9a9aeda
11 changed files with 0 additions and 555 deletions

View File

@ -1,53 +0,0 @@
require "lunit"
module("tests.castles", package.seeall, lunit.testcase )
function setup()
eressea.game.reset()
eressea.config.reset()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.ships.storms", "0")
conf = [[{
"races": {
"human" : {},
"halfling" : {}
},
"buildings" : {
"castle" : {
"name" : "castle_name",
"construction" : [
{ "maxsize" : 2 },
{ "maxsize" : 10 },
{ "maxsize" : 50 },
{ "maxsize" : 250 }
]
}
},
"terrains" : {
"plain": { "flags" : [ "land" ] }
},
"keywords" : {
"de" : {
"make" : "MACHEN"
}
}
}]]
assert(eressea.config.parse(conf)==0)
end
function test_castle_names()
local r = region.create(0, 0, "plain")
local f1 = faction.create("test@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local b = building.create(r, "castle")
u1.building = b
b.owner = u1
assert_equal("site", b:get_typename(1))
assert_equal("tradepost", b:get_typename(2))
assert_equal("tradepost", b:get_typename(9))
assert_equal("fortification", b:get_typename(10))
end

View File

@ -1,38 +0,0 @@
require "lunit"
module("tests.eressea.config", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
eressea.config.reset();
end
function test_read_race()
local f
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
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

View File

@ -1,12 +0,0 @@
-- new tests 2014-06-11
require "tests.pool"
require "tests.settings"
require "tests.config"
require "tests.locale"
require "tests.regions"
require "tests.study"
require "tests.castles"
require "tests.spells"
require "tests.movement"
require "tests.ships"
require "tests.pool"

View File

@ -1,17 +0,0 @@
require "lunit"
module("tests.eressea.locale", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_get_set()
local loc = "en"
assert_not_nil(eressea.locale)
eressea.locale.create(loc)
assert_equal(nil, eressea.locale.get(loc, "move"))
eressea.locale.set(loc, "move", "MOVE")
assert_equal("MOVE", eressea.locale.get(loc, "move"))
end

View File

@ -1,117 +0,0 @@
require "lunit"
module("tests.movement", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.ships.storms", "0")
conf = [[{
"races": {
"human" : {
"speed" : 1,
"weight" : 1000,
"capacity" : 1500,
"flags" : [ "walk" ]
},
"troll" : {}
},
"items" : {
"horse" : {
"capacity" : 7000,
"weight" : 5000,
"flags" : [ "big", "animal" ]
}
},
"terrains" : {
"ocean": { "flags" : [ "sea", "sail" ] },
"plain": { "flags" : [ "land", "walk", "sail" ] },
"glacier": { "flags" : [ "land", "walk" ] }
},
"directions" : {
"de" : {
"east" : "OSTEN",
"west" : "WESTEN"
}
},
"keywords" : {
"de" : {
"move" : "NACH"
}
}
}]]
eressea.config.reset()
eressea.config.parse(conf)
end
function test_walk_to_land()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
local f = faction.create("walk@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u:add_order("NACH O")
process_orders()
assert_equal(r2, u.region)
end
function test_walk_into_ocean_fails()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "ocean")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u:add_order("NACH O")
process_orders()
assert_equal(r1, u.region)
end
function test_walk_distance()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
region.create(2, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u:add_order("NACH O O")
process_orders()
assert_equal(r2, u.region)
end
function test_ride_max_distance()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(2, 0, "plain")
region.create(1, 0, "plain")
region.create(3, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u:add_item("horse", 1)
u:set_skill("riding", 2)
u:add_order("NACH O O O")
process_orders()
assert_equal(r2, u.region, "should ride exactly two hexes")
end
function test_ride_over_capacity_leads_horse()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
region.create(2, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 3)
u:add_item("horse", 1)
u:set_skill("riding", 2)
u:add_order("NACH O O")
process_orders()
assert_equal(r2, u.region)
end
function test_ride_no_skill_leads_horse()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
region.create(2, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u:add_item("horse", 1)
u:add_order("NACH O O")
process_orders()
assert_equal(r2, u.region)
end

View File

@ -1,74 +0,0 @@
require "lunit"
module("tests.eressea.pool", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
eressea.config.reset();
eressea.settings.set("rules.economy.food", "0")
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
conf = [[{
"races": {
"human" : { "flags" : [ "giveitem", "getitem" ] }
},
"terrains" : {
"plain": { "flags" : [ "land" ] }
},
"keywords" : {
"de" : {
"give" : "GIB",
"contact" : "KONTAKTIERE"
}
},
"strings" : {
"de" : {
"money" : "Silber"
}
}
}]]
assert(eressea.config.parse(conf)==0)
end
function test_give_nopool()
local r = region.create(1, 1, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
u1:add_item("money", 100)
u1:add_order("GIB " .. itoa36(u2.id) .. " 50 SILBER")
process_orders()
assert_equal(50, u1:get_item("money"))
assert_equal(50, u2:get_item("money"))
end
function test_give_from_faction()
local r = region.create(1, 1, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1)
u1:add_item("money", 50)
u2:add_item("money", 50)
u1:add_order("GIB " .. itoa36(u3.id) .. " 100 SILBER")
process_orders()
assert_equal(0, u1:get_item("money"))
assert_equal(0, u2:get_item("money"))
assert_equal(100, u3:get_item("money"))
end
function test_give_divisor()
eressea.settings.set("rules.items.give_divisor", 2)
local r = region.create(1, 1, "plain")
local f1 = faction.create("test@example.com", "human", "de")
local f2 = faction.create("test@example.com", "human", "de")
local u1 = unit.create(f1, r, 1)
local u2 = unit.create(f2, r, 1)
u2:add_order("KONTAKTIERE " .. itoa36(u1.id))
u1:add_item("money", 100)
u1:add_order("GIB " .. itoa36(u2.id) .. " 100 SILBER")
process_orders()
assert_equal(0, u1:get_item("money"))
assert_equal(50, u2:get_item("money"))
end

View File

@ -1,20 +0,0 @@
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

View File

@ -1,13 +0,0 @@
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

View File

@ -1,127 +0,0 @@
require "lunit"
module("tests.ships", package.seeall, lunit.testcase)
function setup()
eressea.game.reset()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.ships.storms", "0")
conf = [[{
"races": {
"human" : {},
"insect" : {}
},
"ships" : {
"boat" : {
"construction" : {
"maxsize" : 5
},
"coasts" : [ "plain" ],
"range" : 3
}
},
"buildings" : {
"harbour" : { "maintenance" : { "type" : "money", "amount" : 250, "flags" : [ "required" ] } }
},
"terrains" : {
"ocean": { "flags" : [ "sea", "sail" ] },
"plain": { "flags" : [ "land", "walk", "sail" ] },
"glacier": { "flags" : [ "land", "walk" ] }
},
"directions" : {
"de" : {
"east" : "OSTEN",
"west" : "WESTEN"
}
},
"keywords" : {
"de" : {
"move" : "NACH"
}
},
"strings" : {
"de" : {
"harbour" : "Hafen"
}
}
}]]
eressea.config.reset()
assert(eressea.config.parse(conf)==0)
end
function test_sail_oceans()
local r1 = region.create(0, 0, "ocean")
local r2 = region.create(1, 0, "ocean")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u.ship = ship.create(r1, "boat")
u.ship.size = 5
u:set_skill("sailing", 10)
u:add_order("NACH O")
process_orders()
assert_equal(r2, u.region)
end
function test_sail_to_shore()
local ocean = region.create(1, 0, "ocean")
local shore = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, ocean, 1)
u.ship = ship.create(ocean, "boat")
u:set_skill("sailing", 10)
u:add_order("NACH W")
process_orders()
assert_equal(shore, u.region)
end
function test_sail_to_forbidden_shore()
local ocean = region.create(1, 0, "ocean")
local shore = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, ocean, 1)
u.ship = ship.create(ocean, "boat")
u:set_skill("sailing", 10)
u:add_order("NACH W")
process_orders()
assert_equal(ocean, u.region)
end
function test_sail_into_good_harbour()
local ocean = region.create(1, 0, "ocean")
local shore = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local b = building.create(shore, "harbour")
local u
u = unit.create(f, shore, 1)
u:add_item("money", 250) -- building maintenance fee
u.building = b
u = unit.create(f, ocean, 1)
u.ship = ship.create(ocean, "boat")
u:set_skill("sailing", 10)
u:add_order("NACH W")
process_orders()
assert_equal(shore, u.region, "working harbour should let the ship land")
end
function test_sail_into_bad_harbour()
local ocean = region.create(1, 0, "ocean")
local shore = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, ocean, 1)
u.name = "Sailor"
u.ship = ship.create(ocean, "boat")
u:set_skill("sailing", 10)
u:add_order("NACH W")
local b = building.create(shore, "harbour")
assert_not_nil(b)
process_orders()
assert_equal(ocean, u.region, "harbour without owner should stop ship")
end

View File

@ -1,47 +0,0 @@
require "lunit"
module("tests.spells", package.seeall, lunit.testcase)
function setup()
eressea.game.reset()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
conf = [[{
"races": {
"human" : {}
},
"terrains" : {
"plain": { "flags" : [ "land", "walk", "sail" ] }
},
"spells" : {
"resist_magic" : {
"index" : 97,
"parameters" : "u+"
}
},
"keywords" : {
"de" : {
"cast" : "ZAUBERE"
}
},
"strings" : {
"de" : {
"harbour" : "Hafen"
}
}
}]]
eressea.config.reset()
assert(eressea.config.parse(conf)==0)
end
function test_antimagic_visibility()
local r = region.create(0, 0, "plain")
local f1 = faction.create("test@example.com", "human", "de")
local mage = unit.create(f1, r, 1)
local target = unit.create(f1, r, 1)
mage:set_skill("magic", 10)
mage:add_spell("resist_magic")
mage:add_order("ZAUBERE Antimagie " .. target.id)
process_orders()
end

View File

@ -1,37 +0,0 @@
require "lunit"
module("tests.eressea.study", package.seeall, lunit.testcase)
function setup()
conf = [[{
"races" : { "human" : {} },
"terrains" : { "plain" : { "flags" : [ "land" ] } },
"keywords" : { "de" : { "study": "LERNEN" } },
"skills" : { "de": { "alchemy" : "Alchemie", "crossbow" : "Armbrust" } }
}]]
eressea.game.reset()
eressea.config.reset();
eressea.config.parse(conf)
end
function test_study()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r, 1)
u:add_order("LERNEN Armbrust")
process_orders()
assert_equal(1, u:get_skill("crossbow"))
end
function test_study_expensive()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r, 1)
eressea.settings.set("skills.cost.alchemy", "50")
eressea.settings.set("rules.encounters", "0")
u:add_order("LERNEN Alchemie")
u:add_item("money", 50)
process_orders()
assert_equal(1, u:get_skill("alchemy"))
assert_equal(0, u:get_item("money"))
end