diff options
Diffstat (limited to 'base/pickle_unittest.cc')
-rw-r--r-- | base/pickle_unittest.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc index b0a8f21..6f9fcc7 100644 --- a/base/pickle_unittest.cc +++ b/base/pickle_unittest.cc @@ -428,4 +428,18 @@ TEST(PickleTest, ReadBytes) { EXPECT_EQ(data, outdata); } +// Checks that when a pickle is deep-copied, the result is not larger than +// needed. +TEST(PickleTest, DeepCopyResize) { + Pickle pickle; + while (pickle.capacity_after_header() != pickle.payload_size()) + pickle.WriteBool(true); + + // Make a deep copy. + Pickle pickle2(pickle); + + // Check that there isn't any extraneous capacity. + EXPECT_EQ(pickle.capacity_after_header(), pickle2.capacity_after_header()); +} + } // namespace base |