mirror of
https://github.com/nlohmann/json
synced 2024-11-09 22:20:05 +00:00
fixed #306
This commit is contained in:
parent
8ea0ee502d
commit
2daab5a4c2
@ -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).
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
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}
|
@ -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,19 @@ TEST_CASE("regression tests")
|
||||
|
||||
CHECK(at_integer == val_integer);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user