mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Add more json tests for ljson (#478)
This commit is contained in:
parent
11a1c62d11
commit
594615a0ff
43 changed files with 961 additions and 203 deletions
90
test/tool/net/samples/jsonorg-lenient.lua
Normal file
90
test/tool/net/samples/jsonorg-lenient.lua
Normal file
|
@ -0,0 +1,90 @@
|
|||
-- json.org says the following test cases should be
|
||||
-- considered as invalid JSON, but ljson.c is lenient.
|
||||
-- we run these tests anyway just to ensure that
|
||||
-- no segfaults occurs while parsing these cases
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail4.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "extra comma",]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail5.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "double extra comma",,]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail6.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ , "<-- missing value"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail7.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "Comma after the close"] ,
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail8.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "Extra close"] ]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail9.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Extra comma": true,}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail19.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Missing colon" null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail20.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Double colon":: null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail21.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Comma instead of colon", null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail10.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Extra value after close": true} "misplaced quoted value"
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail25.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ " tab character in string "]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail26.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "tab\ character\ in\ string\ "]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail27.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "line
|
||||
break"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail28.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "line\
|
||||
break"]
|
||||
]]))
|
Loading…
Add table
Add a link
Reference in a new issue