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

Side by Side 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 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 | Annotate | Revision Log
« no previous file with comments | « base/values.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits> 5 #include <limits>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 EXPECT_EQ(1U, value2->size()); 316 EXPECT_EQ(1U, value2->size());
317 317
318 EXPECT_TRUE(dict.HasKey("this.isnt.expanded")); 318 EXPECT_TRUE(dict.HasKey("this.isnt.expanded"));
319 Value* value3; 319 Value* value3;
320 EXPECT_FALSE(dict.Get("this.isnt.expanded", &value3)); 320 EXPECT_FALSE(dict.Get("this.isnt.expanded", &value3));
321 Value* value4; 321 Value* value4;
322 ASSERT_TRUE(dict.GetWithoutPathExpansion("this.isnt.expanded", &value4)); 322 ASSERT_TRUE(dict.GetWithoutPathExpansion("this.isnt.expanded", &value4));
323 EXPECT_EQ(Value::TYPE_NULL, value4->GetType()); 323 EXPECT_EQ(Value::TYPE_NULL, value4->GetType());
324 } 324 }
325 325
326 TEST(ValuesTest, DictionaryRemovePath) {
327 DictionaryValue dict;
328 dict.Set("a.long.way.down", Value::CreateIntegerValue(1));
329 dict.Set("a.long.key.path", Value::CreateBooleanValue(true));
330
331 scoped_ptr<Value> removed_item;
332 EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item));
333 ASSERT_TRUE(removed_item);
334 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER));
335 EXPECT_FALSE(dict.HasKey("a.long.way.down"));
336 EXPECT_FALSE(dict.HasKey("a.long.way"));
337 EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
338
339 removed_item.reset();
340 EXPECT_FALSE(dict.RemovePath("a.long.way.down", &removed_item));
341 EXPECT_FALSE(removed_item);
342 EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
343
344 removed_item.reset();
345 EXPECT_TRUE(dict.RemovePath("a.long.key.path", &removed_item));
346 ASSERT_TRUE(removed_item);
347 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_BOOLEAN));
348 EXPECT_TRUE(dict.empty());
349 }
350
326 TEST(ValuesTest, DeepCopy) { 351 TEST(ValuesTest, DeepCopy) {
327 DictionaryValue original_dict; 352 DictionaryValue original_dict;
328 Value* original_null = Value::CreateNullValue(); 353 Value* original_null = Value::CreateNullValue();
329 original_dict.Set("null", original_null); 354 original_dict.Set("null", original_null);
330 FundamentalValue* original_bool = new FundamentalValue(true); 355 FundamentalValue* original_bool = new FundamentalValue(true);
331 original_dict.Set("bool", original_bool); 356 original_dict.Set("bool", original_bool);
332 FundamentalValue* original_int = new FundamentalValue(42); 357 FundamentalValue* original_int = new FundamentalValue(42);
333 original_dict.Set("int", original_int); 358 original_dict.Set("int", original_int);
334 FundamentalValue* original_double = new FundamentalValue(3.14); 359 FundamentalValue* original_double = new FundamentalValue(3.14);
335 original_dict.Set("double", original_double); 360 original_dict.Set("double", original_double);
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 seen2 = true; 792 seen2 = true;
768 } else { 793 } else {
769 ADD_FAILURE(); 794 ADD_FAILURE();
770 } 795 }
771 } 796 }
772 EXPECT_TRUE(seen1); 797 EXPECT_TRUE(seen1);
773 EXPECT_TRUE(seen2); 798 EXPECT_TRUE(seen2);
774 } 799 }
775 800
776 } // namespace base 801 } // namespace base
OLDNEW
« 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