add tests for find_keys and hasitem

This commit is contained in:
Seth Barberee 2019-11-24 21:38:54 -06:00
parent 76f8c11776
commit 5d499db3d0
1 changed files with 21 additions and 0 deletions

View File

@ -42,6 +42,27 @@ describe("gears.table", function()
end) end)
end) end)
describe("table.find_keys", function()
it("nil argument", function()
local t = { "a", "b", c = "c", "d" }
local f = gtable.find_keys(t, function(k) return k == "c" end)
assert.is.same(f, {"c"})
end)
end)
describe("table.hasitem", function()
it("exist", function()
local t = {"a", "b", c = "c"}
local f = gtable.hasitem(t, "c")
assert.is.equal(f, "c")
end)
it("nil", function()
local t = {"a", "b"}
local f = gtable.hasitem(t, "c")
assert.is.equal(f, nil)
end)
end)
describe("table.join", function() describe("table.join", function()
it("nil argument", function() it("nil argument", function()
local t = gtable.join({"a"}, nil, {"b"}) local t = gtable.join({"a"}, nil, {"b"})