summaryrefslogtreecommitdiffstats
path: root/base/values_unittest.cc
diff options
context:
space:
mode:
authormitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 19:31:16 +0000
committermitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 19:31:16 +0000
commit00590b3d673c7b6bbe7bd96c29323794861a11f6 (patch)
treef7ada40e5edd1df6f4af01b45485840a12873ba6 /base/values_unittest.cc
parent8c7b4a9e6e01e4a902b4ef08bc8380f600fc0a15 (diff)
downloadchromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.zip
chromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.tar.gz
chromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.tar.bz2
Allowed BinaryValue to take a NULL buffer.
BUG=127630 Review URL: https://chromiumcodereview.appspot.com/10389088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r--base/values_unittest.cc30
1 files changed, 11 insertions, 19 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 9b92949..b0dd22e 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -105,23 +105,15 @@ TEST(ValuesTest, List) {
}
TEST(ValuesTest, BinaryValue) {
- char* buffer = NULL;
- // Passing a null buffer pointer doesn't yield a BinaryValue
- scoped_ptr<BinaryValue> binary(BinaryValue::Create(buffer, 0));
- ASSERT_FALSE(binary.get());
-
- // If you want to represent an empty binary value, use a zero-length buffer.
- buffer = new char[1];
- ASSERT_TRUE(buffer);
- binary.reset(BinaryValue::Create(buffer, 0));
+ // Default constructor creates a BinaryValue with a null buffer and size 0.
+ scoped_ptr<BinaryValue> binary(new BinaryValue());
ASSERT_TRUE(binary.get());
- ASSERT_TRUE(binary->GetBuffer());
- ASSERT_EQ(buffer, binary->GetBuffer());
+ ASSERT_EQ(NULL, binary->GetBuffer());
ASSERT_EQ(0U, binary->GetSize());
// Test the common case of a non-empty buffer
- buffer = new char[15];
- binary.reset(BinaryValue::Create(buffer, 15));
+ char* buffer = new char[15];
+ binary.reset(new BinaryValue(scoped_ptr<char>(buffer), 15));
ASSERT_TRUE(binary.get());
ASSERT_TRUE(binary->GetBuffer());
ASSERT_EQ(buffer, binary->GetBuffer());
@@ -350,9 +342,9 @@ TEST(ValuesTest, DeepCopy) {
Value::CreateStringValue(ASCIIToUTF16("hello16"));
original_dict.Set("string16", original_string16);
- char* original_buffer = new char[42];
- memset(original_buffer, '!', 42);
- BinaryValue* original_binary = BinaryValue::Create(original_buffer, 42);
+ scoped_ptr<char> original_buffer(new char[42]);
+ memset(original_buffer.get(), '!', 42);
+ BinaryValue* original_binary = new BinaryValue(original_buffer.Pass(), 42);
original_dict.Set("binary", original_binary);
ListValue* original_list = new ListValue();
@@ -558,9 +550,9 @@ TEST(ValuesTest, DeepCopyCovariantReturnTypes) {
Value::CreateStringValue(ASCIIToUTF16("hello16"));
original_dict.Set("string16", original_string16);
- char* original_buffer = new char[42];
- memset(original_buffer, '!', 42);
- BinaryValue* original_binary = BinaryValue::Create(original_buffer, 42);
+ scoped_ptr<char> original_buffer(new char[42]);
+ memset(original_buffer.get(), '!', 42);
+ BinaryValue* original_binary = new BinaryValue(original_buffer.Pass(), 42);
original_dict.Set("binary", original_binary);
ListValue* original_list = new ListValue();