added more tests from recent nst's JSONTestSuite

This commit is contained in:
Niels Lohmann 2018-05-17 10:10:01 +02:00
parent 567fe9b7a0
commit 4639bb2c8f
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
321 changed files with 813 additions and 0 deletions

View File

@ -0,0 +1,21 @@
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.

View File

@ -0,0 +1,55 @@
# JSON Parsing Test Suite
A comprehensive test suite for RFC 8259 compliant JSON parsers
This repository was created as an appendix to the article [Parsing JSON is a Minefield 💣](http://seriot.ch/parsing_json.php).
**/parsers/**
This directory contains several parsers and tiny wrappers to turn the parsers into JSON validators, by returning a specific value.
- `0` the parser did accept the content
- `1` the parser did reject the content
- `>1` the process did crash
- `timeout` happens after 5 seconds
**/test\_parsing/**
The name of these files tell if their contents should be accepted or rejected.
- `y_` content must be accepted by parsers
- `n_` content must be rejected by parsers
- `i_` parsers are free to accept or reject content
**/test\_transform/**
These files contain weird structures and characters that parsers may understand differently, eg:
- huge numbers
- dictionaries with similar keys
- NULL characters
- escaped invalid strings
These files were used to produce `results/transform.html`.
**/run_tests.py**
Run all parsers with all files:
$ python3 run_tests.py
Run all parsers with a specific file:
$ python3 run_tests.py file.json
Run specific parsers with all files:
$ echo '["Python 2.7.10", "Python 3.5.2"]' > python_only.json
$ python3 run_tests.py --filter=python_only.json
The script writes logs in `results/logs.txt`.
The script then reads `logs.txt` and generates `results/parsing.html`.
**/results/**
<img src="results/pruned_results.png" alt="JSON Parsing Tests" />

View File

@ -0,0 +1 @@
[123.456e-789]

View File

@ -0,0 +1 @@
[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]

View File

@ -0,0 +1 @@
[-1e+9999]

View File

@ -0,0 +1 @@
[1.5e+9999]

View File

@ -0,0 +1 @@
[-123123e100000]

View File

@ -0,0 +1 @@
[123123e100000]

View File

@ -0,0 +1 @@
[123e-10000000]

View File

@ -0,0 +1 @@
[-123123123123123123123123123123]

View File

@ -0,0 +1 @@
[100000000000000000000]

View File

@ -0,0 +1 @@
[-237462374673276894279832749832423479823246327846]

View File

@ -0,0 +1 @@
{"\uDFAA":0}

View File

@ -0,0 +1 @@
["譌・ム淫"]

View File

@ -0,0 +1 @@
["<22><><EFBFBD>"]

View File

@ -0,0 +1 @@
["\uDd1ea"]

View File

@ -0,0 +1 @@
["\uD800\uD800\n"]

View File

@ -0,0 +1 @@
["\ud800"]

View File

@ -0,0 +1 @@
["\ud800abc"]

View File

@ -0,0 +1 @@
["<22>"]

View File

@ -0,0 +1 @@
["\uDd1e\uD834"]

View File

@ -0,0 +1 @@
["И"]

View File

@ -0,0 +1 @@
["<22><><EFBFBD><EFBFBD>"]

View File

@ -0,0 +1 @@
["<22>ソソソソ"]

View File

@ -0,0 +1 @@
["<22>€€€€"]

View File

@ -0,0 +1 @@
["<22><>"]

View File

@ -0,0 +1 @@
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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0 +1 @@
[<EFBFBD>]

View File

@ -0,0 +1 @@
[,]

View File

@ -0,0 +1 @@
[-]

View File

@ -0,0 +1 @@
[ , ""]

View File

@ -0,0 +1,3 @@
["a",
4
,1,

View File

@ -0,0 +1 @@
[1,]

View File

@ -0,0 +1 @@
[*]

View File

@ -0,0 +1 @@
[""

View File

@ -0,0 +1 @@
[fals]

View File

@ -0,0 +1 @@
[nul]

View File

@ -0,0 +1 @@
[tru]

View File

@ -0,0 +1 @@
[++1234]

View File

@ -0,0 +1 @@
[+1]

View File

@ -0,0 +1 @@
[+Inf]

View File

@ -0,0 +1 @@
[-01]

View File

@ -0,0 +1 @@
[-1.0.]

View File

@ -0,0 +1 @@
[-2.]

View File

@ -0,0 +1 @@
[-NaN]

View File

@ -0,0 +1 @@
[.-1]

View File

@ -0,0 +1 @@
[.2e-3]

View File

@ -0,0 +1 @@
[0.1.2]

View File

@ -0,0 +1 @@
[0.3e+]

View File

@ -0,0 +1 @@
[0.3e]

View File

@ -0,0 +1 @@
[0.e1]

View File

@ -0,0 +1 @@
[0E+]

View File

@ -0,0 +1 @@
[0E]

View File

@ -0,0 +1 @@
[0e+]

View File

@ -0,0 +1 @@
[0e]

View File

@ -0,0 +1 @@
[1.0e+]

View File

@ -0,0 +1 @@
[1.0e-]

View File

@ -0,0 +1 @@
[1.0e]

View File

@ -0,0 +1 @@
[1 000.0]

View File

@ -0,0 +1 @@
[1eE2]

View File

@ -0,0 +1 @@
[2.e+3]

View File

@ -0,0 +1 @@
[2.e-3]

View File

@ -0,0 +1 @@
[2.e3]

View File

@ -0,0 +1 @@
[9.e+]

View File

@ -0,0 +1 @@
[Inf]

View File

@ -0,0 +1 @@
[NaN]

View File

@ -0,0 +1 @@
[1+2]

View File

@ -0,0 +1 @@
[0x1]

View File

@ -0,0 +1 @@
[0x42]

View File

@ -0,0 +1 @@
[Infinity]

Some files were not shown because too many files have changed in this diff Show More