Index: webrtc/base/buffer_unittest.cc |
diff --git a/webrtc/base/buffer_unittest.cc b/webrtc/base/buffer_unittest.cc |
index 0b93b9b56e8d54afdd4b5d89964023f75c0cbb5f..f917bc6181e3a1394e0c08208d6febb50441ffca 100644 |
--- a/webrtc/base/buffer_unittest.cc |
+++ b/webrtc/base/buffer_unittest.cc |
@@ -177,4 +177,16 @@ TEST(BufferTest, TestSwap) { |
EXPECT_EQ(buf2.data(), data1); |
} |
+TEST(BufferTest, TestClear) { |
+ Buffer buf; |
+ buf.SetData(kTestData, 15); |
+ EXPECT_EQ(buf.size(), 15u); |
+ EXPECT_EQ(buf.capacity(), 15u); |
+ const char *data = buf.data<char>(); |
+ buf.Clear(); |
+ EXPECT_EQ(buf.size(), 0u); |
+ EXPECT_EQ(buf.capacity(), 15u); // Hasn't shrunk. |
+ EXPECT_EQ(buf.data<char>(), data); // No reallocation. |
+} |
+ |
} // namespace rtc |