Unverified Commit 8c1387cf authored by knilch's avatar knilch Committed by GitHub

unit-testsuites.cpp: fix hangup if file not found

If run from the wrong directory, std::ifstream f("test/data/big-list-of-naughty-strings/blns.json"); will not find the file and thus f.eof() will never return true.
Use canonical C++ file reading loop from https://gehrcke.de/2011/06/reading-files-in-c-using-ifstream-dealing-correctly-with-badbit-failbit-eofbit-and-perror/ instead.
parent 680a4ab6
...@@ -1346,13 +1346,11 @@ TEST_CASE("Big List of Naughty Strings") ...@@ -1346,13 +1346,11 @@ TEST_CASE("Big List of Naughty Strings")
SECTION("roundtripping") SECTION("roundtripping")
{ {
std::ifstream f("test/data/big-list-of-naughty-strings/blns.json"); std::ifstream f("test/data/big-list-of-naughty-strings/blns.json");
std::string line;
while (not f.eof()) // read lines one by one, bail out on error or eof
while (getline(f, line))
{ {
// read line
std::string line;
getline(f, line);
// trim whitespace // trim whitespace
line = trim(line); line = trim(line);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment