aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2012-01-13 22:49:01 +1030
committerMark Pulford <mark@kyne.com.au>2012-03-04 18:54:34 +1030
commitcb272bab61784d8d69dee20d27d7b6a9ca8df11a (patch)
tree2f505bcee41fe8d854faf01e63fdf06d4e1182d0 /tests
parentd2108a207511352f32f21a91bdfc5f835e0460de (diff)
downloadlua-cjson-cb272bab61784d8d69dee20d27d7b6a9ca8df11a.tar.gz
lua-cjson-cb272bab61784d8d69dee20d27d7b6a9ca8df11a.tar.bz2
lua-cjson-cb272bab61784d8d69dee20d27d7b6a9ca8df11a.zip
Add tests for decode_max_depth()
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua18
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 @@
1#!/usr/bin/env lua 1#!/usr/bin/env lua
2 2
3-- CJSON tests 3-- Lua CJSON tests
4-- 4--
5-- Mark Pulford <mark@kyne.com.au> 5-- Mark Pulford <mark@kyne.com.au>
6-- 6--
@@ -163,8 +163,6 @@ local encode_error_tests = {
163 end, 163 end,
164} 164}
165 165
166local json_nested = string.rep("[", 100000) .. string.rep("]", 100000)
167
168local decode_error_tests = { 166local decode_error_tests = {
169 { json.decode, { '\0"\0"' }, 167 { json.decode, { '\0"\0"' },
170 false, { "JSON parser does not support UTF-16 or UTF-32" } }, 168 false, { "JSON parser does not support UTF-16 or UTF-32" } },
@@ -186,8 +184,18 @@ local decode_error_tests = {
186 false, { "Expected value but found invalid number at character 1" } }, 184 false, { "Expected value but found invalid number at character 1" } },
187 { json.decode, { '[ 0.4eg10 ]' }, 185 { json.decode, { '[ 0.4eg10 ]' },
188 false, { "Expected comma or array end but found invalid token at character 6" } }, 186 false, { "Expected comma or array end but found invalid token at character 6" } },
189 { json.decode, { json_nested }, 187 function ()
190 false, { "Too many nested data structures" } } 188 json.decode_max_depth(5)
189 return "Setting decode_max_depth(5)"
190 end,
191 { json.decode, { '[[[[[ "nested" ]]]]]' },
192 true, { {{{{{ "nested" }}}}} } },
193 { json.decode, { '[[[[[[ "nested" ]]]]]]' },
194 false, { "Too many nested data structures" } },
195 function ()
196 json.decode_max_depth(1000)
197 return "Setting decode_max_depth(1000)"
198 end
191} 199}
192 200
193local escape_tests = { 201local escape_tests = {