✅ added test for #367
This commit is contained in:
parent
c7bd01edf2
commit
9a576fe1d9
1 changed files with 39 additions and 0 deletions
|
@ -34,6 +34,7 @@ using nlohmann::json;
|
|||
|
||||
#include <fstream>
|
||||
#include <list>
|
||||
#include <cstdio>
|
||||
|
||||
TEST_CASE("regression tests")
|
||||
{
|
||||
|
@ -709,6 +710,44 @@ TEST_CASE("regression tests")
|
|||
CHECK_THROWS_WITH(ss >> j,
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("second example from #529")
|
||||
{
|
||||
std::string str = "{\n\"one\" : 1,\n\"two\" : 2\n}\n{\n\"three\" : 3\n}";
|
||||
|
||||
{
|
||||
std::ofstream file("test.json");
|
||||
file << str;
|
||||
}
|
||||
|
||||
std::ifstream stream("test.json", std::ifstream::in);
|
||||
json val;
|
||||
|
||||
size_t i = 0;
|
||||
while (stream.peek() != EOF)
|
||||
{
|
||||
CAPTURE(i);
|
||||
CHECK_NOTHROW(stream >> val);
|
||||
|
||||
CHECK(i < 2);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
CHECK(val == json({{"one", 1}, {"two", 2}}));
|
||||
CHECK(stream.tellg() == 28);
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
CHECK(val == json({{"three", 3}}));
|
||||
CHECK(stream.tellg() == 44);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
std::remove("test.json");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("issue #389 - Integer-overflow (OSS-Fuzz issue 267)")
|
||||
|
|
Loading…
Reference in a new issue