mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Escape bad unicode in json tests (#480)
This commit is contained in:
parent
594615a0ff
commit
9308463b0f
8 changed files with 6266 additions and 430 deletions
File diff suppressed because one or more lines are too long
245
test/tool/net/samples/JSONTestSuite-fail1.lua
Normal file
245
test/tool/net/samples/JSONTestSuite-fail1.lua
Normal file
|
@ -0,0 +1,245 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
|
||||
--
|
||||
-- MIT License
|
||||
--
|
||||
-- Copyright (c) 2016 Nicolas Seriot
|
||||
--
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in all
|
||||
-- copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_no-colon.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_value.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a": ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_key.json
|
||||
assert(false == pcall(DecodeJson, [[ {:"b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_colon.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a" b} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x22\xb9\x22\x3a\x22\x30\x22\x2c\x7d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_key_with_single_quotes.json
|
||||
assert(false == pcall(DecodeJson, [[ {key: 'value'} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_garbage_at_end.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a":"a" 123} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_emoji.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\xf0\x9f\x87\xa8\xf0\x9f\x87\xad\x7d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_bracket_key.json
|
||||
assert(false == pcall(DecodeJson, [[ {[: "x"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_with_alpha_char.json
|
||||
assert(false == pcall(DecodeJson, [[ [1.8011670033376514H-308] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_with_alpha.json
|
||||
assert(false == pcall(DecodeJson, [[ [1.2a-3] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_starting_with_dot.json
|
||||
assert(false == pcall(DecodeJson, [[ [.123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_real_with_invalid_utf8_after_e.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x31\x65\xe5\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_real_garbage_after_e.json
|
||||
assert(false == pcall(DecodeJson, [[ [1ea] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_neg_with_garbage_at_end.json
|
||||
assert(false == pcall(DecodeJson, [[ [-1x] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_neg_real_without_int_part.json
|
||||
assert(false == pcall(DecodeJson, [[ [-.123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_minus_sign_with_trailing_garbage.json
|
||||
assert(false == pcall(DecodeJson, [[ [-foo] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_minus_infinity.json
|
||||
assert(false == pcall(DecodeJson, [[ [-Infinity] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-int.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x30\xe5\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-exponent.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x31\x65\x31\xe5\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-bigger-int.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x31\x32\x33\xe5\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-negative-real.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x2d\x31\x32\x33\x2e\x31\x32\x33\x66\x6f\x6f\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid+-.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x30\x65\x2b\x2d\x31\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_infinity.json
|
||||
assert(false == pcall(DecodeJson, [[ [Infinity] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_hex_2_digits.json
|
||||
assert(false == pcall(DecodeJson, [[ [0x42] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_hex_1_digit.json
|
||||
assert(false == pcall(DecodeJson, [[ [0x1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_expression.json
|
||||
assert(false == pcall(DecodeJson, [[ [1+2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_U+FF11_fullwidth_digit_one.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xef\xbc\x91\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_NaN.json
|
||||
assert(false == pcall(DecodeJson, [[ [NaN] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_Inf.json
|
||||
assert(false == pcall(DecodeJson, [[ [Inf] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_9.e+.json
|
||||
assert(false == pcall(DecodeJson, [[ [9.e+] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1eE2.json
|
||||
assert(false == pcall(DecodeJson, [[ [1eE2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e.json
|
||||
assert(false == pcall(DecodeJson, [[ [1.0e] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e-.json
|
||||
assert(false == pcall(DecodeJson, [[ [1.0e-] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e+.json
|
||||
assert(false == pcall(DecodeJson, [[ [1.0e+] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0e.json
|
||||
assert(false == pcall(DecodeJson, [[ [0e] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0e+.json
|
||||
assert(false == pcall(DecodeJson, [[ [0e+] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0_capital_E.json
|
||||
assert(false == pcall(DecodeJson, [[ [0E] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0_capital_E+.json
|
||||
assert(false == pcall(DecodeJson, [[ [0E+] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.3e.json
|
||||
assert(false == pcall(DecodeJson, [[ [0.3e] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.3e+.json
|
||||
assert(false == pcall(DecodeJson, [[ [0.3e+] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.1.2.json
|
||||
assert(false == pcall(DecodeJson, [[ [0.1.2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_.2e-3.json
|
||||
assert(false == pcall(DecodeJson, [[ [.2e-3] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_.-1.json
|
||||
assert(false == pcall(DecodeJson, [[ [.-1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-NaN.json
|
||||
assert(false == pcall(DecodeJson, [[ [-NaN] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-1.0..json
|
||||
assert(false == pcall(DecodeJson, [[ [-1.0.] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_+Inf.json
|
||||
assert(false == pcall(DecodeJson, [[ [+Inf] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_+1.json
|
||||
assert(false == pcall(DecodeJson, [[ [+1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_++.json
|
||||
assert(false == pcall(DecodeJson, [[ [++1234] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_true.json
|
||||
assert(false == pcall(DecodeJson, [[ [tru] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_null.json
|
||||
assert(false == pcall(DecodeJson, [[ [nul] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_false.json
|
||||
assert(false == pcall(DecodeJson, [[ [fals] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_with_object_inside.json
|
||||
assert(false == pcall(DecodeJson, [[ [{} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_with_new_lines.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[1,
|
||||
1
|
||||
,1 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_trailing_comma.json
|
||||
assert(false == pcall(DecodeJson, [[ [1, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed.json
|
||||
assert(false == pcall(DecodeJson, [[ ["" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_star_inside.json
|
||||
assert(false == pcall(DecodeJson, [[ [*] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_spaces_vertical_tab_formfeed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\xb\x61\x22\x5c\x66\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_newlines_unclosed.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
["a",
|
||||
4
|
||||
,1, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_items_separated_by_semicolon.json
|
||||
assert(false == pcall(DecodeJson, [[ [1:2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_invalid_utf8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xff\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_incomplete_invalid_value.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x78 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_incomplete.json
|
||||
assert(false == pcall(DecodeJson, [[ ["x" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_colon_instead_of_comma.json
|
||||
assert(false == pcall(DecodeJson, [[ ["": 1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_a_invalid_utf8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x61\xe5\x5d ]]))
|
158
test/tool/net/samples/JSONTestSuite-fail2.lua
Normal file
158
test/tool/net/samples/JSONTestSuite-fail2.lua
Normal file
|
@ -0,0 +1,158 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
|
||||
--
|
||||
-- MIT License
|
||||
--
|
||||
-- Copyright (c) 2016 Nicolas Seriot
|
||||
--
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in all
|
||||
-- copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_whitespace_formfeed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xc\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_whitespace_U+2060_word_joiner.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xe2\x81\xa0\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unicode-identifier.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \xc3\xa5 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_object.json
|
||||
assert(false == pcall(DecodeJson, [[ {"asd":"asd" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_unfinished_true.json
|
||||
assert(false == pcall(DecodeJson, [[ [ false, tru ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_unfinished_false.json
|
||||
assert(false == pcall(DecodeJson, [[ [ true, fals ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_partial_null.json
|
||||
assert(false == pcall(DecodeJson, [[ [ false, nul ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array.json
|
||||
assert(false == pcall(DecodeJson, [[ [1 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_uescaped_LF_before_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x5c\x75\x30\x30\x30\x41\x22\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_single_star.json
|
||||
assert(false == pcall(DecodeJson, [[ * ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_single_eacute.json
|
||||
assert(false == pcall(DecodeJson, [[ é ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_open.json
|
||||
assert(false == pcall(DecodeJson, [[ ["\{["\{["\{["\{ ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_string_with_apostrophes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x27\x61\x27 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_open_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x22\x61 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_open_array.json
|
||||
assert(false == pcall(DecodeJson, [[ {[ ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_comma.json
|
||||
assert(false == pcall(DecodeJson, [[ {, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_close_array.json
|
||||
assert(false == pcall(DecodeJson, [[ {] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object.json
|
||||
assert(false == pcall(DecodeJson, [[ { ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x61\x22 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_open_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x61 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_open_object.json
|
||||
assert(false == pcall(DecodeJson, [[ [{ ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_comma.json
|
||||
assert(false == pcall(DecodeJson, [[ [, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_apostrophe.json
|
||||
assert(false == pcall(DecodeJson, [[ [' ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_with_comment.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a":/*comment*/"b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_unclosed_no_value.json
|
||||
assert(false == pcall(DecodeJson, [[ {"": ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_null-byte-outside-string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x0\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_lone-open-bracket.json
|
||||
assert(false == pcall(DecodeJson, [[ [ ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_lone-invalid-utf-8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \xe5 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_incomplete_UTF8_BOM.json
|
||||
assert(false == pcall(DecodeJson, [[ ï»{} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_comma_instead_of_closing_brace.json
|
||||
assert(false == pcall(DecodeJson, [[ {"x": true, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_capitalized_True.json
|
||||
assert(false == pcall(DecodeJson, [[ [True] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_ascii-unicode-identifier.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x61\xc3\xa5 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_with_unclosed_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x61\x73\x64\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_angle_bracket_null.json
|
||||
assert(false == pcall(DecodeJson, [[ [<null>] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_angle_bracket_..json
|
||||
assert(false == pcall(DecodeJson, [[ <.> ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_UTF8_BOM_no_data.json
|
||||
assert(false == pcall(DecodeJson, [[  ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_U+2060_word_joined.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xe2\x81\xa0\x5d ]]))
|
||||
|
||||
|
5667
test/tool/net/samples/JSONTestSuite-fail3.lua
Normal file
5667
test/tool/net/samples/JSONTestSuite-fail3.lua
Normal file
File diff suppressed because it is too large
Load diff
173
test/tool/net/samples/JSONTestSuite-fail4.lua
Normal file
173
test/tool/net/samples/JSONTestSuite-fail4.lua
Normal file
|
@ -0,0 +1,173 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
|
||||
--
|
||||
-- MIT License
|
||||
--
|
||||
-- Copyright (c) 2016 Nicolas Seriot
|
||||
--
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in all
|
||||
-- copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
-- these test cases are prefixed with n_
|
||||
-- ljson should reject all of them as invalid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_with_trailing_garbage.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x22\x22\x78 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unicode_CapitalU.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x22\x5c\x55\x41\x36\x36\x44\x22 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_tab.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x9\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_newline.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x6e\x65\x77\xa\x6c\x69\x6e\x65\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_ctrl_char.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x61\x0\x61\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_start_escape_unclosed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_string_no_double_quotes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x61\x62\x63 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_quote.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x27\x73\x69\x6e\x67\x6c\x65\x20\x71\x75\x6f\x74\x65\x27\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_doublequote.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x22 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_no_quotes_with_bad_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x5c\x6e\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_leading_uescaped_thinspace.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x5c\x75\x30\x30\x32\x30\x22\x61\x73\x64\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_utf8_after_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\xe5\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_unicode_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x71\x71\x71\x71\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_backslash_esc.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x61\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid-utf-8-in-escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\xe5\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_surrogate_escape_invalid.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x44\x38\x30\x30\x5c\x78\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_surrogate.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x33\x34\x5c\x75\x44\x64\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_escaped_character.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x30\x30\x41\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_emoji.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\xf0\x9f\x8c\x80\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_ctrl_char_tab.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x9\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_backslash_bad.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x5c\x5c\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escape_x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x78\x30\x30\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_backslash_00.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x0\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_accentuated_char_no_quotes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\xc3\xa9\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x78\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x22\x5d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_with_single_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x20\x22\x66\x6f\x6f\x22\x20\x3a\x20\x22\x62\x61\x72\x22\x2c\x20\x22\x61\x22\x20\x7d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_unterminated-value.json
|
||||
assert(false == pcall(DecodeJson, [[ {"a":"a ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_unquoted_key.json
|
||||
assert(false == pcall(DecodeJson, [[ {a: "b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_single_quote.json
|
||||
assert(false == pcall(DecodeJson, [[ {'a':0} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_repeated_null_null.json
|
||||
assert(false == pcall(DecodeJson, [[ {null:null,null:null} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_non_string_key_but_huge_number_instead.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x39\x39\x39\x39\x45\x39\x39\x39\x39\x3a\x31\x7d ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_non_string_key.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, [[ \x7b\x31\x3a\x31\x7d ]]))
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
--
|
||||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
|
@ -67,6 +67,9 @@ assert(true == pcall(DecodeJson, [[ ["aa"] ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_utf8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["€𝄞"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_escaped_double_quote.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0022"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFFFE"] ]]))
|
||||
|
||||
|
@ -85,27 +88,24 @@ assert(true == pcall(DecodeJson, [[ ["\uD83F\uDFFE"] ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+10FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uDBFF\uDFFE"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uA66D"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_escaped_double_quote.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0022"] ]]))
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_2.json
|
||||
assert(true == pcall(DecodeJson, [[ ["⍂㈴⍂"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicodeEscapedBackslash.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u005C"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_2.json
|
||||
assert(true == pcall(DecodeJson, [[ ["⍂㈴⍂"] ]]))
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uA66D"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unescaped_char_delete.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uEscape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0061\u30af\u30EA\u30b9"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uescaped_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["new\u000Aline"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uEscape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0061\u30af\u30EA\u30b9"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_u+2029_par_sep.json
|
||||
assert(true == pcall(DecodeJson, [[ ["
"] ]]))
|
||||
|
||||
|
@ -205,9 +205,6 @@ assert(true == pcall(DecodeJson, [[ {"a":[]} ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_long_strings.json
|
||||
assert(true == pcall(DecodeJson, [[ {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf", "dfg":"fgh"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_extreme_numbers.json
|
||||
assert(true == pcall(DecodeJson, [[ { "min": -1.0e+28, "max": 1.0e+28 } ]]))
|
||||
|
||||
|
@ -220,15 +217,18 @@ assert(true == pcall(DecodeJson, [[ {"":0} ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ {} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"c"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key_and_value.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"c"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_basic.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf", "dfg":"fgh"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_simple_real.json
|
||||
assert(true == pcall(DecodeJson, [[ [123.456789] ]]))
|
||||
|
||||
|
@ -268,9 +268,6 @@ assert(true == pcall(DecodeJson, [[ [-123] ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_minus_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number.json
|
||||
assert(true == pcall(DecodeJson, [[ [123e65] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_int_with_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [20e1] ]]))
|
||||
|
||||
|
@ -286,6 +283,9 @@ assert(true == pcall(DecodeJson, [[ [0e1] ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_0e+1.json
|
||||
assert(true == pcall(DecodeJson, [[ [0e+1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number.json
|
||||
assert(true == pcall(DecodeJson, [[ [123e65] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_trailing_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [2] ]]))
|
||||
|
||||
|
@ -312,12 +312,12 @@ assert(true == pcall(DecodeJson, [[ [false] ]]))
|
|||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_ending_with_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty-string.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ [] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty-string.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_arraysWithSpaces.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(true == pcall(DecodeJson, [[
|
||||
|
|
Loading…
Reference in a new issue