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

Side by Side Diff: tools/json_schema_compiler/test/arrays_unittest.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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
OLDNEW
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 "tools/json_schema_compiler/test/arrays.h" 5 #include "tools/json_schema_compiler/test/arrays.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) { 244 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) {
245 std::vector<int> integers; 245 std::vector<int> integers;
246 integers.push_back(1); 246 integers.push_back(1);
247 integers.push_back(2); 247 integers.push_back(2);
248 std::unique_ptr<base::ListValue> results = 248 std::unique_ptr<base::ListValue> results =
249 ReturnIntegerArray::Results::Create(integers); 249 ReturnIntegerArray::Results::Create(integers);
250 250
251 base::ListValue expected; 251 base::ListValue expected;
252 base::ListValue* expected_argument = new base::ListValue(); 252 std::unique_ptr<base::ListValue> expected_argument(new base::ListValue());
253 expected_argument->AppendInteger(1); 253 expected_argument->AppendInteger(1);
254 expected_argument->AppendInteger(2); 254 expected_argument->AppendInteger(2);
255 expected.Append(expected_argument); 255 expected.Append(std::move(expected_argument));
256 EXPECT_TRUE(results->Equals(&expected)); 256 EXPECT_TRUE(results->Equals(&expected));
257 } 257 }
258 258
259 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) { 259 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) {
260 std::vector<Item> items; 260 std::vector<Item> items;
261 items.push_back(Item()); 261 items.push_back(Item());
262 items.push_back(Item()); 262 items.push_back(Item());
263 items[0].val = 1; 263 items[0].val = 1;
264 items[1].val = 2; 264 items[1].val = 2;
265 std::unique_ptr<base::ListValue> results = 265 std::unique_ptr<base::ListValue> results =
266 ReturnRefArray::Results::Create(items); 266 ReturnRefArray::Results::Create(items);
267 267
268 base::ListValue expected; 268 base::ListValue expected;
269 base::ListValue* expected_argument = new base::ListValue(); 269 std::unique_ptr<base::ListValue> expected_argument(new base::ListValue());
270 base::DictionaryValue* first = new base::DictionaryValue(); 270 std::unique_ptr<base::DictionaryValue> first(new base::DictionaryValue());
271 first->SetInteger("val", 1); 271 first->SetInteger("val", 1);
272 expected_argument->Append(first); 272 expected_argument->Append(std::move(first));
273 base::DictionaryValue* second = new base::DictionaryValue(); 273 std::unique_ptr<base::DictionaryValue> second(new base::DictionaryValue());
274 second->SetInteger("val", 2); 274 second->SetInteger("val", 2);
275 expected_argument->Append(second); 275 expected_argument->Append(std::move(second));
276 expected.Append(expected_argument); 276 expected.Append(std::move(expected_argument));
277 EXPECT_TRUE(results->Equals(&expected)); 277 EXPECT_TRUE(results->Equals(&expected));
278 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698