#include <nlohmann/json-schema.hpp>
#include <iostream>
Go to the source code of this file.
◆ EXPECT_EQ
| #define EXPECT_EQ |
( |
| a, |
|
|
| b ) |
Value: do { \
if (a != b) { \
std::cerr << "Failed: '" << a << "' != '" << b << "'\n"; \
} \
} while (0)
Definition at line 7 of file errors.cpp.
7#define EXPECT_EQ(a, b) \
8 do { \
9 if (a != b) { \
10 std::cerr << "Failed: '" << a << "' != '" << b << "'\n"; \
11 error_count++; \
12 } \
13 } while (0)
◆ main()
Definition at line 73 of file errors.cpp.
74{
76
77 try {
79 } catch (const std::exception &e) {
80 std::cerr << "Validation of schema failed, here is why: " << e.what() << "\n";
81 return EXIT_FAILURE;
82 }
83
85
86 validator.validate({{
"age", 42}, {
"name",
"John"}}, err);
89
91
95
96 validator.validate({{
"street",
"Boulevard"}}, err);
102
103 validator.validate({{
"age", 42}, {
"name", 12}}, err);
107
109 {"age", 42},
110 {"name", "John"},
111 {"phones", {1234, "223"}},
112 },
113 err);
117
119 {"age", 42},
120 {"name", "John"},
121 {"phones", {0}},
122 {"post-code", 12345},
123 },
124 err);
128
130}
nlohmann::json_schema::json_validator validator
std::vector< nlohmann::json::json_pointer > failed_pointers
static json person_schema
References error_count, anonymous_namespace{errors.cpp}::store_ptr_err_handler::failed_pointers, anonymous_namespace{errors.cpp}::person_schema, anonymous_namespace{errors.cpp}::store_ptr_err_handler::reset(), nlohmann::json_schema::json_validator::set_root_schema(), and nlohmann::json_schema::json_validator::validate().
◆ error_count