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

Unified Diff: base/values_unittest.cc

Issue 1129083003: More base::Values-related bare pointer -> scoped_ptr conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: base/values_unittest.cc
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 0d39d8b24da81c5b634c22b757c085cffa16a51f..b12c3e487b16a1adb63342553f6f4d8962c504f3 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -318,9 +318,8 @@ TEST(ValuesTest, DictionaryRemoval) {
TEST(ValuesTest, DictionaryWithoutPathExpansion) {
DictionaryValue dict;
- dict.Set("this.is.expanded", make_scoped_ptr(Value::CreateNullValue()));
- dict.SetWithoutPathExpansion("this.isnt.expanded",
- make_scoped_ptr(Value::CreateNullValue()));
+ dict.Set("this.is.expanded", Value::CreateNullValue());
+ dict.SetWithoutPathExpansion("this.isnt.expanded", Value::CreateNullValue());
EXPECT_FALSE(dict.HasKey("this.is.expanded"));
EXPECT_TRUE(dict.HasKey("this"));
@@ -390,7 +389,7 @@ TEST(ValuesTest, DictionaryRemovePath) {
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
- Value* original_null = Value::CreateNullValue();
+ Value* original_null = Value::CreateNullValue().release();
danakj 2015/05/08 18:07:26 can you make original_null a scoped_ptr?
Evan Stade 2015/05/08 18:32:09 not really --- it's referenced below; this test ne
danakj 2015/05/08 18:33:42 Can you put the weak ref in a separate variable so
Evan Stade 2015/05/08 18:38:27 I don't think expressing ownership with a raw poin
danakj 2015/05/08 18:48:28 This test was written before scoped_ptr existed fr
Evan Stade 2015/05/08 18:54:12 All the lines with "make_scoped_ptr" were not writ
original_dict.Set("null", make_scoped_ptr(original_null));
FundamentalValue* original_bool = new FundamentalValue(true);
original_dict.Set("bool", make_scoped_ptr(original_bool));
@@ -529,16 +528,13 @@ TEST(ValuesTest, DeepCopy) {
}
TEST(ValuesTest, Equals) {
- Value* null1 = Value::CreateNullValue();
- Value* null2 = Value::CreateNullValue();
- EXPECT_NE(null1, null2);
- EXPECT_TRUE(null1->Equals(null2));
+ scoped_ptr<Value> null1(Value::CreateNullValue());
+ scoped_ptr<Value> null2(Value::CreateNullValue());
+ EXPECT_NE(null1.get(), null2.get());
+ EXPECT_TRUE(null1->Equals(null2.get()));
- Value* boolean = new FundamentalValue(false);
- EXPECT_FALSE(null1->Equals(boolean));
- delete null1;
- delete null2;
- delete boolean;
+ FundamentalValue boolean(false);
+ EXPECT_FALSE(null1->Equals(&boolean));
DictionaryValue dv;
dv.SetBoolean("a", false);
@@ -546,7 +542,7 @@ TEST(ValuesTest, Equals) {
dv.SetDouble("c", 2.5);
dv.SetString("d1", "string");
dv.SetString("d2", ASCIIToUTF16("http://google.com"));
- dv.Set("e", make_scoped_ptr(Value::CreateNullValue()));
+ dv.Set("e", Value::CreateNullValue());
scoped_ptr<DictionaryValue> copy = dv.CreateDeepCopy();
EXPECT_TRUE(dv.Equals(copy.get()));
@@ -596,7 +592,7 @@ TEST(ValuesTest, StaticEquals) {
TEST(ValuesTest, DeepCopyCovariantReturnTypes) {
DictionaryValue original_dict;
- Value* original_null = Value::CreateNullValue();
+ Value* original_null = Value::CreateNullValue().release();
danakj 2015/05/08 18:07:26 can you make original_null a scoped_ptr too?
Evan Stade 2015/05/08 18:32:09 Done.
original_dict.Set("null", make_scoped_ptr(original_null));
FundamentalValue* original_bool = new FundamentalValue(true);
original_dict.Set("bool", make_scoped_ptr(original_bool));
« base/values.cc ('K') | « base/values.cc ('k') | cc/debug/invalidation_benchmark.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698