summaryrefslogtreecommitdiffstats
path: root/base/values_unittest.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 20:47:52 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 20:47:52 +0000
commit4dad9ad838f6671fbd67e1c5292525e739e31983 (patch)
tree4d79fc17f12752cc221e0e40d16951677da71f92 /base/values_unittest.cc
parent2b3f0f59a6761a41e22007c2c3096e8e18517e08 (diff)
downloadchromium_src-4dad9ad838f6671fbd67e1c5292525e739e31983.zip
chromium_src-4dad9ad838f6671fbd67e1c5292525e739e31983.tar.gz
chromium_src-4dad9ad838f6671fbd67e1c5292525e739e31983.tar.bz2
Many changes to DictionaryValues:
* Add support for keys with "." in them via new XXXWithoutPathExpansion() APIs. * Use these APIs with all key iterator usage. * SetXXX() calls cannot fail, so change them from bool to void. * Change GetSize() to size() since it's cheap, and add empty(). Other: * Use standard for loop format in more places (e.g. instead of while loops when they're really doing a for loop). * Shorten a few bits of code. BUG=567 TEST=none Review URL: http://codereview.chromium.org/441008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r--base/values_unittest.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 5253eca..0182d76 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -20,9 +20,9 @@ TEST(ValuesTest, Basic) {
ASSERT_EQ(std::wstring(L"http://google.com"), homepage);
ASSERT_FALSE(settings.Get(L"global", NULL));
- ASSERT_TRUE(settings.Set(L"global", Value::CreateBooleanValue(true)));
+ settings.Set(L"global", Value::CreateBooleanValue(true));
ASSERT_TRUE(settings.Get(L"global", NULL));
- ASSERT_TRUE(settings.SetString(L"global.homepage", L"http://scurvy.com"));
+ settings.SetString(L"global.homepage", L"http://scurvy.com");
ASSERT_TRUE(settings.Get(L"global", NULL));
homepage = L"http://google.com";
ASSERT_TRUE(settings.GetString(L"global.homepage", &homepage));
@@ -285,6 +285,28 @@ TEST(ValuesTest, DictionaryRemoval) {
}
}
+TEST(ValuesTest, DictionaryWithoutPathExpansion) {
+ DictionaryValue dict;
+ dict.Set(L"this.is.expanded", Value::CreateNullValue());
+ dict.SetWithoutPathExpansion(L"this.isnt.expanded", Value::CreateNullValue());
+
+ EXPECT_FALSE(dict.HasKey(L"this.is.expanded"));
+ EXPECT_TRUE(dict.HasKey(L"this"));
+ Value* value1;
+ EXPECT_TRUE(dict.Get(L"this", &value1));
+ DictionaryValue* value2;
+ ASSERT_TRUE(dict.GetDictionaryWithoutPathExpansion(L"this", &value2));
+ EXPECT_EQ(value1, value2);
+ EXPECT_EQ(1U, value2->size());
+
+ EXPECT_TRUE(dict.HasKey(L"this.isnt.expanded"));
+ Value* value3;
+ EXPECT_FALSE(dict.Get(L"this.isnt.expanded", &value3));
+ Value* value4;
+ ASSERT_TRUE(dict.GetWithoutPathExpansion(L"this.isnt.expanded", &value4));
+ EXPECT_EQ(Value::TYPE_NULL, value4->GetType());
+}
+
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
Value* original_null = Value::CreateNullValue();