Skip to content

Commit

Permalink
Avoid deprecated function and add test (range for Array2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslze committed Mar 15, 2024
1 parent 65bb9f7 commit 99e9c73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/asl/Array2.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ inline IndexIJEnumerator end(const IndexIJEnumerator& e) { return e.all(); }
template<class T>
typename Array<T>::Enumerator begin(const Array2<T>& a)
{
return a.data().all();
return a.array().all();
}

template<class T>
typename Array<T>::Enumerator end(const Array2<T>& a)
{
return a.data().all();
return a.array().all();
}

#endif
Expand Down
14 changes: 14 additions & 0 deletions tests/unittests4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ ASL_TEST(Array2)
Array2<int> a4 = a.slice(0, 2, 1, 2);

ASL_ASSERT(a4 == Array2<int>(2, 1, array(1, 11)));

#ifdef ASL_HAVE_RANGEFOR
float s = 0;
for (auto& x : a4)
s += x;
ASL_ASSERT(s == 12);
#endif
}

ASL_TEST(Matrix)
Expand Down Expand Up @@ -190,6 +197,13 @@ ASL_TEST(Matrix)
ASL_ASSERT(C[0] == 3 && C[1] == 5);

#endif

#ifdef ASL_HAVE_RANGEFOR
float s = 0;
for (auto& x : A)
s += x;
ASL_ASSERT(s == 5);
#endif
}

ASL_TEST(URL)
Expand Down

0 comments on commit 99e9c73

Please sign in to comment.