Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: webrtc/base/buffer_unittest.cc

Issue 2293983002: rtc::Buffer: Let SetData and AppendData accept anything with .data() and .size() (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/base/buffer.h ('K') | « webrtc/base/buffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/buffer_unittest.cc
diff --git a/webrtc/base/buffer_unittest.cc b/webrtc/base/buffer_unittest.cc
index bd095a6b0954a5a9dc907ba7aeb4e9db38bc5ae3..e99faffdcc7c933eab6625b2c06c39b4baa201a6 100644
--- a/webrtc/base/buffer_unittest.cc
+++ b/webrtc/base/buffer_unittest.cc
@@ -9,6 +9,8 @@
*/
#include "webrtc/base/buffer.h"
+
+#include "webrtc/base/array_view.h"
#include "webrtc/base/gunit.h"
#include <type_traits>
@@ -70,6 +72,11 @@ TEST(BufferTest, TestSetData) {
EXPECT_EQ(buf.size(), 9u);
EXPECT_EQ(buf.capacity(), 7u * 3 / 2);
EXPECT_EQ(0, memcmp(buf.data(), kTestData, 9));
+ Buffer buf2;
ossu 2016/08/31 09:31:03 Do you want to test this with an unrelated class a
kwiberg-webrtc 2016/09/01 09:23:53 Done.
+ buf2.SetData(buf);
+ EXPECT_EQ(buf.size(), 9u);
+ EXPECT_EQ(buf.capacity(), 7u * 3 / 2);
+ EXPECT_EQ(0, memcmp(buf.data(), kTestData, 9));
}
TEST(BufferTest, TestAppendData) {
@@ -77,6 +84,11 @@ TEST(BufferTest, TestAppendData) {
buf.AppendData(kTestData + 10, 2);
const int8_t exp[] = {0x4, 0x5, 0x6, 0xa, 0xb};
EXPECT_EQ(buf, Buffer(exp));
+ Buffer buf2;
+ buf2.AppendData(buf);
+ buf2.AppendData(rtc::ArrayView<uint8_t>(buf));
+ const int8_t exp2[] = {0x4, 0x5, 0x6, 0xa, 0xb, 0x4, 0x5, 0x6, 0xa, 0xb};
+ EXPECT_EQ(buf2, Buffer(exp2));
}
TEST(BufferTest, TestSetSizeSmaller) {
« webrtc/base/buffer.h ('K') | « webrtc/base/buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698