aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/stl_iterators.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-11-09 16:49:19 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-11-09 16:49:19 +0100
commitdb9a9a12ba25353c94417dba24fab35cee16bde1 (patch)
tree9ee1e1a7621429ee7b6ce505e77f4eccfbb083bb /test/stl_iterators.cpp
parentfbd6e7b0255d63fb979e83c4a19009955e797f76 (diff)
bug #1619: make const and non-const iterators compatible
Diffstat (limited to 'test/stl_iterators.cpp')
-rw-r--r--test/stl_iterators.cpp58
1 files changed, 34 insertions, 24 deletions
diff --git a/test/stl_iterators.cpp b/test/stl_iterators.cpp
index ff89ec6ee..8c56db506 100644
--- a/test/stl_iterators.cpp
+++ b/test/stl_iterators.cpp
@@ -61,32 +61,42 @@ void check_begin_end_for_loop(Xpr xpr)
i = 0;
for(typename Xpr::const_iterator it = cxpr.begin(); it!=cxpr.end(); ++it) { VERIFY_IS_EQUAL(*it,xpr[i++]); }
- // Needs to be uncommented while fixing bug 1619
- // i = 0;
- // for(typename Xpr::const_iterator it = xpr.begin(); it!=xpr.end(); ++it) { VERIFY_IS_EQUAL(*it,xpr[i++]); }
+ i = 0;
+ for(typename Xpr::const_iterator it = xpr.begin(); it!=xpr.end(); ++it) { VERIFY_IS_EQUAL(*it,xpr[i++]); }
+
+ {
+ // simple API check
+ typename Xpr::const_iterator cit;
+ cit = xpr.begin();
+ cit = xpr.cbegin();
+ }
+
+ VERIFY( xpr.end() -xpr.begin() == xpr.size() );
+ VERIFY( xpr.cend()-xpr.begin() == xpr.size() );
+ VERIFY( xpr.end() -xpr.cbegin() == xpr.size() );
+ VERIFY( xpr.cend()-xpr.cbegin() == xpr.size() );
if(xpr.size()>0) {
VERIFY(xpr.begin() != xpr.end());
VERIFY(xpr.begin() < xpr.end());
VERIFY(xpr.begin() <= xpr.end());
VERIFY(!(xpr.begin() == xpr.end()));
- VERIFY(!(xpr.begin() < xpr.end()));
- VERIFY(!(xpr.begin() <= xpr.end()));
+ VERIFY(!(xpr.begin() > xpr.end()));
+ VERIFY(!(xpr.begin() >= xpr.end()));
- // Needs to be uncommented while fixing bug 1619
- // VERIFY(xpr.cbegin() != xpr.end());
- // VERIFY(xpr.cbegin() < xpr.end());
- // VERIFY(xpr.cbegin() <= xpr.end());
- // VERIFY(!(xpr.cbegin() == xpr.end()));
- // VERIFY(!(xpr.cbegin() < xpr.end()));
- // VERIFY(!(xpr.cbegin() <= xpr.end()));
-
- // VERIFY(xpr.begin() != xpr.cend());
- // VERIFY(xpr.begin() < xpr.cend());
- // VERIFY(xpr.begin() <= xpr.cend());
- // VERIFY(!(xpr.begin() == xpr.cend()));
- // VERIFY(!(xpr.begin() < xpr.cend()));
- // VERIFY(!(xpr.begin() <= xpr.cend()));
+ VERIFY(xpr.cbegin() != xpr.end());
+ VERIFY(xpr.cbegin() < xpr.end());
+ VERIFY(xpr.cbegin() <= xpr.end());
+ VERIFY(!(xpr.cbegin() == xpr.end()));
+ VERIFY(!(xpr.cbegin() > xpr.end()));
+ VERIFY(!(xpr.cbegin() >= xpr.end()));
+
+ VERIFY(xpr.begin() != xpr.cend());
+ VERIFY(xpr.begin() < xpr.cend());
+ VERIFY(xpr.begin() <= xpr.cend());
+ VERIFY(!(xpr.begin() == xpr.cend()));
+ VERIFY(!(xpr.begin() > xpr.cend()));
+ VERIFY(!(xpr.begin() >= xpr.cend()));
}
}
@@ -419,11 +429,11 @@ void test_stl_iterators(int rows=Rows, int cols=Cols)
// a valid type, the first overload is not viable, and the second
// overload will be picked.
template <class C,
- class Iterator = decltype(::std::declval<const C&>().begin()),
- class = decltype(::std::declval<const C&>().end()),
- class = decltype(++::std::declval<Iterator&>()),
- class = decltype(*::std::declval<Iterator>()),
- class = typename C::const_iterator>
+ class Iterator = decltype(::std::declval<const C&>().begin()),
+ class = decltype(::std::declval<const C&>().end()),
+ class = decltype(++::std::declval<Iterator&>()),
+ class = decltype(*::std::declval<Iterator>()),
+ class = typename C::const_iterator>
bool IsContainerType(int /* dummy */) { return true; }
template <class C>