Merge branch 'develop' into feature/issue365
This commit is contained in:
commit
a8522f391a
4 changed files with 35 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
|
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
|
||||||
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
|
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
|
||||||
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
|
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
|
||||||
|
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
|
||||||
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/fsf5FqYe6GoX68W6)
|
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/fsf5FqYe6GoX68W6)
|
||||||
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
|
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
|
||||||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||||
|
@ -501,6 +502,7 @@ I deeply appreciate the help of the following people.
|
||||||
- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file.
|
- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file.
|
||||||
- [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function.
|
- [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function.
|
||||||
- [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser and improved the benchmarking code.
|
- [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser and improved the benchmarking code.
|
||||||
|
- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan.
|
||||||
|
|
||||||
Thanks a lot for helping out!
|
Thanks a lot for helping out!
|
||||||
|
|
||||||
|
|
|
@ -7597,6 +7597,12 @@ class basic_json
|
||||||
explicit lexer(std::istream& s)
|
explicit lexer(std::istream& s)
|
||||||
: m_stream(&s), m_line_buffer()
|
: m_stream(&s), m_line_buffer()
|
||||||
{
|
{
|
||||||
|
// immediately abort if stream is erroneous
|
||||||
|
if (s.fail())
|
||||||
|
{
|
||||||
|
throw std::invalid_argument("stream error: " + std::string(strerror(errno)));
|
||||||
|
}
|
||||||
|
|
||||||
// fill buffer
|
// fill buffer
|
||||||
fill_line_buffer();
|
fill_line_buffer();
|
||||||
|
|
||||||
|
|
|
@ -7597,6 +7597,12 @@ class basic_json
|
||||||
explicit lexer(std::istream& s)
|
explicit lexer(std::istream& s)
|
||||||
: m_stream(&s), m_line_buffer()
|
: m_stream(&s), m_line_buffer()
|
||||||
{
|
{
|
||||||
|
// immediately abort if stream is erroneous
|
||||||
|
if (s.fail())
|
||||||
|
{
|
||||||
|
throw std::invalid_argument("stream error: " + std::string(strerror(errno)));
|
||||||
|
}
|
||||||
|
|
||||||
// fill buffer
|
// fill buffer
|
||||||
fill_line_buffer();
|
fill_line_buffer();
|
||||||
|
|
||||||
|
|
|
@ -495,4 +495,25 @@ TEST_CASE("regression tests")
|
||||||
json j = json::parse("22e2222");
|
json j = json::parse("22e2222");
|
||||||
CHECK(j == json());
|
CHECK(j == json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("issue #366 - json::parse on failed stream gets stuck")
|
||||||
|
{
|
||||||
|
std::ifstream f("file_not_found.json");
|
||||||
|
CHECK_THROWS_AS(json::parse(f), std::invalid_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("issue #367 - calling stream at EOF")
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
json j;
|
||||||
|
ss << "123";
|
||||||
|
CHECK_NOTHROW(j << ss);
|
||||||
|
|
||||||
|
// see https://github.com/nlohmann/json/issues/367#issuecomment-262841893:
|
||||||
|
// ss is not at EOF; this yielded an error before the fix
|
||||||
|
// (threw basic_string::append). No, it should just throw
|
||||||
|
// a parse error because of the EOF.
|
||||||
|
CHECK_THROWS_AS(j << ss, std::invalid_argument);
|
||||||
|
CHECK_THROWS_WITH(j << ss, "parse error - unexpected end of input");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue