forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind.lua
More file actions
31 lines (28 loc) · 954 Bytes
/
Copy pathfind.lua
File metadata and controls
31 lines (28 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
config.mode = 'title' -- not safe to run when a world is loaded
config.target = 'core'
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