Skip to content

Commit 456ce8c

Browse files
committed
Add tests for (hollow)cube
1 parent 8065e3d commit 456ce8c

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

worldedit/test/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ end)
282282

283283

284284
for _, name in ipairs({
285-
"manipulations", "schematic"
285+
"manipulations", "primitives", "schematic"
286286
}) do
287287
dofile(minetest.get_modpath("worldedit") .. "/test/" .. name .. ".lua")
288288
end

worldedit/test/primitives.lua

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---------------------
2+
local vec = vector.new
3+
local vecw = function(axis, n, base)
4+
local ret = vec(base)
5+
ret[axis] = n
6+
return ret
7+
end
8+
local air = "air"
9+
---------------------
10+
11+
12+
worldedit.register_test("Primitives")
13+
worldedit.register_test("worldedit.cube", function()
14+
local pos1, pos2 = area.get(6, 5, 4)
15+
local m = area.margin(1)
16+
17+
local center = vec(pos1.x + 3, pos1.y, pos1.z + 2)
18+
19+
worldedit.cube(center, 6, 5, 4, testnode2)
20+
21+
check.filled(pos1, pos2, testnode2)
22+
check.filled2(m, air)
23+
end)
24+
25+
worldedit.register_test("worldedit.cube hollow small", function()
26+
for n = 1, 2 do
27+
local pos1, pos2 = area.get(n)
28+
local m = area.margin(1)
29+
30+
local center = vec(pos1.x + math.floor(n/2), pos1.y, pos1.z + math.floor(n/2))
31+
32+
worldedit.cube(center, n, n, n, testnode1, true)
33+
34+
check.filled(pos1, pos2, testnode1) -- filled entirely
35+
check.filled2(m, air)
36+
end
37+
end)
38+
39+
worldedit.register_test("worldedit.cube hollow", function()
40+
local pos1, pos2 = area.get(6, 5, 4)
41+
local m = area.margin(1)
42+
43+
local center = vec(pos1.x + 3, pos1.y, pos1.z + 2)
44+
45+
worldedit.cube(center, 6, 5, 4, testnode1, true)
46+
47+
check.filled(vector.add(pos1, vec(1,1,1)), vector.subtract(pos2, vec(1,1,1)), air)
48+
check.filled2({
49+
{ vecw("x", pos2.x, pos1), pos2 },
50+
{ vecw("y", pos2.y, pos1), pos2 },
51+
{ vecw("z", pos2.z, pos1), pos2 },
52+
{ pos1, vecw("x", pos1.x, pos2) },
53+
{ pos1, vecw("y", pos1.y, pos2) },
54+
{ pos1, vecw("z", pos1.z, pos2) },
55+
}, testnode1)
56+
check.filled2(m, air)
57+
end)
58+
59+

0 commit comments

Comments
 (0)