mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Add Lua unit tests to builtin using busted (#9184)
This commit is contained in:
parent
6d472b1840
commit
1173ff0c13
7 changed files with 151 additions and 27 deletions
28
builtin/common/tests/serialize_spec.lua
Normal file
28
builtin/common/tests/serialize_spec.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
_G.core = {}
|
||||
|
||||
_G.setfenv = function() end
|
||||
|
||||
dofile("builtin/common/serialize.lua")
|
||||
|
||||
describe("serialize", function()
|
||||
it("works", function()
|
||||
local test_in = {cat={sound="nyan", speed=400}, dog={sound="woof"}}
|
||||
local test_out = core.deserialize(core.serialize(test_in))
|
||||
|
||||
assert.same(test_in, test_out)
|
||||
end)
|
||||
|
||||
it("handles characters", function()
|
||||
local test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"}
|
||||
local test_out = core.deserialize(core.serialize(test_in))
|
||||
assert.same(test_in, test_out)
|
||||
end)
|
||||
|
||||
it("handles recursive structures", function()
|
||||
local test_in = { hello = "world" }
|
||||
test_in.foo = test_in
|
||||
|
||||
local test_out = core.deserialize(core.serialize(test_in))
|
||||
assert.same(test_in, test_out)
|
||||
end)
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue