Index: base/pickle_unittest.cc |
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc |
index b0a8f21f89f9282d5d6783eaf13d49e43f837a6e..6f9fcc7f62ad898bf4b7de91aee43faafddbda6d 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 |