Index: webrtc/base/copyonwritebuffer_unittest.cc |
diff --git a/webrtc/base/copyonwritebuffer_unittest.cc b/webrtc/base/copyonwritebuffer_unittest.cc |
index a95ad67a03e6ec2c41ad1210d3ae241f590ed3e7..21ac73198f5843bd85b78d864c6e590d944058e8 100644 |
--- a/webrtc/base/copyonwritebuffer_unittest.cc |
+++ b/webrtc/base/copyonwritebuffer_unittest.cc |
@@ -41,6 +41,13 @@ void EnsureBuffersDontShareData(const CopyOnWriteBuffer& buf1, |
EXPECT_NE(data1, data2); |
} |
+TEST(CopyOnWriteBufferTest, TestCreateEmptyData) { |
+ CopyOnWriteBuffer buf(static_cast<const uint8_t*>(nullptr), 0); |
+ EXPECT_EQ(buf.size(), 0u); |
+ EXPECT_EQ(buf.capacity(), 0u); |
+ EXPECT_EQ(buf.data(), nullptr); |
+} |
+ |
TEST(CopyOnWriteBufferTest, TestMoveConstruct) { |
CopyOnWriteBuffer buf1(kTestData, 3, 10); |
size_t buf1_size = buf1.size(); |
@@ -125,6 +132,21 @@ TEST(CopyOnWriteBufferTest, TestSetData) { |
EnsureBuffersDontShareData(buf1, buf3); |
const int8_t exp[] = {'f', 'o', 'o', 0x0}; |
EXPECT_EQ(buf3, CopyOnWriteBuffer(exp)); |
+ |
+ buf2.SetData(static_cast<const uint8_t*>(nullptr), 0u); |
+ EnsureBuffersDontShareData(buf1, buf2); |
+ EXPECT_EQ(buf1.size(), 3u); |
+ EXPECT_EQ(buf1.capacity(), 10u); |
+ EXPECT_EQ(buf2.size(), 0u); |
+ EXPECT_EQ(buf2.capacity(), 0u); |
+} |
+ |
+TEST(CopyOnWriteBufferTest, TestSetDataEmpty) { |
+ CopyOnWriteBuffer buf; |
+ buf.SetData(static_cast<const uint8_t*>(nullptr), 0u); |
+ EXPECT_EQ(buf.size(), 0u); |
+ EXPECT_EQ(buf.capacity(), 0u); |
+ EXPECT_EQ(buf.data(), nullptr); |
} |
TEST(CopyOnWriteBufferTest, TestEnsureCapacity) { |