Index: components/json_schema/json_schema_validator_unittest.cc |
diff --git a/components/json_schema/json_schema_validator_unittest.cc b/components/json_schema/json_schema_validator_unittest.cc |
index 6372032c13576b29f56a860d255c19c18c057edd..8a5d113abc90ea97b5debd29f63a794479f39ac0 100644 |
--- a/components/json_schema/json_schema_validator_unittest.cc |
+++ b/components/json_schema/json_schema_validator_unittest.cc |
@@ -54,46 +54,45 @@ TEST_F(JSONSchemaValidatorCPPTest, Test) { |
TEST(JSONSchemaValidator, IsValidSchema) { |
std::string error; |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("", &error)); |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("\0", &error)); |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("string", &error)); |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("\"string\"", &error)); |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("[]", &error)); |
- EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("{}", &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("", false, &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("\0", false, &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("string", false, &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("\"string\"", false, &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("[]", false, &error)); |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema("{}", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
- "{ \"type\": 123 }", &error)); |
+ "{ \"type\": 123 }", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
- "{ \"type\": \"invalid\" }", &error)); |
+ "{ \"type\": \"invalid\" }", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": \"object\"," |
" \"properties\": []" // Invalid properties type. |
- "}", &error)); |
+ "}", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": \"string\"," |
" \"maxLength\": -1" // Must be >= 0. |
- "}", &error)); |
+ "}", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": \"string\"," |
" \"enum\": [ {} ]" // "enum" dict values must contain "name". |
- "}", &error)); |
+ "}", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": \"string\"," |
" \"enum\": [ { \"name\": {} } ]" // "enum" name must be a simple value. |
- "}", |
- &error)); |
+ "}", false, &error)); |
EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": \"array\"," |
" \"items\": [ 123 ]," // "items" must contain a schema or schemas. |
- "}", &error)); |
+ "}", false, &error)); |
EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( |
- "{ \"type\": \"object\" }", &error)) << error; |
+ "{ \"type\": \"object\" }", false, &error)) << error; |
EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( |
- "{ \"type\": [\"object\", \"array\"] }", &error)) << error; |
+ "{ \"type\": [\"object\", \"array\"] }", false, &error)) << error; |
EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( |
"{" |
" \"type\": [\"object\", \"array\"]," |
@@ -131,5 +130,15 @@ TEST(JSONSchemaValidator, IsValidSchema) { |
" \"additionalProperties\": {" |
" \"type\": \"any\"" |
" }" |
- "}", &error)) << error; |
+ "}", false, &error)) << error; |
+ EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( |
+ "{" |
+ " \"type\": \"object\"," |
+ " \"unknown attribute\": \"that should just be ignored\"" |
+ "}", true, &error)) << error; |
+ EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( |
+ "{" |
+ " \"type\": \"object\"," |
+ " \"unknown attribute\": \"that will cause a failure\"" |
+ "}", false, &error)) << error; |
} |