mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-04 13:03:59 +01:00
tests/weaschem: okay, here we go: parse_vector3
Let's go slow, one function at a time, from nuts and bolts gradually up to full files
This commit is contained in:
parent
3faaaa5283
commit
06f90edd46
61
.tests/parse/file/weaschem_vector3.test.lua
Normal file
61
.tests/parse/file/weaschem_vector3.test.lua
Normal file
@ -0,0 +1,61 @@
|
||||
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)
|
Loading…
Reference in New Issue
Block a user