Minetest-WorldEditAdditions/.tests/parse/table/makeset.test.lua

33 lines
804 B
Lua
Raw Normal View History

2022-09-24 12:45:50 +00:00
local makeset = require("worldeditadditions_core.utils.table.makeset")
describe("table.makeset", function()
it("should work with a single item", function()
local result = makeset({ "apples" })
assert.are.same(
{ apples = true },
result
)
end)
it("should work with 2 items", function()
local result = makeset({ "apples", "orange" })
assert.are.same(
{ apples = true, orange = true },
result
)
end)
it("should work with duplicate items", function()
local result = makeset({ "apples", "apples" })
assert.are.same(
{ apples = true },
result
)
end)
it("should work with duplicate items and non-duplicate items", function()
local result = makeset({ "apples", "oranges", "apples" })
assert.are.same(
{ apples = true, oranges = true },
result
)
end)
end)