summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-13 02:48:08 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-15 22:23:02 +0300
commitc244d07286e4010ee884eeea6f8e67fa5d1ff3cb (patch)
treebba3c0cbe62ead027cb6b00ce06504d074325d88
parentc3269524e46d1c4a227c33c8f44940efc43b8cc2 (diff)
test: span: Add tests for begin() and rbegin()
Verify that the begin() and rbegin() iterators (and their const version) reference the correct values. The end() and rend() iterators can't be tested the same way as they're not dereferenceable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--test/span.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/test/span.cpp b/test/span.cpp
index d60b769c..ca037c8f 100644
--- a/test/span.cpp
+++ b/test/span.cpp
@@ -72,12 +72,24 @@ protected:
staticSpan = Span<int, 4>{ v };
- staticSpan.begin();
- staticSpan.cbegin();
+ if (*staticSpan.begin() != 1) {
+ std::cout << "Span<static_extent>::begin() failed" << std::endl;
+ return TestFail;
+ }
+ if (*staticSpan.cbegin() != 1) {
+ std::cout << "Span<static_extent>::cbegin() failed" << std::endl;
+ return TestFail;
+ }
staticSpan.end();
staticSpan.cend();
- staticSpan.rbegin();
- staticSpan.crbegin();
+ if (*staticSpan.rbegin() != 4) {
+ std::cout << "Span<static_extent>::rbegin() failed" << std::endl;
+ return TestFail;
+ }
+ if (*staticSpan.crbegin() != 4) {
+ std::cout << "Span<static_extent>::crbegin() failed" << std::endl;
+ return TestFail;
+ }
staticSpan.rend();
staticSpan.crend();
@@ -141,12 +153,24 @@ protected:
dynamicSpan = Span<int>{ a };
- dynamicSpan.begin();
- dynamicSpan.cbegin();
+ if (*dynamicSpan.begin() != 1) {
+ std::cout << "Span<dynamic_extent>::begin() failed" << std::endl;
+ return TestFail;
+ }
+ if (*dynamicSpan.cbegin() != 1) {
+ std::cout << "Span<dynamic_extent>::cbegin() failed" << std::endl;
+ return TestFail;
+ }
dynamicSpan.end();
dynamicSpan.cend();
- dynamicSpan.rbegin();
- dynamicSpan.crbegin();
+ if (*dynamicSpan.rbegin() != 4) {
+ std::cout << "Span<dynamic_extent>::rbegin() failed" << std::endl;
+ return TestFail;
+ }
+ if (*dynamicSpan.crbegin() != 4) {
+ std::cout << "Span<dynamic_extent>::crbegin() failed" << std::endl;
+ return TestFail;
+ }
dynamicSpan.rend();
dynamicSpan.crend();