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

Side by Side Diff: base/values_unittest.cc

Issue 131503015: Get rid of some uses of base::Create*Value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 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') | cc/resources/managed_tile_state.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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 memset(stack_buffer, '!', 42); 123 memset(stack_buffer, '!', 42);
124 binary.reset(BinaryValue::CreateWithCopiedBuffer(stack_buffer, 42)); 124 binary.reset(BinaryValue::CreateWithCopiedBuffer(stack_buffer, 42));
125 ASSERT_TRUE(binary.get()); 125 ASSERT_TRUE(binary.get());
126 ASSERT_TRUE(binary->GetBuffer()); 126 ASSERT_TRUE(binary->GetBuffer());
127 ASSERT_NE(stack_buffer, binary->GetBuffer()); 127 ASSERT_NE(stack_buffer, binary->GetBuffer());
128 ASSERT_EQ(42U, binary->GetSize()); 128 ASSERT_EQ(42U, binary->GetSize());
129 ASSERT_EQ(0, memcmp(stack_buffer, binary->GetBuffer(), binary->GetSize())); 129 ASSERT_EQ(0, memcmp(stack_buffer, binary->GetBuffer(), binary->GetSize()));
130 } 130 }
131 131
132 TEST(ValuesTest, StringValue) { 132 TEST(ValuesTest, StringValue) {
133 // Test overloaded CreateStringValue. 133 // Test overloaded StringValue constructor.
134 scoped_ptr<Value> narrow_value(new StringValue("narrow")); 134 scoped_ptr<Value> narrow_value(new StringValue("narrow"));
135 ASSERT_TRUE(narrow_value.get()); 135 ASSERT_TRUE(narrow_value.get());
136 ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING)); 136 ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING));
137 scoped_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16"))); 137 scoped_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16")));
138 ASSERT_TRUE(utf16_value.get()); 138 ASSERT_TRUE(utf16_value.get());
139 ASSERT_TRUE(utf16_value->IsType(Value::TYPE_STRING)); 139 ASSERT_TRUE(utf16_value->IsType(Value::TYPE_STRING));
140 140
141 // Test overloaded GetString. 141 // Test overloaded GetString.
142 std::string narrow = "http://google.com"; 142 std::string narrow = "http://google.com";
143 string16 utf16 = ASCIIToUTF16("http://google.com"); 143 string16 utf16 = ASCIIToUTF16("http://google.com");
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 326 TEST(ValuesTest, DictionaryRemovePath) {
327 DictionaryValue dict; 327 DictionaryValue dict;
328 dict.Set("a.long.way.down", Value::CreateIntegerValue(1)); 328 dict.Set("a.long.way.down", new FundamentalValue(1));
329 dict.Set("a.long.key.path", Value::CreateBooleanValue(true)); 329 dict.Set("a.long.key.path", new FundamentalValue(true));
330 330
331 scoped_ptr<Value> removed_item; 331 scoped_ptr<Value> removed_item;
332 EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item)); 332 EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item));
333 ASSERT_TRUE(removed_item); 333 ASSERT_TRUE(removed_item);
334 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER)); 334 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER));
335 EXPECT_FALSE(dict.HasKey("a.long.way.down")); 335 EXPECT_FALSE(dict.HasKey("a.long.way.down"));
336 EXPECT_FALSE(dict.HasKey("a.long.way")); 336 EXPECT_FALSE(dict.HasKey("a.long.way"));
337 EXPECT_TRUE(dict.Get("a.long.key.path", NULL)); 337 EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
338 338
339 removed_item.reset(); 339 removed_item.reset();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 seen2 = true; 792 seen2 = true;
793 } else { 793 } else {
794 ADD_FAILURE(); 794 ADD_FAILURE();
795 } 795 }
796 } 796 }
797 EXPECT_TRUE(seen1); 797 EXPECT_TRUE(seen1);
798 EXPECT_TRUE(seen2); 798 EXPECT_TRUE(seen2);
799 } 799 }
800 800
801 } // namespace base 801 } // namespace base
OLDNEW
« no previous file with comments | « base/values.cc ('k') | cc/resources/managed_tile_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698