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

Side by Side Diff: base/values_unittest.cc

Issue 12092021: Remove PersistentPrefStore::MarkNeedsEmptyValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some tests. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « base/values.cc ('k') | chrome/browser/prefs/pref_service.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/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 EXPECT_EQ(1U, value2->size()); 318 EXPECT_EQ(1U, value2->size());
319 319
320 EXPECT_TRUE(dict.HasKey("this.isnt.expanded")); 320 EXPECT_TRUE(dict.HasKey("this.isnt.expanded"));
321 Value* value3; 321 Value* value3;
322 EXPECT_FALSE(dict.Get("this.isnt.expanded", &value3)); 322 EXPECT_FALSE(dict.Get("this.isnt.expanded", &value3));
323 Value* value4; 323 Value* value4;
324 ASSERT_TRUE(dict.GetWithoutPathExpansion("this.isnt.expanded", &value4)); 324 ASSERT_TRUE(dict.GetWithoutPathExpansion("this.isnt.expanded", &value4));
325 EXPECT_EQ(Value::TYPE_NULL, value4->GetType()); 325 EXPECT_EQ(Value::TYPE_NULL, value4->GetType());
326 } 326 }
327 327
328 TEST(ValuesTest, DictionaryRemovePath) {
329 DictionaryValue dict;
330 dict.Set("a.long.way.down", Value::CreateIntegerValue(1));
331 dict.Set("a.long.key.path", Value::CreateBooleanValue(true));
332
333 base::Value* out_value = NULL;
334 EXPECT_TRUE(dict.RemovePath("a.long.way.down", &out_value));
335 ASSERT_TRUE(out_value);
336 EXPECT_TRUE(out_value->IsType(base::Value::TYPE_INTEGER));
337 EXPECT_FALSE(dict.HasKey("a.long.way.down"));
338 EXPECT_FALSE(dict.HasKey("a.long.way"));
339 EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
340
341 out_value = NULL;
342 EXPECT_FALSE(dict.RemovePath("a.long.way.down", &out_value));
343 EXPECT_FALSE(out_value);
344 EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
345
346 out_value = NULL;
347 EXPECT_TRUE(dict.RemovePath("a.long.key.path", &out_value));
348 ASSERT_TRUE(out_value);
349 EXPECT_TRUE(out_value->IsType(base::Value::TYPE_BOOLEAN));
350 EXPECT_TRUE(dict.empty());
351 }
352
328 TEST(ValuesTest, DeepCopy) { 353 TEST(ValuesTest, DeepCopy) {
329 DictionaryValue original_dict; 354 DictionaryValue original_dict;
330 Value* original_null = Value::CreateNullValue(); 355 Value* original_null = Value::CreateNullValue();
331 original_dict.Set("null", original_null); 356 original_dict.Set("null", original_null);
332 FundamentalValue* original_bool = new FundamentalValue(true); 357 FundamentalValue* original_bool = new FundamentalValue(true);
333 original_dict.Set("bool", original_bool); 358 original_dict.Set("bool", original_bool);
334 FundamentalValue* original_int = new FundamentalValue(42); 359 FundamentalValue* original_int = new FundamentalValue(42);
335 original_dict.Set("int", original_int); 360 original_dict.Set("int", original_int);
336 FundamentalValue* original_double = new FundamentalValue(3.14); 361 FundamentalValue* original_double = new FundamentalValue(3.14);
337 original_dict.Set("double", original_double); 362 original_dict.Set("double", original_double);
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 seen2 = true; 794 seen2 = true;
770 } else { 795 } else {
771 ADD_FAILURE(); 796 ADD_FAILURE();
772 } 797 }
773 } 798 }
774 EXPECT_TRUE(seen1); 799 EXPECT_TRUE(seen1);
775 EXPECT_TRUE(seen2); 800 EXPECT_TRUE(seen2);
776 } 801 }
777 802
778 } // namespace base 803 } // namespace base
OLDNEW
« no previous file with comments | « base/values.cc ('k') | chrome/browser/prefs/pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698