diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua index 0513d97..068a9f0 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
| @@ -333,6 +333,32 @@ local cjson_tests = { | |||
| 333 | json.decode, { [["\uDB00\uD"]] }, | 333 | json.decode, { [["\uDB00\uD"]] }, |
| 334 | false, { "Expected value but found invalid unicode escape code at character 2" } }, | 334 | false, { "Expected value but found invalid unicode escape code at character 2" } }, |
| 335 | 335 | ||
| 336 | -- Test comments | ||
| 337 | { 'Set decode_allow_comments(true)', | ||
| 338 | json.decode_allow_comments, { true }, true, { true } }, | ||
| 339 | { "Decode single-line comment", | ||
| 340 | json.decode, { '{//comment\n}' }, true, { {} } }, | ||
| 341 | { "Decode single-line comment with windows newline", | ||
| 342 | json.decode, { '{//comment\r\n}' }, true, { {} } }, | ||
| 343 | { "Decode single-line comment after string value", | ||
| 344 | json.decode, { '"test // /* */ string"//comment' }, true, { "test // /* */ string" } }, | ||
| 345 | { "Decode multi-line comment", | ||
| 346 | json.decode, { '{/* A multi-line\ncomment*/}' }, true, { {} } }, | ||
| 347 | { "Decode multi-line comment before colon", | ||
| 348 | json.decode, { '{"a" /* Comment */: 1}' }, true, { { a = 1 } } }, | ||
| 349 | { "Decode multi-line comment after colon", | ||
| 350 | json.decode, { '{"a": /* Comment */ 1}' }, true, { { a = 1 } } }, | ||
| 351 | { "Decode multiple comments in a row", | ||
| 352 | json.decode, { '/*first*//*second*/{}' }, true, { {} } }, | ||
| 353 | { "Decode unclosed multi-line comment [throw error]", | ||
| 354 | json.decode, { '{}/*Unclosed' }, | ||
| 355 | false, { "Expected the end but found unclosed multi-line comment at character 13" } }, | ||
| 356 | { "Decode comment inside number [throw error]", | ||
| 357 | json.decode, { '{"a":1/*x*/0}' }, | ||
| 358 | false, { "Expected comma or object end but found T_INTEGER at character 12" } }, | ||
| 359 | { 'Set decode_allow_comments(false)', | ||
| 360 | json.decode_allow_comments, { false }, true, { false } }, | ||
| 361 | |||
| 336 | -- Test indenting | 362 | -- Test indenting |
| 337 | { 'Set encode_indent(" ")', | 363 | { 'Set encode_indent(" ")', |
| 338 | json.encode_indent, { " " }, true, { " " } }, | 364 | json.encode_indent, { " " }, true, { " " } }, |
