test-app: use cout and print group-results
This commit is contained in:
parent
f59b151974
commit
ccc72e3673
@ -10,23 +10,25 @@ int main(void)
|
||||
try {
|
||||
std::cin >> validation;
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << e.what() << "\n";
|
||||
std::cout << e.what() << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
json_validator validator;
|
||||
|
||||
size_t failed = 0,
|
||||
size_t total_failed = 0,
|
||||
total = 0;
|
||||
|
||||
for (auto &test_group : validation) {
|
||||
size_t group_failed = 0,
|
||||
group_total = 0;
|
||||
|
||||
std::cerr << "Testing Group " << test_group["description"] << "\n";
|
||||
std::cout << "Testing Group " << test_group["description"] << "\n";
|
||||
|
||||
const auto &schema = test_group["schema"];
|
||||
|
||||
for (auto &test_case : test_group["tests"]) {
|
||||
std::cerr << " Testing Case " << test_case["description"] << "\n";
|
||||
std::cout << " Testing Case " << test_case["description"] << "\n";
|
||||
|
||||
bool valid = true;
|
||||
|
||||
@ -34,28 +36,33 @@ int main(void)
|
||||
validator.validate(test_case["data"], schema);
|
||||
} catch (const std::out_of_range &e) {
|
||||
valid = false;
|
||||
std::cerr << " Test Case Exception (out of range): " << e.what() << "\n";
|
||||
std::cout << " Test Case Exception (out of range): " << e.what() << "\n";
|
||||
} catch (const std::invalid_argument &e) {
|
||||
valid = false;
|
||||
std::cerr << " Test Case Exception (invalid argument): " << e.what() << "\n";
|
||||
std::cout << " Test Case Exception (invalid argument): " << e.what() << "\n";
|
||||
} catch (const std::logic_error &e) {
|
||||
valid = !test_case["valid"]; /* force test-case failure */
|
||||
std::cerr << " Not yet implemented: " << e.what() << "\n";
|
||||
std::cout << " Not yet implemented: " << e.what() << "\n";
|
||||
}
|
||||
|
||||
if (valid == test_case["valid"])
|
||||
std::cerr << " --> Test Case exited with " << valid << " as expected.\n";
|
||||
std::cout << " --> Test Case exited with " << valid << " as expected.\n";
|
||||
else {
|
||||
failed++;
|
||||
std::cerr << " --> Test Case exited with " << valid << " NOT expected.\n";
|
||||
group_failed++;
|
||||
std::cout << " --> Test Case exited with " << valid << " NOT expected.\n";
|
||||
}
|
||||
total++;
|
||||
std::cerr << "\n";
|
||||
group_total++;
|
||||
std::cout << "\n";
|
||||
}
|
||||
std::cerr << "-------------\n";
|
||||
total_failed += group_failed;
|
||||
total += group_total;
|
||||
std::cout << "Group RESULT: " << test_group["description"] << " "
|
||||
<< (group_total - group_failed) << " of " << group_total
|
||||
<< " have succeeded - " << group_failed << " failed\n";
|
||||
std::cout << "-------------\n";
|
||||
}
|
||||
|
||||
std::cerr << (total - failed) << " of " << total << " have succeeded - " << failed << " failed\n";
|
||||
std::cout << (total - total_failed) << " of " << total << " have succeeded - " << total_failed << " failed\n";
|
||||
|
||||
return failed;
|
||||
return total_failed;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user