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

Unified Diff: base/values_unittest.cc

Issue 81183005: Remove JsonPrefStore pruning of empty values on write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove else Created 7 years, 1 month 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
« no previous file with comments | « base/values.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values_unittest.cc
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 733c485d2b1aca599dcb917edf179728bef6bbc9..70acdfd6966aaf124b59e3b0b94640674bc0f489 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -323,6 +323,31 @@ TEST(ValuesTest, DictionaryWithoutPathExpansion) {
EXPECT_EQ(Value::TYPE_NULL, value4->GetType());
}
+TEST(ValuesTest, DictionaryRemovePath) {
+ DictionaryValue dict;
+ dict.Set("a.long.way.down", Value::CreateIntegerValue(1));
+ dict.Set("a.long.key.path", Value::CreateBooleanValue(true));
+
+ scoped_ptr<Value> removed_item;
+ EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item));
+ ASSERT_TRUE(removed_item);
+ EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER));
+ EXPECT_FALSE(dict.HasKey("a.long.way.down"));
+ EXPECT_FALSE(dict.HasKey("a.long.way"));
+ EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
+
+ removed_item.reset();
+ EXPECT_FALSE(dict.RemovePath("a.long.way.down", &removed_item));
+ EXPECT_FALSE(removed_item);
+ EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
+
+ removed_item.reset();
+ EXPECT_TRUE(dict.RemovePath("a.long.key.path", &removed_item));
+ ASSERT_TRUE(removed_item);
+ EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_BOOLEAN));
+ EXPECT_TRUE(dict.empty());
+}
+
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
Value* original_null = Value::CreateNullValue();
« no previous file with comments | « base/values.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698