From da9f578e86ab306cf5db581a8dc27e165ec6affd Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 24 Sep 2022 18:42:54 +0100 Subject: [PATCH] table_contains: write tests --- .tests/parse/table/table_contains.test.lua | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .tests/parse/table/table_contains.test.lua diff --git a/.tests/parse/table/table_contains.test.lua b/.tests/parse/table/table_contains.test.lua new file mode 100644 index 0000000..d8a88ca --- /dev/null +++ b/.tests/parse/table/table_contains.test.lua @@ -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)