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:
mefyl 2018-11-07 16:02:50 +01:00
parent d2e6e1bf58
commit aa10382629
3 changed files with 27 additions and 6 deletions

View file

@ -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());
}
}