Skip to content

Commit

Permalink
#28 more logging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCzarnecki committed Jan 5, 2025
1 parent 91e697e commit 3a251a5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ std::filesystem::path expected_results_path(std::string const &test_name) {
return path;
}

#include <cerrno>

nlohmann::json parse_expected_results(std::string const &test_name) {
//logMsg("start parse_expected_results: " + test_name);
auto path = expected_results_path(test_name);
Expand All @@ -36,10 +38,35 @@ nlohmann::json parse_expected_results(std::string const &test_name) {
return nlohmann::json::object();
}
std::ifstream fin(path);
if(fin.eof())
{
logMsg("****************************************************");
logMsg("fin eof before content");
logMsg("****************************************************");
}
if(fin.bad())
{
logMsg("****************************************************");
logMsg("fin bad before content. error: " + std::string(std::strerror(errno)));
logMsg("****************************************************");
}
std::string content((std::istreambuf_iterator<char>(fin)),
(std::istreambuf_iterator<char>()));

if(fin.bad())
{
logMsg("****************************************************");
logMsg("fin bad after content. error: " + std::string(std::strerror(errno)));
logMsg("****************************************************");
}

nlohmann::json expected_results_json = nlohmann::json::parse(content);
if (expected_results_json.is_discarded())
{
logMsg("****************************************************");
logMsg("expected_results_json.is_discarded()");
logMsg("****************************************************");
}
//logMsg("end parse_expected_results: " + test_name);
return expected_results_json;
}
Expand Down

0 comments on commit 3a251a5

Please sign in to comment.