diff options
author | Mark Pulford <mark@kyne.com.au> | 2012-01-13 16:19:01 +0400 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 12:24:34 +0400 |
commit | cb272bab61784d8d69dee20d27d7b6a9ca8df11a (patch) | |
tree | 2f505bcee41fe8d854faf01e63fdf06d4e1182d0 /tests | |
parent | d2108a207511352f32f21a91bdfc5f835e0460de (diff) |
Add tests for decode_max_depth()
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/test.lua b/tests/test.lua index a4ebafe..4b8525b 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env lua --- CJSON tests +-- Lua CJSON tests -- -- Mark Pulford <mark@kyne.com.au> -- @@ -163,8 +163,6 @@ local encode_error_tests = { end, } -local json_nested = string.rep("[", 100000) .. string.rep("]", 100000) - local decode_error_tests = { { json.decode, { '\0"\0"' }, false, { "JSON parser does not support UTF-16 or UTF-32" } }, @@ -186,8 +184,18 @@ local decode_error_tests = { false, { "Expected value but found invalid number at character 1" } }, { json.decode, { '[ 0.4eg10 ]' }, false, { "Expected comma or array end but found invalid token at character 6" } }, - { json.decode, { json_nested }, - false, { "Too many nested data structures" } } + function () + json.decode_max_depth(5) + return "Setting decode_max_depth(5)" + end, + { json.decode, { '[[[[[ "nested" ]]]]]' }, + true, { {{{{{ "nested" }}}}} } }, + { json.decode, { '[[[[[[ "nested" ]]]]]]' }, + false, { "Too many nested data structures" } }, + function () + json.decode_max_depth(1000) + return "Setting decode_max_depth(1000)" + end } local escape_tests = { |