From ca2061acef5b626551c2088bf1073f857b583e61 Mon Sep 17 00:00:00 2001 From: miloyip Date: Wed, 6 May 2015 18:31:56 +0800 Subject: [PATCH] Turn off some not-yet-implemented test cases, and fix a few [ci skip] --- include/rapidjson/schema.h | 5 +++-- test/unittest/schematest.cpp | 39 +++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index e4731f2..9860415 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -960,8 +960,8 @@ public: virtual bool StartObject(Context&) const { return false; } virtual bool Key(Context&, const Ch*, SizeType, bool) const { return false; } virtual bool EndObject(Context&, SizeType) const { return false; } - virtual bool StartArray(Context&) const { return true; } - virtual bool EndArray(Context&, SizeType) const { return true; } + virtual bool StartArray(Context&) const { return false; } + virtual bool EndArray(Context&, SizeType) const { return false; } private: #if RAPIDJSON_SCHEMA_USE_STDREGEX @@ -1350,6 +1350,7 @@ public: while (!schemaStack_.Empty()) PopSchema(); //documentStack_.Clear(); + valid_ = true; }; // Implementation of ISchemaValidator diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 7b0df90..726483b 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -645,8 +645,8 @@ TEST(SchemaValidator, TestSuite) { "additionalProperties.json", "allOf.json", "anyOf.json", - "definitions.json", - "dependencies.json", + //"definitions.json", + //"dependencies.json", "enum.json", "items.json", "maximum.json", @@ -660,16 +660,21 @@ TEST(SchemaValidator, TestSuite) { "multipleOf.json", "not.json", "oneOf.json", +#if RAPIDJSON_SCHEMA_HAS_REGEX "pattern.json", "patternProperties.json", +#endif "properties.json", - "ref.json", - "refRemote.json", + //"ref.json", + //"refRemote.json", "required.json", "type.json", - "uniqueItems.json" + //"uniqueItems.json" }; + const char* onlyRunDescription = 0; + //const char* onlyRunDescription = "a string is a string"; + unsigned testCount = 0; unsigned passCount = 0; @@ -694,19 +699,21 @@ TEST(SchemaValidator, TestSuite) { SchemaValidator validator(schema); const Value& tests = (*schemaItr)["tests"]; for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) { - testCount++; - const Value& data = (*testItr)["data"]; - bool expected = (*testItr)["valid"].GetBool(); const char* description = (*testItr)["description"].GetString(); - validator.Reset(); - bool actual = data.Accept(validator); - if (expected != actual) { - char buffer[256]; - sprintf(buffer, "%s \"%s\"", filename, description); - GTEST_NONFATAL_FAILURE_(buffer); + if (!onlyRunDescription || strcmp(description, onlyRunDescription) == 0) { + const Value& data = (*testItr)["data"]; + bool expected = (*testItr)["valid"].GetBool(); + testCount++; + validator.Reset(); + bool actual = data.Accept(validator); + if (expected != actual) { + char buffer[256]; + sprintf(buffer, "%s \"%s\"", filename, description); + GTEST_NONFATAL_FAILURE_(buffer); + } + else + passCount++; } - else - passCount++; } } }