Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: components/json_schema/json_schema_validator_unittest.cc

Issue 195193002: Add regular expression support in json_schema component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/values.h" 5 #include "base/values.h"
6 #include "components/json_schema/json_schema_validator.h" 6 #include "components/json_schema/json_schema_validator.h"
7 #include "components/json_schema/json_schema_validator_unittest_base.h" 7 #include "components/json_schema/json_schema_validator_unittest_base.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 class JSONSchemaValidatorCPPTest : public JSONSchemaValidatorTestBase { 10 class JSONSchemaValidatorCPPTest : public JSONSchemaValidatorTestBase {
11 public: 11 public:
12 JSONSchemaValidatorCPPTest() 12 JSONSchemaValidatorCPPTest() : JSONSchemaValidatorTestBase() {}
13 : JSONSchemaValidatorTestBase(JSONSchemaValidatorTestBase::CPP) {
14 }
15 13
16 protected: 14 protected:
17 virtual void ExpectValid(const std::string& test_source, 15 virtual void ExpectValid(const std::string& test_source,
18 base::Value* instance, 16 base::Value* instance,
19 base::DictionaryValue* schema, 17 base::DictionaryValue* schema,
20 base::ListValue* types) OVERRIDE { 18 base::ListValue* types) OVERRIDE {
21 JSONSchemaValidator validator(schema, types); 19 JSONSchemaValidator validator(schema, types);
22 if (validator.Validate(instance)) 20 if (validator.Validate(instance))
23 return; 21 return;
24 22
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 " ]" 125 " ]"
128 " }" 126 " }"
129 " }," 127 " },"
130 " \"additionalProperties\": {" 128 " \"additionalProperties\": {"
131 " \"type\": \"any\"" 129 " \"type\": \"any\""
132 " }" 130 " }"
133 "}", &error)) << error; 131 "}", &error)) << error;
134 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 132 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
135 "{" 133 "{"
136 " \"type\": \"object\"," 134 " \"type\": \"object\","
135 " \"patternProperties\": {"
136 " \".\": { \"type\": \"any\" },"
137 " \"foo\": { \"type\": \"any\" },"
138 " \"^foo$\": { \"type\": \"any\" },"
139 " \"foo+\": { \"type\": \"any\" },"
140 " \"foo?\": { \"type\": \"any\" },"
141 " \"fo{2,4}\": { \"type\": \"any\" },"
142 " \"(left)|(right)\": { \"type\": \"any\" }"
143 " }"
144 "}", &error)) << error;
145 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
146 "{"
147 " \"type\": \"object\","
137 " \"unknown attribute\": \"that should just be ignored\"" 148 " \"unknown attribute\": \"that should just be ignored\""
138 "}", 149 "}",
139 JSONSchemaValidator::OPTIONS_IGNORE_UNKNOWN_ATTRIBUTES, 150 JSONSchemaValidator::OPTIONS_IGNORE_UNKNOWN_ATTRIBUTES,
140 &error)) << error; 151 &error)) << error;
141 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( 152 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema(
142 "{" 153 "{"
143 " \"type\": \"object\"," 154 " \"type\": \"object\","
144 " \"unknown attribute\": \"that will cause a failure\"" 155 " \"unknown attribute\": \"that will cause a failure\""
145 "}", 0, &error)) << error; 156 "}", 0, &error)) << error;
146 } 157 }
OLDNEW
« no previous file with comments | « components/json_schema/json_schema_validator.cc ('k') | components/json_schema/json_schema_validator_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698