fix a fall-through in jsonconf causing an error message.

add tests for pool, not working because of missing GIVEITEM on
JSON-configured races (TBD).
This commit is contained in:
Enno Rehling 2014-07-05 18:21:20 -07:00
parent 587df7fd12
commit 4a8707b06d
5 changed files with 44 additions and 1 deletions

View File

@ -246,6 +246,7 @@
<F N="../src/spells/buildingcurse.c"/> <F N="../src/spells/buildingcurse.c"/>
<F N="../cJSON/cJSON.c"/> <F N="../cJSON/cJSON.c"/>
<F N="../src/kernel/calendar.c"/> <F N="../src/kernel/calendar.c"/>
<F N="../src/callback.c"/>
<F N="../src/triggers/changefaction.c"/> <F N="../src/triggers/changefaction.c"/>
<F N="../src/triggers/changerace.c"/> <F N="../src/triggers/changerace.c"/>
<F N="../src/triggers/clonedied.c"/> <F N="../src/triggers/clonedied.c"/>
@ -403,6 +404,7 @@
<F N="../src/spells/buildingcurse.h"/> <F N="../src/spells/buildingcurse.h"/>
<F N="../cJSON/cJSON.h"/> <F N="../cJSON/cJSON.h"/>
<F N="../src/kernel/calendar.h"/> <F N="../src/kernel/calendar.h"/>
<F N="../src/callback.h"/>
<F N="../src/triggers/changefaction.h"/> <F N="../src/triggers/changefaction.h"/>
<F N="../src/triggers/changerace.h"/> <F N="../src/triggers/changerace.h"/>
<F N="../src/triggers/clonedied.h"/> <F N="../src/triggers/clonedied.h"/>

View File

@ -246,6 +246,7 @@
<F N="../src/util/bsdstring.test.c"/> <F N="../src/util/bsdstring.test.c"/>
<F N="../src/kernel/build.test.c"/> <F N="../src/kernel/build.test.c"/>
<F N="../src/kernel/building.test.c"/> <F N="../src/kernel/building.test.c"/>
<F N="../src/callback.test.c"/>
<F N="../src/kernel/config.test.c"/> <F N="../src/kernel/config.test.c"/>
<F N="../src/kernel/curse.test.c"/> <F N="../src/kernel/curse.test.c"/>
<F N="../src/direction.test.c"/> <F N="../src/direction.test.c"/>

View File

@ -106,8 +106,9 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) {
mt->flags = json_flags(child, flags); mt->flags = json_flags(child, flags);
} }
else { else {
log_error_n("maintenance contains unknown attribute %s", child->string); log_error_n("maintenance contains unknown array %s", child->string);
} }
break;
default: default:
log_error_n("maintenance contains unknown attribute %s", child->string); log_error_n("maintenance contains unknown attribute %s", child->string);
} }

View File

@ -8,3 +8,4 @@ require "tests.castles"
require "tests.spells" require "tests.spells"
require "tests.movement" require "tests.movement"
require "tests.ships" require "tests.ships"
require "tests.pool"

38
tests/pool.lua Normal file
View File

@ -0,0 +1,38 @@
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" : {}
},
"terrains" : {
"plain": { "flags" : [ "land" ] }
},
"keywords" : {
"de" : {
"give" : "GIB"
}
}
}]]
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) .. " 100 SILBER")
process_orders()
assert_equal(0, u1:get_item("money"))
assert_equal(100, u2:get_item("money"))
end