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

Side by Side Diff: base/prefs/pref_value_map_unittest.cc

Issue 390233003: Decrement CreateDoubleValue count (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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/prefs/pref_value_map.cc ('k') | cc/base/math_util.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/prefs/pref_value_map.h" 5 #include "base/prefs/pref_value_map.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 19 matching lines...) Expand all
30 30
31 int int_value = 0; 31 int int_value = 0;
32 EXPECT_TRUE(map.GetInteger("key", &int_value)); 32 EXPECT_TRUE(map.GetInteger("key", &int_value));
33 EXPECT_EQ(5, int_value); 33 EXPECT_EQ(5, int_value);
34 34
35 map.SetInteger("key", -14); 35 map.SetInteger("key", -14);
36 EXPECT_TRUE(map.GetInteger("key", &int_value)); 36 EXPECT_TRUE(map.GetInteger("key", &int_value));
37 EXPECT_EQ(-14, int_value); 37 EXPECT_EQ(-14, int_value);
38 } 38 }
39 39
40 TEST(PrefValueMapTest, SetDoubleValue) {
41 PrefValueMap map;
42 ASSERT_TRUE(map.SetValue("key", new FundamentalValue(5.5)));
43
44 const Value* result = NULL;
45 ASSERT_TRUE(map.GetValue("key", &result));
46 double double_value = 0.;
47 EXPECT_TRUE(result->GetAsDouble(&double_value));
48 EXPECT_DOUBLE_EQ(5.5, double_value);
49 }
50
40 TEST(PrefValueMapTest, RemoveValue) { 51 TEST(PrefValueMapTest, RemoveValue) {
41 PrefValueMap map; 52 PrefValueMap map;
42 EXPECT_FALSE(map.RemoveValue("key")); 53 EXPECT_FALSE(map.RemoveValue("key"));
43 54
44 EXPECT_TRUE(map.SetValue("key", new StringValue("test"))); 55 EXPECT_TRUE(map.SetValue("key", new StringValue("test")));
45 EXPECT_TRUE(map.GetValue("key", NULL)); 56 EXPECT_TRUE(map.GetValue("key", NULL));
46 57
47 EXPECT_TRUE(map.RemoveValue("key")); 58 EXPECT_TRUE(map.RemoveValue("key"));
48 EXPECT_FALSE(map.GetValue("key", NULL)); 59 EXPECT_FALSE(map.GetValue("key", NULL));
49 60
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 EXPECT_TRUE(first_map.GetValue("e", NULL)); 117 EXPECT_TRUE(first_map.GetValue("e", NULL));
107 EXPECT_TRUE(first_map.GetValue("f", NULL)); 118 EXPECT_TRUE(first_map.GetValue("f", NULL));
108 119
109 EXPECT_TRUE(second_map.GetValue("a", NULL)); 120 EXPECT_TRUE(second_map.GetValue("a", NULL));
110 EXPECT_TRUE(second_map.GetValue("b", NULL)); 121 EXPECT_TRUE(second_map.GetValue("b", NULL));
111 EXPECT_TRUE(second_map.GetValue("c", NULL)); 122 EXPECT_TRUE(second_map.GetValue("c", NULL));
112 } 123 }
113 124
114 } // namespace 125 } // namespace
115 } // namespace base 126 } // namespace base
OLDNEW
« no previous file with comments | « base/prefs/pref_value_map.cc ('k') | cc/base/math_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698