@return number of failed tests */
| 4 | |
| 5 | /** @return number of failed tests */ |
| 6 | size_t |
| 7 | testStringFormat(const std::string &format, |
| 8 | const std::vector<std::pair<std::string, bool>> &stringValidTests) |
| 9 | { |
| 10 | size_t numberOfErrors = 0; |
| 11 | |
| 12 | for (auto stringValid = stringValidTests.begin(); stringValid != stringValidTests.end(); ++stringValid) { |
| 13 | std::cout << "[INFO] Testing " << format << ": " << stringValid->first << "\n"; |
| 14 | |
| 15 | try { |
| 16 | nlohmann::json_schema::default_string_format_check(format, stringValid->first); |
| 17 | |
| 18 | if (!stringValid->second) { |
| 19 | ++numberOfErrors; |
| 20 | std::cerr << "[ERROR] String with " << format << " format '" << stringValid->first |
| 21 | << "' validated even though it should NOT!\n"; |
| 22 | } |
| 23 | } catch (std::exception &exception) { |
| 24 | std::cout << "[INFO] Validation failed with: " << exception.what() << "\n"; |
| 25 | if (stringValid->second) { |
| 26 | ++numberOfErrors; |
| 27 | std::cerr << "[ERROR] String with " << format << " format '" << stringValid->first |
| 28 | << "' did NOT validate even though it should!\n"; |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return numberOfErrors; |
| 34 | } |
| 35 | |
| 36 | int main() |
| 37 | { |
no test coverage detected