Merge branch 'feature/filenotfound' into develop
This commit is contained in:
commit
a791af30b4
3 changed files with 18 additions and 0 deletions
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -496,6 +496,12 @@ TEST_CASE("regression tests")
|
||||||
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")
|
SECTION("issue #367 - calling stream at EOF")
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
Loading…
Reference in a new issue