OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/json_schema_compiler/test/objects.h" | 9 #include "tools/json_schema_compiler/test/objects.h" |
10 #include "tools/json_schema_compiler/test/objects_movable.h" | 10 #include "tools/json_schema_compiler/test/objects_movable.h" |
11 #include "tools/json_schema_compiler/test/objects_movable_json.h" | 11 #include "tools/json_schema_compiler/test/objects_movable_json.h" |
12 | 12 |
13 using namespace test::api::objects; | 13 using namespace test::api::objects; |
14 using namespace test::api::objects_movable; | 14 using namespace test::api::objects_movable; |
15 using namespace test::api::objects_movable_json; | 15 using namespace test::api::objects_movable_json; |
16 | 16 |
17 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { | 17 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { |
18 { | 18 { |
19 std::unique_ptr<base::ListValue> strings(new base::ListValue()); | 19 std::unique_ptr<base::ListValue> strings(new base::ListValue()); |
20 strings->Append(new base::StringValue("one")); | 20 strings->AppendString("one"); |
21 strings->Append(new base::StringValue("two")); | 21 strings->AppendString("two"); |
22 std::unique_ptr<base::DictionaryValue> info_value( | 22 std::unique_ptr<base::DictionaryValue> info_value( |
23 new base::DictionaryValue()); | 23 new base::DictionaryValue()); |
24 info_value->Set("strings", strings.release()); | 24 info_value->Set("strings", strings.release()); |
25 info_value->Set("integer", new base::FundamentalValue(5)); | 25 info_value->Set("integer", new base::FundamentalValue(5)); |
26 info_value->Set("boolean", new base::FundamentalValue(true)); | 26 info_value->Set("boolean", new base::FundamentalValue(true)); |
27 | 27 |
28 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); | 28 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); |
29 params_value->Append(info_value.release()); | 29 params_value->Append(info_value.release()); |
30 std::unique_ptr<ObjectParam::Params> params( | 30 std::unique_ptr<ObjectParam::Params> params( |
31 ObjectParam::Params::Create(*params_value)); | 31 ObjectParam::Params::Create(*params_value)); |
32 EXPECT_TRUE(params.get()); | 32 EXPECT_TRUE(params.get()); |
33 EXPECT_EQ((size_t) 2, params->info.strings.size()); | 33 EXPECT_EQ((size_t) 2, params->info.strings.size()); |
34 EXPECT_EQ("one", params->info.strings[0]); | 34 EXPECT_EQ("one", params->info.strings[0]); |
35 EXPECT_EQ("two", params->info.strings[1]); | 35 EXPECT_EQ("two", params->info.strings[1]); |
36 EXPECT_EQ(5, params->info.integer); | 36 EXPECT_EQ(5, params->info.integer); |
37 EXPECT_TRUE(params->info.boolean); | 37 EXPECT_TRUE(params->info.boolean); |
38 } | 38 } |
39 { | 39 { |
40 std::unique_ptr<base::ListValue> strings(new base::ListValue()); | 40 std::unique_ptr<base::ListValue> strings(new base::ListValue()); |
41 strings->Append(new base::StringValue("one")); | 41 strings->AppendString("one"); |
42 strings->Append(new base::StringValue("two")); | 42 strings->AppendString("two"); |
43 std::unique_ptr<base::DictionaryValue> info_value( | 43 std::unique_ptr<base::DictionaryValue> info_value( |
44 new base::DictionaryValue()); | 44 new base::DictionaryValue()); |
45 info_value->Set("strings", strings.release()); | 45 info_value->Set("strings", strings.release()); |
46 info_value->Set("integer", new base::FundamentalValue(5)); | 46 info_value->Set("integer", new base::FundamentalValue(5)); |
47 | 47 |
48 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); | 48 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); |
49 params_value->Append(info_value.release()); | 49 params_value->Append(info_value.release()); |
50 std::unique_ptr<ObjectParam::Params> params( | 50 std::unique_ptr<ObjectParam::Params> params( |
51 ObjectParam::Params::Create(*params_value)); | 51 ObjectParam::Params::Create(*params_value)); |
52 EXPECT_FALSE(params.get()); | 52 EXPECT_FALSE(params.get()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 vals2.push_back("vals2a"); | 152 vals2.push_back("vals2a"); |
153 vals2.push_back("vals2b"); | 153 vals2.push_back("vals2b"); |
154 with_additional.additional_properties["key2"] = vals2; | 154 with_additional.additional_properties["key2"] = vals2; |
155 | 155 |
156 MovableWithAdditional with_additional2(std::move(with_additional)); | 156 MovableWithAdditional with_additional2(std::move(with_additional)); |
157 EXPECT_EQ("str", with_additional2.str); | 157 EXPECT_EQ("str", with_additional2.str); |
158 EXPECT_EQ(2u, with_additional2.additional_properties.size()); | 158 EXPECT_EQ(2u, with_additional2.additional_properties.size()); |
159 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]); | 159 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]); |
160 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]); | 160 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]); |
161 } | 161 } |
OLD | NEW |