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

40 lines
882 B
Lua
Raw Normal View History

2022-09-19 02:18:48 +02:00
local Vector3 = require("worldeditadditions_core.utils.vector3")
describe("Vector3.__tostring", function()
it("should stringify a Vector3", function()
local a = Vector3.new(3, 4, 5)
assert.are.same(
2021-06-26 15:40:14 +02:00
"(3, 4, 5)",
a:__tostring()
)
end)
it("should implicitly stringify a Vector3", function()
local a = Vector3.new(3, 4, 5)
assert.are.same(
2021-06-26 15:40:14 +02:00
"(3, 4, 5)",
tostring(a)
)
end)
it("should implicitly stringify another Vector3", function()
local a = Vector3.new(55, 77, 22)
assert.are.same(
2021-06-26 15:40:14 +02:00
"(55, 77, 22)",
tostring(a)
)
end)
it("should handle negative numbers", function()
local a = Vector3.new(-1, -2, -3)
assert.are.same(
2021-06-26 15:40:14 +02:00
"(-1, -2, -3)",
tostring(a)
)
end)
it("should handle a mix of positive and negative numbers", function()
local a = Vector3.new(-7, 2, -99)
assert.are.same(
2021-06-26 15:40:14 +02:00
"(-7, 2, -99)",
tostring(a)
)
end)
end)