5#include "testing/testing.h"
24TEST(span, AddConstToPointer)
27 std::vector<int *> vec = {&a};
35 int array[] = {3, 5, 8};
210 std::vector<int> a = {1, 2, 3, 4};
221 std::array<int, 2> a = {5, 6};
230 std::array<int, 5> a = {4, 5, 6, 7, 8};
242 std::array<int, 5> a = {0, 0, 0, 0, 0};
254 std::array<int, 10> a{};
262 std::array<int, 4> a = {6, 7, 8, 9};
270TEST(span, FirstLast_OneElement)
281 std::array<int, 3> a = {5, 6, 7};
288 int *ptr_before =
reinterpret_cast<int *
>(uintptr_t(a.data()) - 1);
295 std::array<int, 5> a = {4, 5, 4, 2, 5};
306 std::array<int *, 4> a = {&value,
nullptr,
nullptr,
nullptr};
314 EXPECT_EQ(new_a_span[0], (
float *)&value);
319 std::array<uint32_t, 4> a = {3, 4, 5, 6};
329 std::array<uint16_t, 4> a = {4, 5, 6, 7};
349 std::array<int, 4> src = {5, 6, 7, 8};
350 std::array<int, 4> dst = {1, 2, 3, 4};
362 std::array<int, 4> src = {4, 5, 6, 7};
366 for (
auto it = span.
rbegin(); it != span.
rend(); ++it) {
370 EXPECT_EQ_SPAN<int>(reversed_vec,
Span({7, 6, 5, 4}));
375 std::array<int, 0> src0 = {};
378 EXPECT_EQ_SPAN<int>(span0,
Span<int>({}));
380 std::array<int, 1> src1 = {4};
383 EXPECT_EQ_SPAN<int>(span1,
Span({4}));
385 std::array<int, 2> src2 = {4, 5};
388 EXPECT_EQ_SPAN<int>(span2,
Span({5, 4}));
390 std::array<int, 5> src5 = {4, 5, 6, 7, 8};
393 EXPECT_EQ_SPAN<int>(span5,
Span({8, 7, 6, 5, 4}));
396TEST(span, MutableReverseIterator)
398 std::array<int, 4> src = {4, 5, 6, 7};
402 for (
auto it = span.
rbegin(); it != span.
rend(); ++it) {
407 EXPECT_EQ_SPAN<int>(reversed_vec,
Span({7, 6, 5, 4}));
408 EXPECT_EQ_SPAN<int>(src,
Span({14, 15, 16, 17}));
413 static constexpr std::array<int, 3> src = {3, 2, 1};
420 std::integral_constant<bool, span.
first_index(1) == 2> ic;
440 std::array<int, 3> a = {3, 4, 5};
441 std::array<int, 4>
b = {3, 4, 5, 6};
445 EXPECT_TRUE(
Span(a) ==
Span(
b).take_front(3));
451 EXPECT_FALSE(
Span(a) !=
Span(
b).take_front(3));
#define BLI_STATIC_ASSERT(a, msg)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
constexpr int64_t size() const
constexpr bool contains(const T &value) const
constexpr std::reverse_iterator< T * > rbegin() const
constexpr bool is_empty() const
constexpr MutableSpan take_back(const int64_t n) const
constexpr void fill(const T &value) const
constexpr MutableSpan slice_safe(const int64_t start, const int64_t size) const
constexpr MutableSpan drop_front(const int64_t n) const
constexpr void reverse() const
constexpr std::reverse_iterator< T * > rend() const
constexpr void copy_from(Span< T > values) const
constexpr void fill_indices(Span< IndexT > indices, const T &value) const
constexpr MutableSpan take_front(const int64_t n) const
constexpr Span drop_front(int64_t n) const
Span< NewT > constexpr cast() const
constexpr Span slice_safe(const int64_t start, const int64_t size) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size_in_bytes() const
constexpr std::reverse_iterator< const T * > rend() const
constexpr std::reverse_iterator< const T * > rbegin() const
constexpr Span take_back(int64_t n) const
constexpr Span drop_back(int64_t n) const
constexpr int64_t count(const T &value) const
constexpr const T & first() const
constexpr bool has_duplicates__linear_search() const
constexpr int64_t first_index(const T &search_value) const
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr Span take_front(int64_t n) const
constexpr bool is_empty() const
constexpr bool contains(const T &value) const
constexpr bool contains_ptr(const T *ptr) const
void append(const T &value)
static void test_ref_from_initializer_list(Span< int > span)