diff options
Diffstat (limited to 'test/span.cpp')
-rw-r--r-- | test/span.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/test/span.cpp b/test/span.cpp index 69f0732e..4b9f3279 100644 --- a/test/span.cpp +++ b/test/span.cpp @@ -2,14 +2,14 @@ /* * Copyright (C) 2020, Google Inc. * - * span.cpp - Span tests + * Span tests */ /* * Include first to ensure the header is self-contained, as there's no span.cpp * in libcamera. */ -#include <libcamera/span.h> +#include <libcamera/base/span.h> #include <array> #include <iostream> @@ -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(); @@ -106,7 +118,7 @@ protected: /* staticSpan.subspan(2, 4); */ /* - * Compile-test construction and usage of spans with static + * Compile-test construction and usage of spans with dynamic * extent. Commented-out tests are expected not to compile, or * to generate undefined behaviour. */ @@ -131,9 +143,9 @@ protected: Span<const int>{ v }; /* Span<float>{ v }; */ - Span<const int>{ v }; - /* Span<int>{ v }; */ - /* Span<const float>{ v }; */ + Span<const int>{ cv }; + /* Span<int>{ cv }; */ + /* Span<const float>{ cv }; */ Span<int> dynamicSpan{ i }; Span<int>{ dynamicSpan }; @@ -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(); |