Skip to content

Commit

Permalink
Minor syntax improvements in c++/nda/layout/idx_map.hpp and test/c++/…
Browse files Browse the repository at this point in the history
…nda_basic_array_and_view.cpp
  • Loading branch information
Wentzell committed Jul 30, 2024
1 parent 24751d8 commit 5d10097
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion c++/nda/layout/idx_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace nda {
auto s = size();
if (s == 0) return true;
int i = Rank - 1;
for (; len[stride_order[i]] == 1; --i);
while (len[stride_order[i]] == 1 and i > 0) --i;
return (std::abs(str[stride_order[0]] * len[stride_order[0]]) == s * std::abs(str[stride_order[i]]));
}

Expand Down
9 changes: 4 additions & 5 deletions test/c++/nda_basic_array_and_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,11 @@ TEST_F(NDAArrayAndView, SliceAccessFull) {
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_3d(i, j, k), 42);
}
}
A_s3 = A_3d;
auto A_3d_copy = A_3d;
A_s3 = A_3d_copy;
for (long i = 0; i < 2; ++i) {
for (long j = 0; j < 3; ++j) {
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_s3(i, j, k), A_3d(1 - i, 2 - j, 3 - k));
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_3d(i, j, k), A_3d_copy(1 - i, 2 - j, 3 - k));
}
}
}
Expand Down Expand Up @@ -965,8 +966,6 @@ TEST_F(NDAArrayAndView, StrideOrderOfArrays) {

#if defined(__has_feature)
#if !__has_feature(address_sanitizer)
TEST_F(NDAArrayAndView, BadAlloc) {
EXPECT_THROW(nda::vector<int>(long(1e16)), std::bad_alloc);
}
TEST_F(NDAArrayAndView, BadAlloc) { EXPECT_THROW(nda::vector<int>(long(1e16)), std::bad_alloc); }
#endif
#endif

0 comments on commit 5d10097

Please sign in to comment.