Browse Source

test-refactor: cleanup

Sam Jaffe 1 năm trước cách đây
mục cha
commit
550b9ad842
1 tập tin đã thay đổi với 12 bổ sung6 xóa
  1. 12 6
      tests/annotation_test.cxx

+ 12 - 6
tests/annotation_test.cxx

@@ -37,6 +37,15 @@ Json::Value operator""_json(char const * data, size_t len) {
   return value;
 }
 
+auto validate(Json::Value const & schema_doc, Json::Value const & instance_doc) {
+  jvalidate::Schema const schema(schema_doc, Draft2020_12);
+
+  jvalidate::ValidationResult result;
+  (void)jvalidate::Validator(schema).validate(instance_doc, &result);
+
+  return result;
+}
+
 MATCHER_P(HasAnnotationsFor, doc_path, "") { return arg.has_annotation(doc_path); }
 
 MATCHER_P2(HasAnnotationAt, doc_path, schema_path, "") {
@@ -52,17 +61,14 @@ MATCHER_P3(AnnotationAt, doc_path, schema_path, matcher, "") {
 }
 
 TEST(Annotation, AttachesFormattingAnnotation) {
-  jvalidate::Schema const schema(R"({
+  auto const schema = R"({
     "format": "uri"
-  })"_json,
-                                 Draft2020_12);
+  })"_json;
 
   auto const instance = R"("http://json-schema.org")"_json;
 
-  jvalidate::ValidationResult result;
-  bool const valid = jvalidate::Validator(schema).validate(instance, &result);
+  jvalidate::ValidationResult result = validate(schema, instance);
 
-  EXPECT_TRUE(valid);
   EXPECT_THAT(result, AnnotationAt(""_jptr, "/format"_jptr, "format 'uri'"));
 }