From 340ee82f1e7dff6f718a1665831d357ad543ce77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6=20Fahlke?= <jorrit@jorrit.de>
Date: Thu, 2 Oct 2014 16:56:01 +0200
Subject: [PATCH] [testBidirectionalIterator()] Test both pre- and
 postdecrement.

---
 dune/common/test/iteratortest.hh | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/dune/common/test/iteratortest.hh b/dune/common/test/iteratortest.hh
index e457c32f5..c8cbe100f 100644
--- a/dune/common/test/iteratortest.hh
+++ b/dune/common/test/iteratortest.hh
@@ -91,10 +91,21 @@ template<class Iter, class Opt>
 int testBidirectionalIterator(Iter begin, Iter end, Opt opt)
 {
   testForwardIterator(begin, end, opt);
-  for(Iter it = end; it != begin; )
+  for(Iter pre = end, post = end; pre != begin; )
   {
-    --it;
-    opt(*it);
+    if(pre != post--)
+    {
+      std::cerr << "Postdecrement did not return the old iterator"
+                << std::endl;
+      return 1;
+    }
+    if(--pre != post)
+    {
+      std::cerr << "Predecrement did not return the new iterator"
+                << std::endl;
+      return 1;
+    }
+    opt(*pre);
   }
 
   typename Iter::difference_type size = std::distance(begin, end);
-- 
GitLab