From 8780370562c89ea81cf302d7aba72476844759c8 Mon Sep 17 00:00:00 2001 From: odlomax Date: Thu, 25 Jan 2024 16:42:27 +0000 Subject: [PATCH] Added test with empty integer sequence. --- src/tests/array/test_array_foreach.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tests/array/test_array_foreach.cc b/src/tests/array/test_array_foreach.cc index 42b9d2b09..303da5dd6 100644 --- a/src/tests/array/test_array_foreach.cc +++ b/src/tests/array/test_array_foreach.cc @@ -218,6 +218,7 @@ CASE("test_array_foreach_integer_sequence") { const auto arr3 = ArrayT(2, 3, 4, 5); const auto view3 = make_view(arr3); + const auto none = std::integer_sequence{}; const auto zero = std::integer_sequence{}; const auto one = std::integer_sequence{}; const auto zeroOneTwoThree = std::make_integer_sequence{}; @@ -225,6 +226,26 @@ CASE("test_array_foreach_integer_sequence") { // Test slice shapes. + const auto loopFunctorDimNone = [](auto&& slice1, auto&& slice2, + auto&& slice3) { + EXPECT_EQ(slice1.rank(), 2); + EXPECT_EQ(slice1.shape(0), 2); + EXPECT_EQ(slice1.shape(1), 3); + + EXPECT_EQ(slice2.rank(), 3); + EXPECT_EQ(slice2.shape(0), 2); + EXPECT_EQ(slice2.shape(1), 3); + EXPECT_EQ(slice2.shape(2), 4); + + EXPECT_EQ(slice3.rank(), 4); + EXPECT_EQ(slice3.shape(0), 2); + EXPECT_EQ(slice3.shape(1), 3); + EXPECT_EQ(slice3.shape(2), 4); + EXPECT_EQ(slice3.shape(3), 5); + }; + // No iterations. Apply functor directly to unsliced ArrayViews. + arrayForEachDim(none, std::tie(view1, view2, view3), loopFunctorDimNone); + const auto loopFunctorDim0 = [](auto&& slice1, auto&& slice2, auto&& slice3) { EXPECT_EQ(slice1.rank(), 1); EXPECT_EQ(slice1.shape(0), 3);