| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |