Merge branch 'feature/jsontestsuite' into develop

This commit is contained in:
Niels 2016-11-02 17:03:17 +01:00
commit 79015b9d0a
322 changed files with 1247 additions and 280 deletions

View file

@ -75,7 +75,7 @@ clang_sanitize: clean
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
$(RE2C) -W --utf-8 --encoding-policy fail --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
# pretty printer
pretty:

View file

@ -507,6 +507,11 @@ Thanks a lot for helping out!
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html#a2e26bd0b0168abb61f67ad5bcd5b9fa1) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html#a674de1ee73e6bf4843fc5dc1351fb726).
- As the exact type of a number is not defined in the [JSON specification](http://rfc7159.net/rfc7159), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
- The library supports **Unicode input** as follows:
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](http://rfc7159.net/rfc7159#rfc.section.8.1).
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors.
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
## Execute unit tests
@ -517,7 +522,7 @@ To compile and run the tests, you need to execute
$ make check
===============================================================================
All tests passed (8905169 assertions in 35 test cases)
All tests passed (8905479 assertions in 36 test cases)
```
Alternatively, you can use [CMake](https://cmake.org) and run

File diff suppressed because it is too large Load diff

View file

@ -7620,6 +7620,14 @@ class basic_json
{
// fill buffer
fill_line_buffer();
// skip UTF-8 byte-order mark
if (m_line_buffer.size() >= 3 and m_line_buffer.substr(0, 3) == "\xEF\xBB\xBF")
{
m_line_buffer[0] = ' ';
m_line_buffer[1] = ' ';
m_line_buffer[2] = ' ';
}
}
// switch off unwanted functions (due to pointer members)
@ -7792,8 +7800,8 @@ class basic_json
re2c:define:YYCURSOR = m_cursor;
re2c:define:YYLIMIT = m_limit;
re2c:define:YYMARKER = m_marker;
re2c:define:YYFILL = "fill_line_buffer()";
re2c:yyfill:parameter = 0;
re2c:define:YYFILL = "fill_line_buffer(@@); // LCOV_EXCL_LINE";
re2c:define:YYFILL:naked = 1;
re2c:indent:string = " ";
re2c:indent:top = 1;
re2c:labelprefix = "basic_json_parser_";
@ -7802,10 +7810,6 @@ class basic_json
ws = [ \t\n\r]+;
ws { continue; }
// ignore byte-order-mark
bom = "\xEF\xBB\xBF";
bom { continue; }
// structural characters
"[" { last_token_type = token_type::begin_array; break; }
"]" { last_token_type = token_type::end_array; break; }
@ -7845,10 +7849,10 @@ class basic_json
string { last_token_type = token_type::value_string; break; }
// end of file
"\000" { last_token_type = token_type::end_of_input; break; }
"\x00" { last_token_type = token_type::end_of_input; break; }
// anything else is an error
. { last_token_type = token_type::parse_error; break; }
* { last_token_type = token_type::parse_error; break; }
*/
}
@ -7883,7 +7887,7 @@ class basic_json
m_start
m_content
*/
void fill_line_buffer()
void fill_line_buffer(size_t n = 0)
{
// number of processed characters (p)
const auto offset_start = m_start - m_content;
@ -7894,6 +7898,9 @@ class basic_json
// no stream is used or end of file is reached
if (m_stream == nullptr or m_stream->eof())
{
// skip this part if we are already using the line buffer
if (m_start != reinterpret_cast<const lexer_char_t*>(m_line_buffer.data()))
{
// copy unprocessed characters to line buffer
m_line_buffer.clear();
@ -7901,11 +7908,12 @@ class basic_json
{
m_line_buffer.append(1, static_cast<const char>(*m_cursor));
}
}
// append 5 characters (size of longest keyword "false") to
// make sure that there is sufficient space between m_cursor
// and m_limit
m_line_buffer.append(5, '\0');
// append n characters to make sure that there is sufficient
// space between m_cursor and m_limit
m_line_buffer.append(1, '\x00');
m_line_buffer.append(n - 1, '\x01');
}
else
{
@ -7913,7 +7921,7 @@ class basic_json
m_line_buffer.erase(0, static_cast<size_t>(offset_start));
// read next line from input stream
std::string line;
std::getline(*m_stream, line);
std::getline(*m_stream, line, '\n');
// add line with newline symbol to the line buffer
m_line_buffer += line + "\n";
}
@ -8075,6 +8083,11 @@ class basic_json
// skip the next 10 characters (xxxx\uyyyy)
i += 10;
}
else if (codepoint >= 0xDC00 and codepoint <= 0xDFFF)
{
// we found a lone low surrogate
throw std::invalid_argument("missing high surrogate");
}
else
{
// add unicode character(s)

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 @@
[-1e+9999]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1 @@
["\uDBFF\uDFFE"]

View file

@ -0,0 +1 @@
["\uD83F\uDFFE"]

View file

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

View file

@ -0,0 +1 @@
[a

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,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]

View file

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

View file

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

View file

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

View file

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

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