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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 // GenerateFunctionParamsCreate errors | 94 // GenerateFunctionParamsCreate errors |
95 | 95 |
96 TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) { | 96 TEST(JsonSchemaCompilerErrorTest, ParamIsRequired) { |
97 { | 97 { |
98 std::unique_ptr<base::ListValue> params_value = List(new Value(5)); | 98 std::unique_ptr<base::ListValue> params_value = List(new Value(5)); |
99 base::string16 error; | 99 base::string16 error; |
100 EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error)); | 100 EXPECT_TRUE(TestFunction::Params::Create(*params_value, &error)); |
101 } | 101 } |
102 { | 102 { |
103 std::unique_ptr<base::ListValue> params_value = | 103 std::unique_ptr<base::ListValue> params_value = List(new Value()); |
104 List(base::Value::CreateNullValue().release()); | |
105 base::string16 error; | 104 base::string16 error; |
106 EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error)); | 105 EXPECT_FALSE(TestFunction::Params::Create(*params_value, &error)); |
107 EXPECT_TRUE(EqualsUtf16("'num' is required", error)); | 106 EXPECT_TRUE(EqualsUtf16("'num' is required", error)); |
108 } | 107 } |
109 } | 108 } |
110 | 109 |
111 // GeneratePopulateVariableFromValue errors | 110 // GeneratePopulateVariableFromValue errors |
112 | 111 |
113 TEST(JsonSchemaCompilerErrorTest, WrongPropertyValueType) { | 112 TEST(JsonSchemaCompilerErrorTest, WrongPropertyValueType) { |
114 { | 113 { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value))); | 321 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<TestType>(*value))); |
323 } | 322 } |
324 { | 323 { |
325 std::unique_ptr<base::DictionaryValue> value = | 324 std::unique_ptr<base::DictionaryValue> value = |
326 Dictionary("string", new base::Value("yes"), "ohno", | 325 Dictionary("string", new base::Value("yes"), "ohno", |
327 new base::Value("many values")); | 326 new base::Value("many values")); |
328 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'", | 327 EXPECT_TRUE(EqualsUtf16("found unexpected key 'ohno'", |
329 GetPopulateError<TestType>(*value))); | 328 GetPopulateError<TestType>(*value))); |
330 } | 329 } |
331 } | 330 } |
OLD | NEW |