test the bson functionality, and provide examples for using it

This commit is contained in:
Enno Rehling 2011-02-06 08:41:14 +01:00
parent ad4f4f59f0
commit b07f40c02e
1 changed files with 23 additions and 0 deletions

View File

@ -885,3 +885,26 @@ function test_bug_1679()
assert_true(find_in_report(f, "Die Einheit kann keine weiteren langen Befehle", "cr"))
assert_true(find_in_report(f, "entdeckt, dass es keinen Weg nach Westen gibt"))
end
function test_bson()
local r = region.create(0, 0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
attrib.create(r, 1)
assert_equal(attrib.get(r)().data, 1)
attrib.create(u, 3)
assert_equal(attrib.get(u)().data, 3)
attrib.create(f, 5)
assert_equal(attrib.get(f)().data, 5)
end
function test_bson_with_multiple_attribs()
local r = region.create(0, 0, "mountain")
attrib.create(r, { a=1})
attrib.create(r, { a=5})
local total = 0
for a in attrib.get(r) do
total = total + a.data.a;
end
assert_equal(6, total)
end