| 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 | 12 |
| 12 using namespace test::api::objects; | 13 using namespace test::api::objects; |
| 13 using namespace test::api::objects_movable; | 14 using namespace test::api::objects_movable; |
| 15 using namespace test::api::objects_movable_json; |
| 14 | 16 |
| 15 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { | 17 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { |
| 16 { | 18 { |
| 17 scoped_ptr<base::ListValue> strings(new base::ListValue()); | 19 scoped_ptr<base::ListValue> strings(new base::ListValue()); |
| 18 strings->Append(new base::StringValue("one")); | 20 strings->Append(new base::StringValue("one")); |
| 19 strings->Append(new base::StringValue("two")); | 21 strings->Append(new base::StringValue("two")); |
| 20 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); | 22 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); |
| 21 info_value->Set("strings", strings.release()); | 23 info_value->Set("strings", strings.release()); |
| 22 info_value->Set("integer", new base::FundamentalValue(5)); | 24 info_value->Set("integer", new base::FundamentalValue(5)); |
| 23 info_value->Set("boolean", new base::FundamentalValue(true)); | 25 info_value->Set("boolean", new base::FundamentalValue(true)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 MovablePod pod; | 88 MovablePod pod; |
| 87 pod.foo = FOO_BAZ; | 89 pod.foo = FOO_BAZ; |
| 88 pod.str = "str2"; | 90 pod.str = "str2"; |
| 89 pod.num = 45; | 91 pod.num = 45; |
| 90 pod.b = false; | 92 pod.b = false; |
| 91 pods.push_back(std::move(pod)); | 93 pods.push_back(std::move(pod)); |
| 92 } | 94 } |
| 93 MovableParent parent; | 95 MovableParent parent; |
| 94 parent.pods = std::move(pods); | 96 parent.pods = std::move(pods); |
| 95 parent.strs.push_back("pstr"); | 97 parent.strs.push_back("pstr"); |
| 98 parent.blob.additional_properties.SetString("key", "val"); |
| 96 | 99 |
| 97 MovableParent parent2(std::move(parent)); | 100 MovableParent parent2(std::move(parent)); |
| 98 ASSERT_EQ(2u, parent2.pods.size()); | 101 ASSERT_EQ(2u, parent2.pods.size()); |
| 99 EXPECT_EQ(FOO_BAR, parent2.pods[0].foo); | 102 EXPECT_EQ(FOO_BAR, parent2.pods[0].foo); |
| 100 EXPECT_EQ("str1", parent2.pods[0].str); | 103 EXPECT_EQ("str1", parent2.pods[0].str); |
| 101 EXPECT_EQ(42, parent2.pods[0].num); | 104 EXPECT_EQ(42, parent2.pods[0].num); |
| 102 EXPECT_TRUE(parent2.pods[0].b); | 105 EXPECT_TRUE(parent2.pods[0].b); |
| 103 EXPECT_EQ(FOO_BAZ, parent2.pods[1].foo); | 106 EXPECT_EQ(FOO_BAZ, parent2.pods[1].foo); |
| 104 EXPECT_EQ("str2", parent2.pods[1].str); | 107 EXPECT_EQ("str2", parent2.pods[1].str); |
| 105 EXPECT_EQ(45, parent2.pods[1].num); | 108 EXPECT_EQ(45, parent2.pods[1].num); |
| 106 EXPECT_FALSE(parent2.pods[1].b); | 109 EXPECT_FALSE(parent2.pods[1].b); |
| 107 ASSERT_EQ(1u, parent2.strs.size()); | 110 ASSERT_EQ(1u, parent2.strs.size()); |
| 108 EXPECT_EQ("pstr", parent2.strs[0]); | 111 EXPECT_EQ("pstr", parent2.strs[0]); |
| 112 std::string blob_string; |
| 113 EXPECT_TRUE( |
| 114 parent2.blob.additional_properties.GetString("key", &blob_string)); |
| 115 EXPECT_EQ("val", blob_string); |
| 116 |
| 117 MovableWithAdditional with_additional; |
| 118 with_additional.str = "str"; |
| 119 std::vector<std::string> vals1; |
| 120 vals1.push_back("vals1a"); |
| 121 vals1.push_back("vals1b"); |
| 122 with_additional.additional_properties["key1"] = vals1; |
| 123 std::vector<std::string> vals2; |
| 124 vals2.push_back("vals2a"); |
| 125 vals2.push_back("vals2b"); |
| 126 with_additional.additional_properties["key2"] = vals2; |
| 127 |
| 128 MovableWithAdditional with_additional2(std::move(with_additional)); |
| 129 EXPECT_EQ("str", with_additional2.str); |
| 130 EXPECT_EQ(2u, with_additional2.additional_properties.size()); |
| 131 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]); |
| 132 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]); |
| 109 } | 133 } |
| OLD | NEW |