diff --git a/scripts/tests/bson.lua b/scripts/tests/bson.lua index a7c12d75c..0ee6e6e2e 100644 --- a/scripts/tests/bson.lua +++ b/scripts/tests/bson.lua @@ -37,3 +37,29 @@ function test_bson_readwrite() assert_equal(a.data, 42) end 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) + assert_not_equal(nil, u) + assert_not_equal(nil, r) + assert_not_equal(nil, f) + 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 diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 6c98b19ac..635b06f34 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -960,32 +960,6 @@ function test_bug_1679() 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) - assert_not_equal(nil, u) - assert_not_equal(nil, r) - assert_not_equal(nil, f) - 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 - function test_building_unique0() local r = region.create(0, 0, "mountain") local f = faction.create("noreply@eressea.de", "human", "de")