#include #include #include #include #include #include inline auto operator""_jptr(char const * data, size_t len) { return jvalidate::detail::Pointer(std::string_view{data, len}); } inline Json::Value operator""_json(char const * data, size_t len) { Json::Value value; Json::CharReaderBuilder builder; std::unique_ptr reader(builder.newCharReader()); std::string error; if (not reader->parse(data, data + len, &value, &error)) { throw std::runtime_error(error); } return value; } MATCHER(Valid, "") { return arg.valid(); } MATCHER_P(HasAnnotationsFor, doc_path, "") { return arg.has(doc_path); } MATCHER_P2(HasAnnotationAt, doc_path, schema_path, "") { return arg.has(doc_path, schema_path); } MATCHER_P2(AnnotationAt, key, matcher, "") { auto const * anno = arg.annotation({}, {}, key); if (not anno) { return false; } return testing::ExplainMatchResult(matcher, *anno, result_listener); } MATCHER_P4(AnnotationAt, doc_path, schema_path, key, matcher, "") { auto const * anno = arg.annotation(doc_path, schema_path, key); if (not anno) { return false; } return testing::ExplainMatchResult(matcher, *anno, result_listener); } MATCHER_P2(ErrorAt, key, matcher, "") { auto const * anno = arg.error({}, {}, key); if (not anno) { return false; } return testing::ExplainMatchResult(matcher, *anno, result_listener); } MATCHER_P4(ErrorAt, doc_path, schema_path, key, matcher, "") { auto const * anno = arg.error(doc_path, schema_path, key); if (not anno) { return false; } return testing::ExplainMatchResult(matcher, *anno, result_listener); }