diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 21:00:03 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 21:00:03 +0000 |
commit | e64ff5ef1675d78a38a251eb98dba2e0c8af61b7 (patch) | |
tree | 1805281e1444b202ee9dd3c845766a6d6d731ddd /base/pickle_unittest.cc | |
parent | b572562659e2b46d99ee2a049e57f5d3dd28e0a7 (diff) | |
download | chromium_src-e64ff5ef1675d78a38a251eb98dba2e0c8af61b7.zip chromium_src-e64ff5ef1675d78a38a251eb98dba2e0c8af61b7.tar.gz chromium_src-e64ff5ef1675d78a38a251eb98dba2e0c8af61b7.tar.bz2 |
WriteData and BeginWriteData should fail if length is
negative.
Add a unit test for WriteData(NULL, 0).
R=darin
BUG=none
TEST=new unit test should pass
Review URL: http://codereview.chromium.org/159310
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle_unittest.cc')
-rw-r--r-- | base/pickle_unittest.cc | 15 |
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. +} + |