diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-07 03:48:58 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-07 03:48:58 +0930 |
commit | d75e1cb7f0418615e208f49c6209b7c144591f14 (patch) | |
tree | 318bbaa76d34472b956cc21e7128e2a322210693 /tests/test.lua | |
parent | 7befa3e83bd60f1b749d80420ee5189d095f4682 (diff) | |
download | lua-cjson-d75e1cb7f0418615e208f49c6209b7c144591f14.tar.gz lua-cjson-d75e1cb7f0418615e208f49c6209b7c144591f14.tar.bz2 lua-cjson-d75e1cb7f0418615e208f49c6209b7c144591f14.zip |
Add test to compare objects after decode/encode
Diffstat (limited to 'tests/test.lua')
-rwxr-xr-x | tests/test.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test.lua b/tests/test.lua index 9424e8f..3c8c404 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -122,11 +122,17 @@ local ascii2 = json.decode(json.encode(ascii)) | |||
122 | print("8bit clean encode/decode: " .. tostring(ascii1 ~= ascii2)) | 122 | print("8bit clean encode/decode: " .. tostring(ascii1 ~= ascii2)) |
123 | 123 | ||
124 | for i = 1, #arg do | 124 | for i = 1, #arg do |
125 | print(arg[i] .. " enc->dec..") | ||
126 | local obj1 = json.decode(file_load(arg[i])) | 125 | local obj1 = json.decode(file_load(arg[i])) |
127 | local obj2 = json.decode(json.encode(obj1)) | 126 | local obj2 = json.decode(json.encode(obj1)) |
128 | -- obj_compare(obj_json1, obj_json2) | 127 | if compare_values(obj, obj) then |
129 | print(".. unimplemented") | 128 | print(arg[i] .. ": PASS") |
129 | else | ||
130 | print(arg[i] .. ": FAIL") | ||
131 | print("== obj1 ==") | ||
132 | dump_value(obj1) | ||
133 | print("== obj2 ==") | ||
134 | dump_value(obj2) | ||
135 | end | ||
130 | end | 136 | end |
131 | 137 | ||
132 | -- vi:ai et sw=4 ts=4: | 138 | -- vi:ai et sw=4 ts=4: |