mirror of
https://github.com/nlohmann/json.git
synced 2026-03-05 16:56:25 +00:00
Set eofbit on exhausted input stream.
Fix issue #1340. The eofbit is set manually since we don't go through the stream interface. We could maybe use the stream interface instead, but there are some assumptions regarding which exception go through, so this seems to be the most prudent approach for now.
This commit is contained in:
@@ -1708,3 +1708,16 @@ TEST_CASE("regression tests")
|
||||
CHECK(expected == data);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("regression tests, exceptions dependent", "[!throws]")
|
||||
{
|
||||
SECTION("issue #1340 - eof not set on exhausted input stream")
|
||||
{
|
||||
std::stringstream s("{}{}");
|
||||
json j;
|
||||
s >> j;
|
||||
s >> j;
|
||||
CHECK_THROWS_AS(s >> j, json::parse_error const&);
|
||||
CHECK(s.eof());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user