mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-26 09:03:01 +00:00
Starbeamrainbowlabs
06f90edd46
Let's go slow, one function at a time, from nuts and bolts gradually up to full files
61 lines
2.3 KiB
Lua
61 lines
2.3 KiB
Lua
local weaschem = require("worldeditadditions_core.utils.parse.file.weaschem")
|
|
|
|
|
|
describe("parse.file.weaschem.parse_vector3", function()
|
|
it("should parse a valid positive integer vector3", function()
|
|
local a = { x = 4, y = 5, z = 6 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(true, success)
|
|
assert.are.same("SUCCESS", code)
|
|
assert.are.same(a, result)
|
|
end)
|
|
it("should parse a valid negative integer vector3", function()
|
|
local a = { x = -4, y = -5, z = -6 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(true, success)
|
|
assert.are.same("SUCCESS", code)
|
|
assert.are.same(a, result)
|
|
end)
|
|
it("should get upset if there's no x coordinate", function()
|
|
local a = { y = -5, z = -6 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_NO_X", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
it("should get upset if there's no y coordinate", function()
|
|
local a = { x = -5, z = -6 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_NO_Y", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
it("should get upset if there's no z coordinate", function()
|
|
local a = { x = -5, y = -6 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_NO_Z", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
it("should get upset if x is not an int", function()
|
|
local a = { x = -5.1, y = -6, z = 0 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_X_FLOAT", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
it("should get upset if y is not an int", function()
|
|
local a = { x = -5, y = -6.4, z = 0 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_Y_FLOAT", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
it("should get upset if z is not an int", function()
|
|
local a = { x = -5, y = -6, z = 0.001 }
|
|
local success, code, result = weaschem.parse_vector3(a)
|
|
assert.are.same(false, success)
|
|
assert.are.same("VECTOR3_Z_FLOAT", code)
|
|
assert.are.same("string", type(result))
|
|
end)
|
|
end)
|