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

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

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
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" must contain simple values. 80 " \"enum\": [ {} ]" // "enum" dict values must contain "name".
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 "{"
84 " \"type\": \"array\"," 90 " \"type\": \"array\","
85 " \"items\": [ 123 ]," // "items" must contain a schema or schemas. 91 " \"items\": [ 123 ]," // "items" must contain a schema or schemas.
86 "}", &error)); 92 "}", &error));
87 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 93 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
88 "{ \"type\": \"object\" }", &error)) << error; 94 "{ \"type\": \"object\" }", &error)) << error;
89 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 95 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
90 "{ \"type\": [\"object\", \"array\"] }", &error)) << error; 96 "{ \"type\": [\"object\", \"array\"] }", &error)) << error;
91 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema( 97 EXPECT_TRUE(JSONSchemaValidator::IsValidSchema(
92 "{" 98 "{"
93 " \"type\": [\"object\", \"array\"]," 99 " \"type\": [\"object\", \"array\"],"
94 " \"properties\": {" 100 " \"properties\": {"
95 " \"string-property\": {" 101 " \"string-property\": {"
96 " \"type\": \"string\"," 102 " \"type\": \"string\","
97 " \"minLength\": 1," 103 " \"minLength\": 1,"
98 " \"maxLength\": 100," 104 " \"maxLength\": 100,"
99 " \"title\": \"The String Policy\"," 105 " \"title\": \"The String Policy\","
100 " \"description\": \"This policy controls the String widget.\"" 106 " \"description\": \"This policy controls the String widget.\""
101 " }," 107 " },"
102 " \"integer-property\": {" 108 " \"integer-property\": {"
103 " \"type\": \"number\"," 109 " \"type\": \"number\","
104 " \"minimum\": 1000.0," 110 " \"minimum\": 1000.0,"
105 " \"maximum\": 9999.0" 111 " \"maximum\": 9999.0"
106 " }," 112 " },"
107 " \"enum-property\": {" 113 " \"enum-property\": {"
108 " \"type\": \"integer\"," 114 " \"type\": \"integer\","
109 " \"enum\": [0, 1, 10, 100]" 115 " \"enum\": [0, 1, {\"name\": 10}, 100]"
110 " }," 116 " },"
111 " \"items-property\": {" 117 " \"items-property\": {"
112 " \"type\": \"array\"," 118 " \"type\": \"array\","
113 " \"items\": {" 119 " \"items\": {"
114 " \"type\": \"string\"" 120 " \"type\": \"string\""
115 " }" 121 " }"
116 " }," 122 " },"
117 " \"items-list-property\": {" 123 " \"items-list-property\": {"
118 " \"type\": \"array\"," 124 " \"type\": \"array\","
119 " \"items\": [" 125 " \"items\": ["
120 " { \"type\": \"string\" }," 126 " { \"type\": \"string\" },"
121 " { \"type\": \"integer\" }" 127 " { \"type\": \"integer\" }"
122 " ]" 128 " ]"
123 " }" 129 " }"
124 " }," 130 " },"
125 " \"additionalProperties\": {" 131 " \"additionalProperties\": {"
126 " \"type\": \"any\"" 132 " \"type\": \"any\""
127 " }" 133 " }"
128 "}", &error)) << error; 134 "}", &error)) << error;
129 } 135 }
OLDNEW
« no previous file with comments | « components/json_schema/json_schema_validator.cc ('k') | components/test/data/json_schema/enum_schema.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698