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

Unified Diff: webrtc/base/array_view_unittest.cc

Issue 2502383004: Introduce ArrayView::subview function (Closed)
Patch Set: nullptr -> ArrayView() Created 4 years, 1 month 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/array_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/array_view_unittest.cc
diff --git a/webrtc/base/array_view_unittest.cc b/webrtc/base/array_view_unittest.cc
index 91facb00436689254889a48bd089604f4beda762..f7fe9fa36bc164c4d6395987ef2230c05f1834c0 100644
--- a/webrtc/base/array_view_unittest.cc
+++ b/webrtc/base/array_view_unittest.cc
@@ -16,11 +16,15 @@
#include "webrtc/base/buffer.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/gunit.h"
+#include "webrtc/test/gmock.h"
namespace rtc {
namespace {
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
template <typename T>
void Call(ArrayView<T>) {}
@@ -232,4 +236,21 @@ TEST(ArrayViewTest, TestCompare) {
EXPECT_NE(ArrayView<int>(a), ArrayView<int>(a, 2));
}
+TEST(ArrayViewTest, TestSubView) {
+ int a[] = {1, 2, 3};
+ ArrayView<int> av(a);
+
+ EXPECT_EQ(av.subview(0), av);
+
+ EXPECT_THAT(av.subview(1), ElementsAre(2, 3));
+ EXPECT_THAT(av.subview(2), ElementsAre(3));
+ EXPECT_THAT(av.subview(3), IsEmpty());
+ EXPECT_THAT(av.subview(4), IsEmpty());
+
+ EXPECT_THAT(av.subview(1, 0), IsEmpty());
+ EXPECT_THAT(av.subview(1, 1), ElementsAre(2));
+ EXPECT_THAT(av.subview(1, 2), ElementsAre(2, 3));
+ EXPECT_THAT(av.subview(1, 3), ElementsAre(2, 3));
+}
+
} // namespace rtc
« no previous file with comments | « webrtc/base/array_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698