Skip to content

Commit

Permalink
One big constexpr if protection for all runtime checks on rank
Browse files Browse the repository at this point in the history
  • Loading branch information
youyu3 committed Feb 15, 2023
1 parent 078e87d commit 45a00ca
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions tests/test_mdarray_ctors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,36 +141,24 @@ void check_correctness(MDA& m, size_t rank, size_t rank_dynamic,
bool exhaustive) {
ASSERT_EQ(m.rank(), rank);
ASSERT_EQ(m.rank_dynamic(), rank_dynamic);
if(rank>0) {
ASSERT_EQ(m.extent(0), extent_0);
#if MDSPAN_HAS_CXX_20
if constexpr (MDA::extents_type::rank()>0) {
if constexpr (MDA::extents_type::rank()>0) {
#endif
if(rank>0) {
ASSERT_EQ(m.extent(0), extent_0);
ASSERT_EQ(m.stride(0), stride_0);
#if MDSPAN_HAS_CXX_20
}
#endif
}
if(rank>1) {
ASSERT_EQ(m.extent(1), extent_1);
#if MDSPAN_HAS_CXX_20
if constexpr (MDA::extents_type::rank()>0) {
#endif
if(rank>1) {
ASSERT_EQ(m.extent(1), extent_1);
ASSERT_EQ(m.stride(1), stride_1);
#if MDSPAN_HAS_CXX_20
}
#endif
}
if(rank>2) {
ASSERT_EQ(m.extent(2), extent_2);
#if MDSPAN_HAS_CXX_20
if constexpr (MDA::extents_type::rank()>0) {
#endif
if(rank>2) {
ASSERT_EQ(m.extent(2), extent_2);
ASSERT_EQ(m.stride(2), stride_2);
#if MDSPAN_HAS_CXX_20
}
#endif
#if MDSPAN_HAS_CXX_20
}
#endif
if(ptr_matches)
ASSERT_EQ(m.data(),ptr);
else
Expand Down

0 comments on commit 45a00ca

Please sign in to comment.