Process each invalid example separately in picojson_format_test

This commit is contained in:
Tristan Penman 2023-08-24 20:52:18 +10:00
parent 0b7efb3763
commit 373576a3d2

View File

@ -31,7 +31,7 @@ constexpr auto validStr = R"JSON([
"2023-07-18T14:46:22Z" "2023-07-18T14:46:22Z"
])JSON"; ])JSON";
constexpr auto invalidStr = R"JSON([ constexpr auto invalidStrs = R"JSON([
["um 12", "um 12"], ["um 12", "um 12"],
["2023-07-18T14:46:22Z"], ["2023-07-18T14:46:22Z"],
["2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z"] ["2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z", "2023-07-18T14:46:22Z"]
@ -80,9 +80,11 @@ int main(int argc, char **argv)
{ {
// invalid // invalid
auto targetJson = Parse(invalidStr, picojson::value{}); auto targetJsonArray = Parse(invalidStrs, picojson::value{});
auto targetAdapter = valijson::adapters::PicoJsonAdapter(targetJson); std::cout << "Invalid Targets:" << std::endl << invalidStrs << std::endl << std::endl;
std::cout << "Invalid Target:" << std::endl << invalidStr << std::endl << std::endl;
for (auto &&testCase : targetJsonArray.get<picojson::array>()) {
auto targetAdapter = valijson::adapters::PicoJsonAdapter(testCase);
valijson::ValidationResults results; valijson::ValidationResults results;
auto validator = valijson::Validator(); auto validator = valijson::Validator();
@ -102,8 +104,9 @@ int main(int argc, char **argv)
std::cerr << contextElement << " "; std::cerr << contextElement << " ";
} }
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << " - " << error.description << std::endl; std::cerr << " - " << error.description << std::endl << std::endl;
++errorNum; ++errorNum;
} }
} }
} }
}