Add a basic test for df.image_set.find()
parent
cc2a5acdd3
commit
d664681ea8
@ -0,0 +1,32 @@
|
|||||||
|
config = {
|
||||||
|
mode = 'title',
|
||||||
|
}
|
||||||
|
|
||||||
|
local function clean_vec(vec)
|
||||||
|
while #vec > 0 do
|
||||||
|
if vec[0] then
|
||||||
|
expect.true_(vec[0]:delete())
|
||||||
|
end
|
||||||
|
vec:erase(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function with_clean_vec(cls, callback)
|
||||||
|
local vec = cls.get_vector()
|
||||||
|
dfhack.call_with_finalizer(1, true, clean_vec, vec, callback, vec)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test.image_set()
|
||||||
|
-- todo: expand to other types?
|
||||||
|
with_clean_vec(df.image_set, function(vec)
|
||||||
|
vec:insert('#', {new = df.image_set, id = 1})
|
||||||
|
vec:insert('#', {new = df.image_set, id = 2})
|
||||||
|
vec:insert('#', {new = df.image_set, id = 4})
|
||||||
|
expect.eq(df.image_set.find(1).id, 1)
|
||||||
|
expect.eq(df.image_set.find(2).id, 2)
|
||||||
|
expect.eq(df.image_set.find(4).id, 4)
|
||||||
|
expect.nil_(df.image_set.find(3))
|
||||||
|
expect.nil_(df.image_set.find(5))
|
||||||
|
expect.nil_(df.image_set.find(-1))
|
||||||
|
end)
|
||||||
|
end
|
Loading…
Reference in New Issue