diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua index ac6419a..96b47ff 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -7,6 +7,7 @@ | |||
7 | -- Note: The output of this script is easier to read with "less -S" | 7 | -- Note: The output of this script is easier to read with "less -S" |
8 | 8 | ||
9 | local json = require "cjson" | 9 | local json = require "cjson" |
10 | local json_safe = require "cjson.safe" | ||
10 | local util = require "cjson.util" | 11 | local util = require "cjson.util" |
11 | 12 | ||
12 | local function gen_raw_octets() | 13 | local function gen_raw_octets() |
@@ -386,6 +387,19 @@ local cjson_tests = { | |||
386 | { "Check encode_sparse_array()", | 387 | { "Check encode_sparse_array()", |
387 | function (...) return json.encode_sparse_array(...) end, { }, | 388 | function (...) return json.encode_sparse_array(...) end, { }, |
388 | true, { false, 2, 10 } }, | 389 | true, { false, 2, 10 } }, |
390 | |||
391 | { "Encode (safe) simple value", | ||
392 | json_safe.encode, { true }, | ||
393 | true, { "true" } }, | ||
394 | { "Encode (safe) argument validation [throw error]", | ||
395 | json_safe.encode, { "arg1", "arg2" }, | ||
396 | false, { "bad argument #1 to '?' (expected 1 argument)" } }, | ||
397 | { "Decode (safe) error generation", | ||
398 | json_safe.decode, { "Oops" }, | ||
399 | true, { nil, "Expected value but found invalid token at character 1" } }, | ||
400 | { "Decode (safe) error generation after new()", | ||
401 | function(...) return json_safe.new().decode(...) end, { "Oops" }, | ||
402 | true, { nil, "Expected value but found invalid token at character 1" } }, | ||
389 | } | 403 | } |
390 | 404 | ||
391 | print(("==> Testing Lua CJSON version %s\n"):format(json._VERSION)) | 405 | print(("==> Testing Lua CJSON version %s\n"):format(json._VERSION)) |