diff options
author | Steve Hanson <smh@uk.ibm.com> | 2021-01-29 22:20:01 +0300 |
---|---|---|
committer | Steve Hanson <smh@uk.ibm.com> | 2021-01-29 22:20:01 +0300 |
commit | 28dc42d8d37ea0aa5f878f182cfa36265b4e3e46 (patch) | |
tree | 70f89eafb541549c7058d4390505786a73dec420 /test | |
parent | a3757456feb86fa6cd0ded48bbe1e32b8e814b54 (diff) |
restore coverage
Diffstat (limited to 'test')
-rw-r--r-- | test/perftest/schematest.cpp | 3 | ||||
-rw-r--r-- | test/unittest/schematest.cpp | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/test/perftest/schematest.cpp b/test/perftest/schematest.cpp index cdc7fda1..7d27344b 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 459de1a6..7f1b43ec 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 |