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

Unified Diff: base/values_unittest.cc

Issue 8701002: Value::GetAsDictionary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pacify clang Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/values.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values_unittest.cc
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 806347c9387a317df0e895de2bed6fdef56b6cff..ff6f4a50284c41dab6a0e86b151ee4644385f796 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -362,6 +362,10 @@ TEST(ValuesTest, DeepCopy) {
original_list->Append(original_list_element_1);
original_dict.Set("list", original_list);
+ DictionaryValue* original_nested_dictionary = new DictionaryValue();
+ original_nested_dictionary->Set("key", Value::CreateStringValue("value"));
+ original_dict.Set("dictionary", original_nested_dictionary);
+
scoped_ptr<DictionaryValue> copy_dict(original_dict.DeepCopy());
ASSERT_TRUE(copy_dict.get());
ASSERT_NE(copy_dict.get(), &original_dict);
@@ -439,7 +443,9 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_TRUE(copy_value);
ASSERT_NE(copy_value, original_list);
ASSERT_TRUE(copy_value->IsType(Value::TYPE_LIST));
- ListValue* copy_list = static_cast<ListValue*>(copy_value);
+ ListValue* copy_list = NULL;
+ ASSERT_TRUE(copy_value->GetAsList(&copy_list));
+ ASSERT_TRUE(copy_list);
ASSERT_EQ(2U, copy_list->GetSize());
Value* copy_list_element_0;
@@ -457,6 +463,16 @@ TEST(ValuesTest, DeepCopy) {
int copy_list_element_1_value;
ASSERT_TRUE(copy_list_element_1->GetAsInteger(&copy_list_element_1_value));
ASSERT_EQ(1, copy_list_element_1_value);
+
+ copy_value = NULL;
+ ASSERT_TRUE(copy_dict->Get("dictionary", &copy_value));
+ ASSERT_TRUE(copy_value);
+ ASSERT_NE(copy_value, original_nested_dictionary);
+ ASSERT_TRUE(copy_value->IsType(Value::TYPE_DICTIONARY));
+ DictionaryValue* copy_nested_dictionary = NULL;
+ ASSERT_TRUE(copy_value->GetAsDictionary(&copy_nested_dictionary));
+ ASSERT_TRUE(copy_nested_dictionary);
+ EXPECT_TRUE(copy_nested_dictionary->HasKey("key"));
}
TEST(ValuesTest, Equals) {
« no previous file with comments | « base/values.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698