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

Side by Side Diff: base/trace_event/trace_event_argument_unittest.cc

Issue 2258713003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 | « base/trace_event/trace_config.cc ('k') | base/values_unittest.cc » ('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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "base/trace_event/trace_event_argument.h" 5 #include "base/trace_event/trace_event_argument.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 std::string json; 125 std::string json;
126 value->AppendAsTraceFormat(&json); 126 value->AppendAsTraceFormat(&json);
127 EXPECT_EQ( 127 EXPECT_EQ(
128 "{\"outer_dict\":{\"inner_list\":[false,1,\"in_list\",{\"bool\":true," 128 "{\"outer_dict\":{\"inner_list\":[false,1,\"in_list\",{\"bool\":true,"
129 "\"double\":42.0,\"int\":42,\"string\":\"ab\"}]}}", 129 "\"double\":42.0,\"int\":42,\"string\":\"ab\"}]}}",
130 json); 130 json);
131 } 131 }
132 132
133 TEST(TraceEventArgumentTest, PassTracedValue) { 133 TEST(TraceEventArgumentTest, PassTracedValue) {
134 auto dict_value = WrapUnique(new TracedValue()); 134 auto dict_value = MakeUnique<TracedValue>();
135 dict_value->SetInteger("a", 1); 135 dict_value->SetInteger("a", 1);
136 136
137 auto nested_dict_value = WrapUnique(new TracedValue()); 137 auto nested_dict_value = MakeUnique<TracedValue>();
138 nested_dict_value->SetInteger("b", 2); 138 nested_dict_value->SetInteger("b", 2);
139 nested_dict_value->BeginArray("c"); 139 nested_dict_value->BeginArray("c");
140 nested_dict_value->AppendString("foo"); 140 nested_dict_value->AppendString("foo");
141 nested_dict_value->EndArray(); 141 nested_dict_value->EndArray();
142 142
143 dict_value->SetValue("e", *nested_dict_value); 143 dict_value->SetValue("e", *nested_dict_value);
144 144
145 // Check the merged result. 145 // Check the merged result.
146 std::string json; 146 std::string json;
147 dict_value->AppendAsTraceFormat(&json); 147 dict_value->AppendAsTraceFormat(&json);
148 EXPECT_EQ("{\"a\":1,\"e\":{\"b\":2,\"c\":[\"foo\"]}}", json); 148 EXPECT_EQ("{\"a\":1,\"e\":{\"b\":2,\"c\":[\"foo\"]}}", json);
149 149
150 // Check that the passed nestd dict was left unouthced. 150 // Check that the passed nestd dict was left unouthced.
151 json = ""; 151 json = "";
152 nested_dict_value->AppendAsTraceFormat(&json); 152 nested_dict_value->AppendAsTraceFormat(&json);
153 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"]}", json); 153 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"]}", json);
154 154
155 // And that it is still usable. 155 // And that it is still usable.
156 nested_dict_value->SetInteger("f", 3); 156 nested_dict_value->SetInteger("f", 3);
157 nested_dict_value->BeginDictionary("g"); 157 nested_dict_value->BeginDictionary("g");
158 nested_dict_value->EndDictionary(); 158 nested_dict_value->EndDictionary();
159 json = ""; 159 json = "";
160 nested_dict_value->AppendAsTraceFormat(&json); 160 nested_dict_value->AppendAsTraceFormat(&json);
161 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"],\"f\":3,\"g\":{}}", json); 161 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"],\"f\":3,\"g\":{}}", json);
162 } 162 }
163 163
164 } // namespace trace_event 164 } // namespace trace_event
165 } // namespace base 165 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_config.cc ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698