Allow CopyOnWriteBuffer to accept vector-like types.

Bug: none
Change-Id: I03ee91be151e10d6b0385b462158ecd0bd9ad4ed
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232129
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35039}
This commit is contained in:
philipel
2021-09-20 11:22:13 +02:00
committed by WebRTC LUCI CQ
parent bc7666be51
commit afc237751a
2 changed files with 40 additions and 2 deletions

View File

@ -353,4 +353,24 @@ TEST(CopyOnWriteBufferTest, SlicesAreIndependent) {
EXPECT_EQ(buf.cdata() + 3, slice.cdata());
}
TEST(CopyOnWriteBufferTest, AcceptsVectorLikeTypes) {
std::vector<uint8_t> a = {1, 2};
std::vector<int8_t> b = {3, 4};
rtc::ArrayView<uint8_t> c(a);
rtc::ArrayView<const int8_t> d(b);
CopyOnWriteBuffer a_buf(a);
CopyOnWriteBuffer b_buf(b);
CopyOnWriteBuffer c_buf(c);
CopyOnWriteBuffer d_buf(d);
CopyOnWriteBuffer all;
all.AppendData(a);
all.AppendData(b);
all.AppendData(c);
all.AppendData(d);
EXPECT_EQ(all.size(), 8U);
}
} // namespace rtc