diff --git a/test/perftest/schematest.cpp b/test/perftest/schematest.cpp index cdc7fda..7d27344 100644 --- a/test/perftest/schematest.cpp +++ b/test/perftest/schematest.cpp @@ -199,8 +199,7 @@ TEST_F(Schema, TestSuite) { char validatorBuffer[65536]; MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer)); - // DCOLES - Reduce number by a factor of 100 to make it more reasonable and inline with other test counts - const int trialCount = 1000; + const int trialCount = 100000; int testCount = 0; clock_t start = clock(); for (int i = 0; i < trialCount; i++) { diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 459de1a..7f1b43e 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -118,13 +118,18 @@ TEST(SchemaValidator, Hasher) { EXPECT_FALSE(d.HasParseError());\ EXPECT_TRUE(expected == d.Accept(validator));\ EXPECT_TRUE(expected == validator.IsValid());\ + ValidateErrorCode code = validator.GetInvalidSchemaCode();\ + if (expected) {\ + EXPECT_TRUE(code == kValidateErrorNone);\ + EXPECT_TRUE(validator.GetInvalidSchemaKeyword() == 0);\ + }\ if ((expected) && !validator.IsValid()) {\ StringBuffer sb;\ validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\ printf("Invalid schema: %s\n", sb.GetString());\ printf("Invalid keyword: %s\n", validator.GetInvalidSchemaKeyword());\ - printf("Invalid code: %d\n", validator.GetInvalidSchemaCode());\ - printf("Invalid message: %s\n", GetValidateError_En(validator.GetInvalidSchemaCode()));\ + printf("Invalid code: %d\n", code);\ + printf("Invalid message: %s\n", GetValidateError_En(code));\ sb.Clear();\ validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\ printf("Invalid document: %s\n", sb.GetString());\ @@ -2522,6 +2527,7 @@ TEST(SchemaValidator, ContinueOnErrors_RogueObject) { kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer); CrtAllocator::Free(schema); } + // Test that when kValidateContinueOnErrorFlag is set, a string appearing for an array or object property is handled // This tests that we don't blow up when there is a type mismatch. TEST(SchemaValidator, ContinueOnErrors_RogueString) { @@ -2544,6 +2550,10 @@ TEST(SchemaValidator, ContinueOnErrors_RogueString) { CrtAllocator::Free(schema); } +TEST(SchemaValidator, Schema_UnknownError) { + ASSERT_TRUE(SchemaValidator::SchemaType::GetValidateErrorKeyword(kValidateErrors).GetString() == std::string("null")); +} + #if defined(_MSC_VER) || defined(__clang__) RAPIDJSON_DIAG_POP #endif