table_apply: write tests

This commit is contained in:
Starbeamrainbowlabs 2022-09-24 18:47:13 +01:00
parent da9f578e86
commit dfb24e679b
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -0,0 +1,48 @@
local apply = require("worldeditadditions_core.utils.table.table_apply")
describe("table.makeset", function()
it("should work", function()
local source = { apples = 4 }
local target = { oranges = 3 }
apply(source, target)
assert.are.same(
{ apples = 4, oranges = 3 },
target
)
end)
it("should overwrite values in target", function()
local source = { apples = 4 }
local target = { apples = 3 }
apply(source, target)
assert.are.same(
{ apples = 4 },
target
)
end)
it("should work with strings", function()
local source = { apples = "4" }
local target = { oranges = "3" }
apply(source, target)
assert.are.same(
{ apples = "4", oranges = "3" },
target
)
end)
it("should overwrite values in target with strings", function()
local source = { apples = "4" }
local target = { apples = "3" }
apply(source, target)
assert.are.same(
{ apples = "4" },
target
)
end)
end)