diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-26 01:11:44 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-26 01:11:44 +0000 |
commit | 5cf906f8476ea5d718bc676e622a04ec153e95f7 (patch) | |
tree | b37dca65e384cc7a5a86dffcf8fed12cf31c9025 /base/values_unittest.cc | |
parent | 1c669f135def144fba217cb04e2e668144bf0177 (diff) | |
download | chromium_src-5cf906f8476ea5d718bc676e622a04ec153e95f7.zip chromium_src-5cf906f8476ea5d718bc676e622a04ec153e95f7.tar.gz chromium_src-5cf906f8476ea5d718bc676e622a04ec153e95f7.tar.bz2 |
Value::GetAsDictionary
BUG=none
TEST=no
Review URL: http://codereview.chromium.org/8701002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r-- | base/values_unittest.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 806347c..ff6f4a5 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(©_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(©_list_element_1_value)); ASSERT_EQ(1, copy_list_element_1_value); + + copy_value = NULL; + ASSERT_TRUE(copy_dict->Get("dictionary", ©_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(©_nested_dictionary)); + ASSERT_TRUE(copy_nested_dictionary); + EXPECT_TRUE(copy_nested_dictionary->HasKey("key")); } TEST(ValuesTest, Equals) { |