1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00

Builtin: Optimize misc helpers (#12377)

Also add formspec_escape unit test
This commit is contained in:
Lars Müller 2022-05-27 21:40:38 +02:00 committed by GitHub
parent fe299e24d6
commit e8b2954586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 20 deletions

View file

@ -163,3 +163,11 @@ describe("table", function()
assert.equal(-1, table.indexof({"foo", "bar"}, "baz"))
end)
end)
describe("formspec_escape", function()
it("escapes", function()
assert.equal(nil, core.formspec_escape(nil))
assert.equal("", core.formspec_escape(""))
assert.equal("\\[Hello\\\\\\[", core.formspec_escape("[Hello\\["))
end)
end)