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

Unified Diff: base/values_unittest.cc

Issue 3163020: Fix DictionaryValue::Equals() to also detect differences in key names. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix test expectations Created 10 years, 4 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 4b4016cc38cb2ca374c32907b954c56788ec88f6..3476d4ace37e8ca5fc29b3c659611011327d6563 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -485,21 +485,28 @@ TEST_F(ValuesTest, Equals) {
dv.SetString("d2", ASCIIToUTF16("http://google.com"));
dv.Set("e", Value::CreateNullValue());
- DictionaryValue* copy = static_cast<DictionaryValue*>(dv.DeepCopy());
- EXPECT_TRUE(dv.Equals(copy));
+ scoped_ptr<DictionaryValue> copy;
+ copy.reset(static_cast<DictionaryValue*>(dv.DeepCopy()));
+ EXPECT_TRUE(dv.Equals(copy.get()));
ListValue* list = new ListValue;
list->Append(Value::CreateNullValue());
list->Append(new DictionaryValue);
dv.Set("f", list);
- EXPECT_FALSE(dv.Equals(copy));
+ EXPECT_FALSE(dv.Equals(copy.get()));
copy->Set("f", list->DeepCopy());
- EXPECT_TRUE(dv.Equals(copy));
+ EXPECT_TRUE(dv.Equals(copy.get()));
list->Append(Value::CreateBooleanValue(true));
- EXPECT_FALSE(dv.Equals(copy));
- delete copy;
+ EXPECT_FALSE(dv.Equals(copy.get()));
+
+ // Check if Equals detects differences in only the keys.
+ copy.reset(static_cast<DictionaryValue*>(dv.DeepCopy()));
+ EXPECT_TRUE(dv.Equals(copy.get()));
+ copy->Remove("a", NULL);
+ copy->SetBoolean("aa", false);
+ EXPECT_FALSE(dv.Equals(copy.get()));
}
TEST_F(ValuesTest, RemoveEmptyChildren) {
« no previous file with comments | « base/values.cc ('k') | chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698