diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-08 23:34:17 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-08 23:34:17 +0930 |
commit | 1798471fcdd3425e7d2bafbd69048ff1165eb31e (patch) | |
tree | c3a27ebb41022bc2b765ebd6474ea56f8efb79b7 /tests/test.lua | |
parent | f59b3b671984d6a3bf7f7dd08512a89dd916a901 (diff) | |
download | lua-cjson-1798471fcdd3425e7d2bafbd69048ff1165eb31e.tar.gz lua-cjson-1798471fcdd3425e7d2bafbd69048ff1165eb31e.tar.bz2 lua-cjson-1798471fcdd3425e7d2bafbd69048ff1165eb31e.zip |
Add test for excessive nesting during encode
Diffstat (limited to 'tests/test.lua')
-rwxr-xr-x | tests/test.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua index 436b20c..10d8989 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -63,6 +63,9 @@ if not utf8_loaded then | |||
63 | end | 63 | end |
64 | local utf16_escaped = gen_utf16_escaped() | 64 | local utf16_escaped = gen_utf16_escaped() |
65 | local nested5 = {{{{{ "nested" }}}}} | 65 | local nested5 = {{{{{ "nested" }}}}} |
66 | local table_cycle = {} | ||
67 | local table_cycle2 = { table_cycle } | ||
68 | table_cycle[1] = table_cycle2 | ||
66 | 69 | ||
67 | local decode_simple_tests = { | 70 | local decode_simple_tests = { |
68 | { json.decode, { '"test string"' }, true, { "test string" } }, | 71 | { json.decode, { '"test string"' }, true, { "test string" } }, |
@@ -124,6 +127,8 @@ local encode_table_tests = { | |||
124 | 127 | ||
125 | { json.encode, { nested5 }, true, { '[ [ [ [ [ "nested" ] ] ] ] ]' } }, | 128 | { json.encode, { nested5 }, true, { '[ [ [ [ [ "nested" ] ] ] ] ]' } }, |
126 | { json.encode, { { nested5 } }, | 129 | { json.encode, { { nested5 } }, |
130 | false, { "Cannot serialise, excessive nesting (6)" } }, | ||
131 | { json.encode, { table_cycle }, | ||
127 | false, { "Cannot serialise, excessive nesting (6)" } } | 132 | false, { "Cannot serialise, excessive nesting (6)" } } |
128 | } | 133 | } |
129 | 134 | ||