Skip to content

Commit

Permalink
Added test with empty integer sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
odlomax authored and wdeconinck committed Jan 30, 2024
1 parent e685853 commit 8780370
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/tests/array/test_array_foreach.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,34 @@ CASE("test_array_foreach_integer_sequence") {
const auto arr3 = ArrayT<double>(2, 3, 4, 5);
const auto view3 = make_view<double, 4>(arr3);

const auto none = std::integer_sequence<int>{};
const auto zero = std::integer_sequence<int, 0>{};
const auto one = std::integer_sequence<int, 1>{};
const auto zeroOneTwoThree = std::make_integer_sequence<int, 4>{};


// 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);
Expand Down

0 comments on commit 8780370

Please sign in to comment.