diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 21:05:32 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 21:05:32 +0000 |
commit | f82fb495a3ccffc3d2a9fbb215a2e1723acee954 (patch) | |
tree | 99c7d26f6fdbeef40235751cb9344c537e83df49 /base/values_unittest.cc | |
parent | d1afe0ea2e4df1543bc3f67d2f191b6c032ce119 (diff) | |
download | chromium_src-f82fb495a3ccffc3d2a9fbb215a2e1723acee954.zip chromium_src-f82fb495a3ccffc3d2a9fbb215a2e1723acee954.tar.gz chromium_src-f82fb495a3ccffc3d2a9fbb215a2e1723acee954.tar.bz2 |
Flesh out ListValue class.
Review URL: http://codereview.chromium.org/18200
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r-- | base/values_unittest.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 1a78089..ac1ff44 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -5,6 +5,7 @@ #include <limits> #include "base/values.h" +#include "base/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" class ValuesTest: public testing::Test { @@ -55,6 +56,41 @@ TEST(ValuesTest, Basic) { ASSERT_EQ(std::wstring(L"http://froogle.com"), bookmark_url); } +TEST(ValuesTest, List) { + scoped_ptr<ListValue> mixed_list(new ListValue()); + mixed_list->Set(0, Value::CreateBooleanValue(true)); + mixed_list->Set(1, Value::CreateIntegerValue(42)); + mixed_list->Set(2, Value::CreateRealValue(88.8)); + mixed_list->Set(3, Value::CreateStringValue("foo")); + ASSERT_EQ(4u, mixed_list->GetSize()); + + Value *value = NULL; + bool bool_value = false; + int int_value = 0; + double double_value = 0.0; + std::string string_value; + + ASSERT_FALSE(mixed_list->Get(4, &value)); + + ASSERT_FALSE(mixed_list->GetInteger(0, &int_value)); + ASSERT_EQ(0, int_value); + ASSERT_FALSE(mixed_list->GetReal(1, &double_value)); + ASSERT_EQ(0.0, double_value); + ASSERT_FALSE(mixed_list->GetString(2, &string_value)); + ASSERT_EQ("", string_value); + ASSERT_FALSE(mixed_list->GetBoolean(3, &bool_value)); + ASSERT_EQ(false, bool_value); + + ASSERT_TRUE(mixed_list->GetBoolean(0, &bool_value)); + ASSERT_EQ(true, bool_value); + ASSERT_TRUE(mixed_list->GetInteger(1, &int_value)); + ASSERT_EQ(42, int_value); + ASSERT_TRUE(mixed_list->GetReal(2, &double_value)); + ASSERT_EQ(88.8, double_value); + ASSERT_TRUE(mixed_list->GetString(3, &string_value)); + ASSERT_EQ("foo", string_value); +} + TEST(ValuesTest, BinaryValue) { char* buffer = NULL; // Passing a null buffer pointer doesn't yield a BinaryValue |