Minetest-WorldEditAdditions/.tests/Vector3/floor.test.lua

36 lines
795 B
Lua
Raw Normal View History

2022-09-19 00:18:48 +00:00
local Vector3 = require("worldeditadditions_core.utils.vector3")
2021-06-26 13:19:18 +00:00
describe("Vector3.floor", function()
it("should floor a positive vector", function()
local a = Vector3.new(3.1, 4.75, 5.9)
assert.are.same(
2021-06-26 13:40:14 +00:00
Vector3.new(3, 4, 5),
a:floor()
2021-06-26 13:19:18 +00:00
)
end)
it("should floor a negative vector", function()
local a = Vector3.new(-3.1, -4.2, -5.3)
assert.are.same(
2021-06-26 13:40:14 +00:00
Vector3.new(-4, -5, -6),
a:floor()
2021-06-26 13:19:18 +00:00
)
end)
it("should work with integers", function()
local a = Vector3.new(3, 4, 5)
assert.are.same(
2021-06-26 13:40:14 +00:00
Vector3.new(3, 4, 5),
a:floor()
2021-06-26 13:19:18 +00:00
)
end)
it("should return a new Vector3 instance", function()
local a = Vector3.new(3.1, 4.7, 5.99999)
local result = a:floor()
assert.are.same(
2021-06-26 13:40:14 +00:00
Vector3.new(3, 4, 5),
result
2021-06-26 13:19:18 +00:00
)
assert.are_not.equal(result, a)
end)
end)