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

Side by Side Diff: tools/json_schema_compiler/test/callbacks_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/callbacks.h" 5 #include "tools/json_schema_compiler/test/callbacks.h"
6 6
7 #include <memory>
8 #include <utility>
9
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
8 11
9 using namespace test::api::callbacks; 12 using namespace test::api::callbacks;
10 13
11 TEST(JsonSchemaCompilerCallbacksTest, ReturnsObjectResultCreate) { 14 TEST(JsonSchemaCompilerCallbacksTest, ReturnsObjectResultCreate) {
12 ReturnsObject::Results::SomeObject some_object; 15 ReturnsObject::Results::SomeObject some_object;
13 some_object.state = ENUMERATION_FOO; 16 some_object.state = ENUMERATION_FOO;
14 std::unique_ptr<base::ListValue> results = 17 std::unique_ptr<base::ListValue> results =
15 ReturnsObject::Results::Create(some_object); 18 ReturnsObject::Results::Create(some_object);
16 19
17 base::DictionaryValue* expected_dict = new base::DictionaryValue(); 20 std::unique_ptr<base::DictionaryValue> expected_dict(
21 new base::DictionaryValue());
18 expected_dict->SetString("state", "foo"); 22 expected_dict->SetString("state", "foo");
19 base::ListValue expected; 23 base::ListValue expected;
20 expected.Append(expected_dict); 24 expected.Append(std::move(expected_dict));
21 EXPECT_TRUE(results->Equals(&expected)); 25 EXPECT_TRUE(results->Equals(&expected));
22 } 26 }
23 27
24 TEST(JsonSchemaCompilerCallbacksTest, ReturnsMultipleResultCreate) { 28 TEST(JsonSchemaCompilerCallbacksTest, ReturnsMultipleResultCreate) {
25 ReturnsMultiple::Results::SomeObject some_object; 29 ReturnsMultiple::Results::SomeObject some_object;
26 some_object.state = ENUMERATION_FOO; 30 some_object.state = ENUMERATION_FOO;
27 std::unique_ptr<base::ListValue> results = 31 std::unique_ptr<base::ListValue> results =
28 ReturnsMultiple::Results::Create(5, some_object); 32 ReturnsMultiple::Results::Create(5, some_object);
29 33
30 base::DictionaryValue* expected_dict = new base::DictionaryValue(); 34 std::unique_ptr<base::DictionaryValue> expected_dict(
35 new base::DictionaryValue());
31 expected_dict->SetString("state", "foo"); 36 expected_dict->SetString("state", "foo");
32 base::ListValue expected; 37 base::ListValue expected;
33 expected.AppendInteger(5); 38 expected.AppendInteger(5);
34 expected.Append(expected_dict); 39 expected.Append(std::move(expected_dict));
35 EXPECT_TRUE(results->Equals(&expected)); 40 EXPECT_TRUE(results->Equals(&expected));
36 } 41 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/arrays_unittest.cc ('k') | tools/json_schema_compiler/test/idl_schemas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698