From 8f03c6473bd3cf91a8fc11de7fb5bf5e6d713826 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 24 Sep 2022 13:45:50 +0100 Subject: [PATCH] test makeset --- .tests/parse/table/makeset.test.lua | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .tests/parse/table/makeset.test.lua diff --git a/.tests/parse/table/makeset.test.lua b/.tests/parse/table/makeset.test.lua new file mode 100644 index 0000000..952879c --- /dev/null +++ b/.tests/parse/table/makeset.test.lua @@ -0,0 +1,32 @@ +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)