mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 23:42:59 +00:00
table_contains: write tests
This commit is contained in:
parent
8f03c6473b
commit
da9f578e86
1 changed files with 40 additions and 0 deletions
40
.tests/parse/table/table_contains.test.lua
Normal file
40
.tests/parse/table/table_contains.test.lua
Normal 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)
|
Loading…
Reference in a new issue