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

Side by Side Diff: tools/json_schema_compiler/test/error_generation_unittest.cc

Issue 1128523003: Add support for passing errors through PopulateArrayFromList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated JSON schema tests. Created 5 years, 7 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
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "tools/json_schema_compiler/test/error_generation.h" 5 #include "tools/json_schema_compiler/test/error_generation.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/json_schema_compiler/test/test_util.h" 10 #include "tools/json_schema_compiler/test/test_util.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 { 163 {
164 scoped_ptr<base::ListValue> params_value = List( 164 scoped_ptr<base::ListValue> params_value = List(
165 new FundamentalValue(5)); 165 new FundamentalValue(5));
166 EXPECT_TRUE(EqualsUtf16("", 166 EXPECT_TRUE(EqualsUtf16("",
167 GetPopulateError<ChoiceType::Integers>(*params_value))); 167 GetPopulateError<ChoiceType::Integers>(*params_value)));
168 } 168 }
169 { 169 {
170 scoped_ptr<base::ListValue> params_value = List( 170 scoped_ptr<base::ListValue> params_value = List(
171 new FundamentalValue(5), 171 new FundamentalValue(5),
172 new FundamentalValue(false)); 172 new FundamentalValue(false));
173 EXPECT_TRUE(EqualsUtf16("unable to populate array 'integers'", 173 EXPECT_TRUE(EqualsUtf16(
174 "expected integer, got boolean; unable to populate array 'integers'",
174 GetPopulateError<ChoiceType::Integers>(*params_value))); 175 GetPopulateError<ChoiceType::Integers>(*params_value)));
175 } 176 }
176 } 177 }
177 178
178 TEST(JsonSchemaCompilerErrorTest, BinaryTypeExpected) { 179 TEST(JsonSchemaCompilerErrorTest, BinaryTypeExpected) {
179 { 180 {
180 scoped_ptr<base::DictionaryValue> value = Dictionary( 181 scoped_ptr<base::DictionaryValue> value = Dictionary(
181 "data", new base::BinaryValue()); 182 "data", new base::BinaryValue());
182 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<BinaryData>(*value))); 183 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<BinaryData>(*value)));
183 } 184 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 GetPopulateError<OptionalChoiceType::Integers>(*params_value))); 288 GetPopulateError<OptionalChoiceType::Integers>(*params_value)));
288 } 289 }
289 { 290 {
290 scoped_ptr<base::ListValue> params_value = List( 291 scoped_ptr<base::ListValue> params_value = List(
291 new FundamentalValue(5), 292 new FundamentalValue(5),
292 new FundamentalValue(false)); 293 new FundamentalValue(false));
293 OptionalChoiceType::Integers out; 294 OptionalChoiceType::Integers out;
294 base::string16 error; 295 base::string16 error;
295 EXPECT_TRUE(OptionalChoiceType::Integers::Populate(*params_value, &out, 296 EXPECT_TRUE(OptionalChoiceType::Integers::Populate(*params_value, &out,
296 &error)); 297 &error));
297 EXPECT_TRUE(EqualsUtf16("unable to populate array 'integers'", 298 EXPECT_TRUE(EqualsUtf16(
299 "expected integer, got boolean; unable to populate array 'integers'",
298 error)); 300 error));
299 EXPECT_EQ(NULL, out.as_integer.get()); 301 EXPECT_EQ(NULL, out.as_integer.get());
300 } 302 }
301 } 303 }
302 304
303 TEST(JsonSchemaCompilerErrorTest, MultiplePopulationErrors) { 305 TEST(JsonSchemaCompilerErrorTest, MultiplePopulationErrors) {
304 { 306 {
305 307
306 scoped_ptr<base::DictionaryValue> value = Dictionary( 308 scoped_ptr<base::DictionaryValue> value = Dictionary(
307 "TheArray", new FundamentalValue(5)); 309 "TheArray", new FundamentalValue(5));
(...skipping 19 matching lines...) Expand all
327 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value))); 329 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value)));
328 } 330 }
329 { 331 {
330 scoped_ptr<base::DictionaryValue> value = Dictionary( 332 scoped_ptr<base::DictionaryValue> value = Dictionary(
331 "string", new base::StringValue("yes"), 333 "string", new base::StringValue("yes"),
332 "ohno", new base::StringValue("many values")); 334 "ohno", new base::StringValue("many values"));
333 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'", 335 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'",
334 GetPopulateError<TestType>(*value))); 336 GetPopulateError<TestType>(*value)));
335 } 337 }
336 } 338 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698