mirror of
https://github.com/nlohmann/json.git
synced 2026-02-18 01:16:25 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15925469c6 | ||
|
|
f922426ec3 | ||
|
|
2daab5a4c2 | ||
|
|
8ea0ee502d | ||
|
|
fa0299f03a | ||
|
|
36745ed296 | ||
|
|
f0455b401d | ||
|
|
e0d809312b | ||
|
|
bfd6678800 | ||
|
|
9639f0dfb3 | ||
|
|
357baeff5a | ||
|
|
42be2edd4c |
@@ -213,6 +213,10 @@ install:
|
||||
if [[ "${LLVM_VERSION}" != "" ]]; then
|
||||
LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION}
|
||||
if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then
|
||||
travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
|
||||
tar xfz cmake-3.6.1.tar.gz
|
||||
(cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install)
|
||||
export PATH="${LLVM_DIR}/cmake/bin:${PATH}"
|
||||
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
|
||||
|
||||
@@ -430,7 +430,7 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| Clang Xcode 7.1 | Darwin Kernel Version 14.5.0 (OSX 10.10.5) | Apple LLVM version 7.0.0 (clang-700.1.76) |
|
||||
| Clang Xcode 7.2 | Darwin Kernel Version 15.0.0 (OSX 10.10.5) | Apple LLVM version 7.0.2 (clang-700.1.81) |
|
||||
| Clang Xcode 7.3 | Darwin Kernel Version 15.0.0 (OSX 10.10.5) | Apple LLVM version 7.3.0 (clang-703.0.29) |
|
||||
| Clang Xcode 8.0 | Darwin Kernel Version 15.5.0 (OSX 10.11.5) | Apple LLVM version 8.0.0 (clang-800.0.24.1) |
|
||||
| Clang Xcode 8.0 | Darwin Kernel Version 15.6.0 (OSX 10.11.6) | Apple LLVM version 8.0.0 (clang-800.0.38) |
|
||||
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25123.0 |
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ To compile and run the tests, you need to execute
|
||||
$ make check
|
||||
|
||||
===============================================================================
|
||||
All tests passed (8905154 assertions in 35 test cases)
|
||||
All tests passed (8905158 assertions in 35 test cases)
|
||||
```
|
||||
|
||||
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
|
||||
|
||||
BIN
doc/images/scanner.png
Normal file
BIN
doc/images/scanner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 645 KiB |
BIN
doc/json.gif
BIN
doc/json.gif
Binary file not shown.
|
Before Width: | Height: | Size: 440 KiB After Width: | Height: | Size: 440 KiB |
@@ -8592,7 +8592,7 @@ basic_json_parser_63:
|
||||
const auto offset_cursor = m_cursor - m_start;
|
||||
|
||||
// no stream is used or end of file is reached
|
||||
if (m_stream == nullptr or not * m_stream)
|
||||
if (m_stream == nullptr or m_stream->eof())
|
||||
{
|
||||
// copy unprocessed characters to line buffer
|
||||
m_line_buffer.clear();
|
||||
@@ -10116,7 +10116,7 @@ basic_json_parser_63:
|
||||
json_pointer top_pointer = ptr.top();
|
||||
if (top_pointer != ptr)
|
||||
{
|
||||
basic_json& x = result.at(top_pointer);
|
||||
result.at(top_pointer);
|
||||
}
|
||||
|
||||
// get reference to parent of JSON pointer ptr
|
||||
|
||||
@@ -7889,7 +7889,7 @@ class basic_json
|
||||
const auto offset_cursor = m_cursor - m_start;
|
||||
|
||||
// no stream is used or end of file is reached
|
||||
if (m_stream == nullptr or not * m_stream)
|
||||
if (m_stream == nullptr or m_stream->eof())
|
||||
{
|
||||
// copy unprocessed characters to line buffer
|
||||
m_line_buffer.clear();
|
||||
@@ -9413,7 +9413,7 @@ class basic_json
|
||||
json_pointer top_pointer = ptr.top();
|
||||
if (top_pointer != ptr)
|
||||
{
|
||||
basic_json& x = result.at(top_pointer);
|
||||
result.at(top_pointer);
|
||||
}
|
||||
|
||||
// get reference to parent of JSON pointer ptr
|
||||
|
||||
1
test/data/regression/broken_file.json
Normal file
1
test/data/regression/broken_file.json
Normal file
@@ -0,0 +1 @@
|
||||
{"AmbientOcclusion":false,"AnisotropicFiltering":16,"FOV":90,"FullScreen":true,"MipmapLevel":4,"RenderDistance":4,"VSync":true,"WindowResX":1920,"WindowResY":1080}
|
||||
1
test/data/regression/working_file.json
Normal file
1
test/data/regression/working_file.json
Normal file
@@ -0,0 +1 @@
|
||||
{"AmbientOcclusion":false,"AnisotropicFiltering":16,"FOV":90,"FullScreen":true,"MipmapLevel":4,"RenderDistance":4,"VSync":true,"WindowResX":1920,"WindowResY":1080}
|
||||
@@ -223,5 +223,21 @@ TEST_CASE("deserialization")
|
||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), std::invalid_argument);
|
||||
}
|
||||
}
|
||||
|
||||
// these cases are required for 100% line coverage
|
||||
SECTION("error cases")
|
||||
{
|
||||
SECTION("case 1")
|
||||
{
|
||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u'};
|
||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), std::invalid_argument);
|
||||
}
|
||||
|
||||
SECTION("case 2")
|
||||
{
|
||||
uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1'};
|
||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), std::invalid_argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ SOFTWARE.
|
||||
#include "json.hpp"
|
||||
using nlohmann::json;
|
||||
|
||||
#include <fstream>
|
||||
|
||||
TEST_CASE("regression tests")
|
||||
{
|
||||
SECTION("issue #60 - Double quotation mark is not parsed correctly")
|
||||
@@ -440,4 +442,28 @@ TEST_CASE("regression tests")
|
||||
|
||||
CHECK(at_integer == val_integer);
|
||||
}
|
||||
|
||||
SECTION("issue #304 - Unused variable warning")
|
||||
{
|
||||
// code triggered a "warning: unused variable" warning and is left
|
||||
// here to avoid the warning in the future
|
||||
json object;
|
||||
json patch = json::array();
|
||||
object = object.patch(patch);
|
||||
}
|
||||
|
||||
SECTION("issue #306 - Parsing fails without space at end of file")
|
||||
{
|
||||
for (auto filename :
|
||||
{
|
||||
"test/data/regression/broken_file.json",
|
||||
"test/data/regression/working_file.json"
|
||||
})
|
||||
{
|
||||
CAPTURE(filename);
|
||||
json j;
|
||||
std::ifstream f(filename);
|
||||
CHECK_NOTHROW(j << f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user