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

Unified Diff: webrtc/base/buffer_unittest.cc

Issue 1745033002: Added an operator[] to Buffer, to make reading data easier. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added DCHECKs for index against size_ Created 4 years, 10 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
« no previous file with comments | « 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 6e9e7bf7baf3fae51cbb88acfd86afc385e9a789..80d26927a227c91d24ee07e389c55c9e1691e6ba 100644
--- a/webrtc/base/buffer_unittest.cc
+++ b/webrtc/base/buffer_unittest.cc
@@ -279,4 +279,43 @@ TEST(BufferTest, TestMutableLambdaSetAppend) {
}
}
+TEST(BufferTest, TestBracketRead) {
+ Buffer buf(kTestData, 7);
+ EXPECT_EQ(buf.size(), 7u);
+ EXPECT_EQ(buf.capacity(), 7u);
+ EXPECT_NE(buf.data(), nullptr);
+
+ for (size_t i = 0; i != 7u; ++i) {
+ EXPECT_EQ(buf[i], kTestData[i]);
+ }
+}
+
+TEST(BufferTest, TestBracketReadConst) {
+ Buffer buf(kTestData, 7);
+ EXPECT_EQ(buf.size(), 7u);
+ EXPECT_EQ(buf.capacity(), 7u);
+ EXPECT_NE(buf.data(), nullptr);
+
+ const Buffer& cbuf = buf;
+
+ for (size_t i = 0; i != 7u; ++i) {
+ EXPECT_EQ(cbuf[i], kTestData[i]);
+ }
+}
+
+TEST(BufferTest, TestBracketWrite) {
+ Buffer buf(7);
+ EXPECT_EQ(buf.size(), 7u);
+ EXPECT_EQ(buf.capacity(), 7u);
+ EXPECT_NE(buf.data(), nullptr);
+
+ for (size_t i = 0; i != 7u; ++i) {
+ buf[i] = kTestData[i];
+ }
+
+ for (size_t i = 0; i != 7u; ++i) {
+ EXPECT_EQ(buf[i], kTestData[i]);
+ }
+}
+
} // namespace rtc
« no previous file with comments | « webrtc/base/buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698