diff options
author | Mattes D <github@xoft.cz> | 2015-12-24 14:02:05 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-12-24 14:02:05 +0100 |
commit | a8dd39acd1b85bea6dca0f671b34cb2d75455f00 (patch) | |
tree | df5ae78ccf37e6f5826a1971aacedf5e159782db /Server/Plugins/Debuggers | |
parent | Merge pull request #2811 from cuberite/isblockfence (diff) | |
parent | Added a Json parser and serializer to Lua API. (diff) | |
download | cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar.gz cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar.bz2 cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar.lz cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar.xz cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.tar.zst cuberite-a8dd39acd1b85bea6dca0f671b34cb2d75455f00.zip |
Diffstat (limited to 'Server/Plugins/Debuggers')
-rw-r--r-- | Server/Plugins/Debuggers/Debuggers.lua | 28 | ||||
-rw-r--r-- | Server/Plugins/Debuggers/Info.lua | 8 |
2 files changed, 35 insertions, 1 deletions
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua index 2b80e15c8..0559a4ef8 100644 --- a/Server/Plugins/Debuggers/Debuggers.lua +++ b/Server/Plugins/Debuggers/Debuggers.lua @@ -1921,6 +1921,34 @@ end +function HandleConsoleTestJson(a_Split, a_EntireCmd) + LOG("Testing Json parsing...") + local t1 = cJson:Parse([[{"a": 1, "b": "2", "c": [3, "4", 5] }]]) + assert(t1.a == 1) + assert(t1.b == "2") + assert(t1.c[1] == 3) + assert(t1.c[2] == "4") + assert(t1.c[3] == 5) + + local t2, msg = cJson:Parse([[{"some": invalid, json}]]) + assert(t2 == nil) + assert(type(msg) == "string") + LOG("Error message returned: " .. msg) + + LOG("Json parsing test succeeded") + + LOG("Testing Json serializing...") + local s1 = cJson:Serialize({a = 1, b = "2", c = {3, "4", 5}}, {indentation = " "}) + LOG("Serialization result: " .. (s1 or "<nil>")) + LOG("Json serializing test succeeded") + + return true +end + + + + + function HandleConsoleTestTracer(a_Split, a_EntireCmd) -- Check required params: if not(a_Split[7]) then diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua index 8f5ef27df..f71ee5509 100644 --- a/Server/Plugins/Debuggers/Info.lua +++ b/Server/Plugins/Debuggers/Info.lua @@ -242,11 +242,17 @@ g_PluginInfo = HelpString = "Tests the world scheduling", }, + ["testjson"] = + { + Handler = HandleConsoleTestJson, + HelpString = "Tests the cJson parser and serializer", + }, + ["testtracer"] = { Handler = HandleConsoleTestTracer, HelpString = "Tests the cLineBlockTracer", - } + }, }, -- ConsoleCommands } -- g_PluginInfo |