|
|
@@ -1,4 +1,3 @@
|
|
|
-#include "gmock/gmock-matchers.h"
|
|
|
#include <string_view>
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
@@ -123,6 +122,23 @@ TEST(Annotation, PathFollowsSchemaNotConstraintModel) {
|
|
|
EXPECT_THAT(result, AnnotationAt(""_jptr, "/disallow"_jptr, "type (string) is one of [string]"));
|
|
|
}
|
|
|
|
|
|
+TEST(Annotation, SomeConstraintsAnnotateBothValidAndInvalid) {
|
|
|
+ auto const schema = R"({
|
|
|
+ "$comment": "accepts any number <= 0 or >= 10",
|
|
|
+ "oneOf": [
|
|
|
+ { "minimum": 10 },
|
|
|
+ { "maximum": 0 }
|
|
|
+ ]
|
|
|
+ })"_json;
|
|
|
+
|
|
|
+ auto const instance = R"(-1)"_json;
|
|
|
+ jvalidate::ValidationResult result = validate(schema, instance);
|
|
|
+
|
|
|
+ EXPECT_THAT(result, Not(HasAnnotationAt(""_jptr, "/oneOf"_jptr)));
|
|
|
+ EXPECT_THAT(result, AnnotationAt(""_jptr, "/oneOf/0/minimum"_jptr, "-1 < 10"));
|
|
|
+ EXPECT_THAT(result, AnnotationAt(""_jptr, "/oneOf/1/maximum"_jptr, "-1 <= 0"));
|
|
|
+}
|
|
|
+
|
|
|
int main(int argc, char ** argv) {
|
|
|
testing::InitGoogleMock(&argc, argv);
|
|
|
return RUN_ALL_TESTS();
|