Lua: Fix off-by-one preventing accessing last df-other-vectors item by ID, add tests
parent
4e218c7de3
commit
f0ad730a37
@ -0,0 +1,27 @@
|
||||
function test.index_name()
|
||||
for _, k in ipairs(df.units_other_id) do
|
||||
expect.eq(df.global.world.units.other[k]._kind, 'container')
|
||||
end
|
||||
end
|
||||
|
||||
function test.index_name_bad()
|
||||
expect.error_match(function()
|
||||
expect.eq(df.global.world.units.other.SOME_FAKE_NAME, 'container')
|
||||
end, 'not found.$')
|
||||
end
|
||||
|
||||
function test.index_id()
|
||||
for i in ipairs(df.units_other_id) do
|
||||
expect.eq(df.global.world.units.other[i]._kind, 'container')
|
||||
end
|
||||
end
|
||||
|
||||
function test.index_id_bad()
|
||||
expect.error_match(function()
|
||||
expect.eq(df.global.world.units.other[df.units_other_id._first_item - 1], 'container')
|
||||
end, 'Cannot read field')
|
||||
expect.error_match(function()
|
||||
expect.eq(df.global.world.units.other[df.units_other_id._last_item + 1], 'container')
|
||||
end, 'Cannot read field')
|
||||
end
|
||||
|
Loading…
Reference in New Issue