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

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

Issue 47403003: Revert 231982 "Docserver: Display enum value descriptions in API..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 " \"properties\": []" // Invalid properties type. 70 " \"properties\": []" // Invalid properties type.
71 "}", &error)); 71 "}", &error));
72 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( 72 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema(
73 "{" 73 "{"
74 " \"type\": \"string\"," 74 " \"type\": \"string\","
75 " \"maxLength\": -1" // Must be >= 0. 75 " \"maxLength\": -1" // Must be >= 0.
76 "}", &error)); 76 "}", &error));
77 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( 77 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema(
78 "{" 78 "{"
79 " \"type\": \"string\"," 79 " \"type\": \"string\","
80 " \"enum\": [ {} ]" // "enum" dict values must contain "name". 80 " \"enum\": [ {} ]," // "enum" must contain simple values.
81 "}", &error)); 81 "}", &error));
82 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( 82 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema(
83 "{" 83 "{"
84 " \"type\": \"string\","
85 " \"enum\": [ { \"name\": {} } ]" // "enum" name must be a simple value.
86 "}",
87 &error));
88 EXPECT_FALSE(JSONSchemaValidator::IsValidSchema(
89 "{"
90 " \"type\": \"array\"," 84 " \"type\": \"array\","
91 " \"items\": [ 123 ]," // "items" must contain a schema or schemas. 85 " \"items\": [ 123 ]," // "items" must contain a schema or schemas.
92 "}", &error)); 86 "}", &error));
93 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 87 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
94 "{ \"type\": \"object\" }", &error)) << error; 88 "{ \"type\": \"object\" }", &error)) << error;
95 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 89 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
96 "{ \"type\": [\"object\", \"array\"] }", &error)) << error; 90 "{ \"type\": [\"object\", \"array\"] }", &error)) << error;
97 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 91 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
98 "{" 92 "{"
99 " \"type\": [\"object\", \"array\"]," 93 " \"type\": [\"object\", \"array\"],"
100 " \"properties\": {" 94 " \"properties\": {"
101 " \"string-property\": {" 95 " \"string-property\": {"
102 " \"type\": \"string\"," 96 " \"type\": \"string\","
103 " \"minLength\": 1," 97 " \"minLength\": 1,"
104 " \"maxLength\": 100," 98 " \"maxLength\": 100,"
105 " \"title\": \"The String Policy\"," 99 " \"title\": \"The String Policy\","
106 " \"description\": \"This policy controls the String widget.\"" 100 " \"description\": \"This policy controls the String widget.\""
107 " }," 101 " },"
108 " \"integer-property\": {" 102 " \"integer-property\": {"
109 " \"type\": \"number\"," 103 " \"type\": \"number\","
110 " \"minimum\": 1000.0," 104 " \"minimum\": 1000.0,"
111 " \"maximum\": 9999.0" 105 " \"maximum\": 9999.0"
112 " }," 106 " },"
113 " \"enum-property\": {" 107 " \"enum-property\": {"
114 " \"type\": \"integer\"," 108 " \"type\": \"integer\","
115 " \"enum\": [0, 1, {\"name\": 10}, 100]" 109 " \"enum\": [0, 1, 10, 100]"
116 " }," 110 " },"
117 " \"items-property\": {" 111 " \"items-property\": {"
118 " \"type\": \"array\"," 112 " \"type\": \"array\","
119 " \"items\": {" 113 " \"items\": {"
120 " \"type\": \"string\"" 114 " \"type\": \"string\""
121 " }" 115 " }"
122 " }," 116 " },"
123 " \"items-list-property\": {" 117 " \"items-list-property\": {"
124 " \"type\": \"array\"," 118 " \"type\": \"array\","
125 " \"items\": [" 119 " \"items\": ["
126 " { \"type\": \"string\" }," 120 " { \"type\": \"string\" },"
127 " { \"type\": \"integer\" }" 121 " { \"type\": \"integer\" }"
128 " ]" 122 " ]"
129 " }" 123 " }"
130 " }," 124 " },"
131 " \"additionalProperties\": {" 125 " \"additionalProperties\": {"
132 " \"type\": \"any\"" 126 " \"type\": \"any\""
133 " }" 127 " }"
134 "}", &error)) << error; 128 "}", &error)) << error;
135 } 129 }
OLDNEW
« no previous file with comments | « trunk/src/components/json_schema/json_schema_validator.cc ('k') | trunk/src/components/test/data/json_schema/enum_schema.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698