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

Side by Side Diff: webrtc/base/buffer_unittest.cc

Issue 2804673002: Add [c]begin() and [c]end() member functions to rtc::Buffer (Closed)
Patch Set: Remove redundant "this->" Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 for (size_t i = 0; i != 7u; ++i) { 350 for (size_t i = 0; i != 7u; ++i) {
351 buf[i] = kTestData[i]; 351 buf[i] = kTestData[i];
352 } 352 }
353 353
354 for (size_t i = 0; i != 7u; ++i) { 354 for (size_t i = 0; i != 7u; ++i) {
355 EXPECT_EQ(buf[i], kTestData[i]); 355 EXPECT_EQ(buf[i], kTestData[i]);
356 } 356 }
357 } 357 }
358 358
359 TEST(BufferTest, TestBeginEnd) {
360 const Buffer cbuf(kTestData);
361 Buffer buf(kTestData);
362 auto b1 = cbuf.begin();
363 for (auto& x : buf) {
364 EXPECT_EQ(*b1, x);
365 ++b1;
366 ++x;
367 }
368 EXPECT_EQ(cbuf.end(), b1);
369 auto b2 = buf.begin();
370 for (auto& y : cbuf) {
371 EXPECT_EQ(*b2, y + 1);
372 ++b2;
373 }
374 EXPECT_EQ(buf.end(), b2);
375 }
376
359 TEST(BufferTest, TestInt16) { 377 TEST(BufferTest, TestInt16) {
360 static constexpr int16_t test_data[] = {14, 15, 16, 17, 18}; 378 static constexpr int16_t test_data[] = {14, 15, 16, 17, 18};
361 BufferT<int16_t> buf(test_data); 379 BufferT<int16_t> buf(test_data);
362 EXPECT_EQ(buf.size(), 5u); 380 EXPECT_EQ(buf.size(), 5u);
363 EXPECT_EQ(buf.capacity(), 5u); 381 EXPECT_EQ(buf.capacity(), 5u);
364 EXPECT_NE(buf.data(), nullptr); 382 EXPECT_NE(buf.data(), nullptr);
365 EXPECT_FALSE(buf.empty()); 383 EXPECT_FALSE(buf.empty());
366 for (size_t i = 0; i != buf.size(); ++i) { 384 for (size_t i = 0; i != buf.size(); ++i) {
367 EXPECT_EQ(test_data[i], buf[i]); 385 EXPECT_EQ(test_data[i], buf[i]);
368 } 386 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 BufferT<BloodStone*> buf2(4); 428 BufferT<BloodStone*> buf2(4);
411 for (size_t i = 0; i < buf2.size(); ++i) { 429 for (size_t i = 0; i < buf2.size(); ++i) {
412 buf2[i] = &buf[i]; 430 buf2[i] = &buf[i];
413 } 431 }
414 static const char kObsidian[] = "obsidian"; 432 static const char kObsidian[] = "obsidian";
415 buf2[2]->stone = kObsidian; 433 buf2[2]->stone = kObsidian;
416 EXPECT_EQ(kObsidian, buf[2].stone); 434 EXPECT_EQ(kObsidian, buf[2].stone);
417 } 435 }
418 436
419 } // namespace rtc 437 } // namespace rtc
OLDNEW
« 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