Skip to content

Commit

Permalink
Add test for issue with assigning to 1D strided views with negative s…
Browse files Browse the repository at this point in the history
…trides
  • Loading branch information
Thoemi09 committed Jul 18, 2024
1 parent 9a12eb8 commit 5bcda71
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/c++/nda_bugs_and_issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,15 @@ TEST(NDA, AmbiguousAssignmentOperatorIssue) {
B = std::array{1, 2, 3};
for (int i = 0; i < 3; ++i) { EXPECT_EQ(B(i), (std::array{1, 2, 3})); }
}

TEST(NDA, AssignmentTo1DNegativeStridedViewsIssue) {
// issue concerning the assignment of scalar values to 1D strided views with negative strides
nda::array<int, 1> A(10);
for (int i = 0; auto &x : A) x = i++;

auto B = A(nda::range(9, -1, -1));
for (int i = 9; auto x : B) EXPECT_EQ(x, i--);

B = 1;
for (auto x : B) EXPECT_EQ(x, 1);
}

0 comments on commit 5bcda71

Please sign in to comment.