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

Unified Diff: base/values_unittest.cc

Issue 18200: Flesh out ListValue class. (Closed)
Patch Set: Created 11 years, 11 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 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 1a7808945c87e60eb35ba226b61961080dfd7303..ac1ff444eaab1c86d427bd31ae22000a7f3e1f62 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
« 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