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

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

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 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 unified diff | Download patch
« no previous file with comments | « components/prefs/pref_value_map.cc ('k') | components/prefs/pref_value_store_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) 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 "components/prefs/pref_value_map.h" 5 #include "components/prefs/pref_value_map.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace base { 11 namespace base {
12 namespace { 12 namespace {
13 13
14 TEST(PrefValueMapTest, SetValue) { 14 TEST(PrefValueMapTest, SetValue) {
15 PrefValueMap map; 15 PrefValueMap map;
16 const Value* result = NULL; 16 const Value* result = NULL;
17 EXPECT_FALSE(map.GetValue("key", &result)); 17 EXPECT_FALSE(map.GetValue("key", &result));
18 EXPECT_FALSE(result); 18 EXPECT_FALSE(result);
19 19
20 EXPECT_TRUE(map.SetValue("key", base::MakeUnique<StringValue>("test"))); 20 EXPECT_TRUE(map.SetValue("key", base::MakeUnique<StringValue>("test")));
21 EXPECT_FALSE(map.SetValue("key", base::MakeUnique<StringValue>("test"))); 21 EXPECT_FALSE(map.SetValue("key", base::MakeUnique<StringValue>("test")));
22 EXPECT_TRUE(map.SetValue("key", base::MakeUnique<StringValue>("hi mom!"))); 22 EXPECT_TRUE(map.SetValue("key", base::MakeUnique<StringValue>("hi mom!")));
23 23
24 EXPECT_TRUE(map.GetValue("key", &result)); 24 EXPECT_TRUE(map.GetValue("key", &result));
25 EXPECT_TRUE(StringValue("hi mom!").Equals(result)); 25 EXPECT_TRUE(StringValue("hi mom!").Equals(result));
26 } 26 }
27 27
28 TEST(PrefValueMapTest, GetAndSetIntegerValue) { 28 TEST(PrefValueMapTest, GetAndSetIntegerValue) {
29 PrefValueMap map; 29 PrefValueMap map;
30 ASSERT_TRUE(map.SetValue("key", base::MakeUnique<FundamentalValue>(5))); 30 ASSERT_TRUE(map.SetValue("key", base::MakeUnique<Value>(5)));
31 31
32 int int_value = 0; 32 int int_value = 0;
33 EXPECT_TRUE(map.GetInteger("key", &int_value)); 33 EXPECT_TRUE(map.GetInteger("key", &int_value));
34 EXPECT_EQ(5, int_value); 34 EXPECT_EQ(5, int_value);
35 35
36 map.SetInteger("key", -14); 36 map.SetInteger("key", -14);
37 EXPECT_TRUE(map.GetInteger("key", &int_value)); 37 EXPECT_TRUE(map.GetInteger("key", &int_value));
38 EXPECT_EQ(-14, int_value); 38 EXPECT_EQ(-14, int_value);
39 } 39 }
40 40
41 TEST(PrefValueMapTest, SetDoubleValue) { 41 TEST(PrefValueMapTest, SetDoubleValue) {
42 PrefValueMap map; 42 PrefValueMap map;
43 ASSERT_TRUE(map.SetValue("key", base::MakeUnique<FundamentalValue>(5.5))); 43 ASSERT_TRUE(map.SetValue("key", base::MakeUnique<Value>(5.5)));
44 44
45 const Value* result = NULL; 45 const Value* result = NULL;
46 ASSERT_TRUE(map.GetValue("key", &result)); 46 ASSERT_TRUE(map.GetValue("key", &result));
47 double double_value = 0.; 47 double double_value = 0.;
48 EXPECT_TRUE(result->GetAsDouble(&double_value)); 48 EXPECT_TRUE(result->GetAsDouble(&double_value));
49 EXPECT_DOUBLE_EQ(5.5, double_value); 49 EXPECT_DOUBLE_EQ(5.5, double_value);
50 } 50 }
51 51
52 TEST(PrefValueMapTest, RemoveValue) { 52 TEST(PrefValueMapTest, RemoveValue) {
53 PrefValueMap map; 53 PrefValueMap map;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_TRUE(first_map.GetValue("e", NULL)); 118 EXPECT_TRUE(first_map.GetValue("e", NULL));
119 EXPECT_TRUE(first_map.GetValue("f", NULL)); 119 EXPECT_TRUE(first_map.GetValue("f", NULL));
120 120
121 EXPECT_TRUE(second_map.GetValue("a", NULL)); 121 EXPECT_TRUE(second_map.GetValue("a", NULL));
122 EXPECT_TRUE(second_map.GetValue("b", NULL)); 122 EXPECT_TRUE(second_map.GetValue("b", NULL));
123 EXPECT_TRUE(second_map.GetValue("c", NULL)); 123 EXPECT_TRUE(second_map.GetValue("c", NULL));
124 } 124 }
125 125
126 } // namespace 126 } // namespace
127 } // namespace base 127 } // namespace base
OLDNEW
« no previous file with comments | « components/prefs/pref_value_map.cc ('k') | components/prefs/pref_value_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698