Skip to content

Commit

Permalink
Add tests for (hollow)cube
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Apr 22, 2024
1 parent 8065e3d commit 456ce8c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion worldedit/test/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ end)


for _, name in ipairs({
"manipulations", "schematic"
"manipulations", "primitives", "schematic"
}) do
dofile(minetest.get_modpath("worldedit") .. "/test/" .. name .. ".lua")
end
Expand Down
59 changes: 59 additions & 0 deletions worldedit/test/primitives.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---------------------
local vec = vector.new
local vecw = function(axis, n, base)
local ret = vec(base)
ret[axis] = n
return ret
end
local air = "air"
---------------------


worldedit.register_test("Primitives")
worldedit.register_test("worldedit.cube", function()
local pos1, pos2 = area.get(6, 5, 4)
local m = area.margin(1)

local center = vec(pos1.x + 3, pos1.y, pos1.z + 2)

worldedit.cube(center, 6, 5, 4, testnode2)

check.filled(pos1, pos2, testnode2)
check.filled2(m, air)
end)

worldedit.register_test("worldedit.cube hollow small", function()
for n = 1, 2 do
local pos1, pos2 = area.get(n)
local m = area.margin(1)

local center = vec(pos1.x + math.floor(n/2), pos1.y, pos1.z + math.floor(n/2))

worldedit.cube(center, n, n, n, testnode1, true)

check.filled(pos1, pos2, testnode1) -- filled entirely
check.filled2(m, air)
end
end)

worldedit.register_test("worldedit.cube hollow", function()
local pos1, pos2 = area.get(6, 5, 4)
local m = area.margin(1)

local center = vec(pos1.x + 3, pos1.y, pos1.z + 2)

worldedit.cube(center, 6, 5, 4, testnode1, true)

check.filled(vector.add(pos1, vec(1,1,1)), vector.subtract(pos2, vec(1,1,1)), air)
check.filled2({
{ vecw("x", pos2.x, pos1), pos2 },
{ vecw("y", pos2.y, pos1), pos2 },
{ vecw("z", pos2.z, pos1), pos2 },
{ pos1, vecw("x", pos1.x, pos2) },
{ pos1, vecw("y", pos1.y, pos2) },
{ pos1, vecw("z", pos1.z, pos2) },
}, testnode1)
check.filled2(m, air)
end)


0 comments on commit 456ce8c

Please sign in to comment.