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 |