table_contains: write tests

This commit is contained in:
Starbeamrainbowlabs 2022-09-24 18:42:54 +01:00
parent 8f03c6473b
commit da9f578e86
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -0,0 +1,40 @@
local contains = require("worldeditadditions_core.utils.table.table_contains")
describe("table.makeset", function()
it("should work with a string", function()
assert.are.same(
true,
contains({ "apples" }, "apples")
)
end)
it("should work with a number", function()
assert.are.same(
true,
contains({ 4 }, 4)
)
end)
it("should return false if a number doesn't exist", function()
assert.are.same(
false,
contains({ 5 }, 4)
)
end)
it("should work with a string and multiple items in the table", function()
assert.are.same(
true,
contains({ "yay", "apples", "cat" }, "apples")
)
end)
it("should return false if it doesn't exist", function()
assert.are.same(
false,
contains({ "yay" }, "orange")
)
end)
it("should return false if it doesn't exist wiith multiple items", function()
assert.are.same(
false,
contains({ "yay", "apples", "cat" }, "orange")
)
end)
end)