summaryrefslogtreecommitdiffstats
path: root/base/pickle_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/pickle_unittest.cc')
-rw-r--r--base/pickle_unittest.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc
index 1ddbd22..1a98cd2 100644
--- a/base/pickle_unittest.cc
+++ b/base/pickle_unittest.cc
@@ -13,7 +13,7 @@
namespace {
const int testint = 2093847192;
-const std::string teststr("Hello world"); // note non-aligned string length
+const std::string teststr("Hello world"); // note non-aligned string length
const std::wstring testwstr(L"Hello, world");
const char testdata[] = "AAA\0BBB\0";
const int testdatalen = arraysize(testdata) - 1;
@@ -246,3 +246,16 @@ TEST(PickleTest, EvilLengths) {
EXPECT_FALSE(big_len.ReadWString(&iter, &wstr));
}
+// Check we can write zero bytes of data and 'data' can be NULL.
+TEST(PickleTest, ZeroLength) {
+ Pickle pickle;
+ EXPECT_TRUE(pickle.WriteData(NULL, 0));
+
+ void* iter = NULL;
+ const char* outdata;
+ int outdatalen;
+ EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
+ EXPECT_EQ(0, outdatalen);
+ // We can't assert that outdata is NULL.
+}
+