Fixed iterator issues in set/map
[libcds.git] / tests / test-hdr / ordered_list / hdr_michael.h
index 3036a5578f332549bf5d2083dc1260eedb469a51..b612cbbdbce84d1c513d2bf2e2ec16eb3be16d8e 100644 (file)
@@ -392,6 +392,28 @@ namespace ordlist {
                 for ( int i = 0; i < nCount; ++i )
                     CPPUNIT_ASSERT( l.insert(i) );
 
+                {
+                    typename OrdList::iterator it( l.begin() );
+                    typename OrdList::const_iterator cit( l.cbegin() );
+                    CPPUNIT_CHECK( it == cit );
+                    CPPUNIT_CHECK( it != l.end() );
+                    CPPUNIT_CHECK( it != l.cend() );
+                    CPPUNIT_CHECK( cit != l.end() );
+                    CPPUNIT_CHECK( cit != l.cend() );
+                    ++it;
+                    CPPUNIT_CHECK( it != cit );
+                    CPPUNIT_CHECK( it != l.end() );
+                    CPPUNIT_CHECK( it != l.cend() );
+                    CPPUNIT_CHECK( cit != l.end() );
+                    CPPUNIT_CHECK( cit != l.cend() );
+                    ++cit;
+                    CPPUNIT_CHECK( it == cit );
+                    CPPUNIT_CHECK( it != l.end() );
+                    CPPUNIT_CHECK( it != l.cend() );
+                    CPPUNIT_CHECK( cit != l.end() );
+                    CPPUNIT_CHECK( cit != l.cend() );
+                }
+
                 int i = 0;
                 for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) {
                     it->nVal = i * 2;
@@ -670,6 +692,29 @@ namespace ordlist {
             CPPUNIT_ASSERT( it->nKey == 1001 );
             CPPUNIT_ASSERT( it->nVal == 1001 * 2 );
 
+            {
+                typename OrdList::iterator it( l.begin() );
+                typename OrdList::const_iterator cit( l.cbegin() );
+                CPPUNIT_CHECK( it == cit );
+                CPPUNIT_CHECK( it != l.end() );
+                CPPUNIT_CHECK( it != l.cend() );
+                CPPUNIT_CHECK( cit != l.end() );
+                CPPUNIT_CHECK( cit != l.cend() );
+                ++it;
+                CPPUNIT_CHECK( it != cit );
+                CPPUNIT_CHECK( it != l.end() );
+                CPPUNIT_CHECK( it != l.cend() );
+                CPPUNIT_CHECK( cit != l.end() );
+                CPPUNIT_CHECK( cit != l.cend() );
+                ++cit;
+                CPPUNIT_CHECK( it == cit );
+                CPPUNIT_CHECK( it != l.end() );
+                CPPUNIT_CHECK( it != l.cend() );
+                CPPUNIT_CHECK( cit != l.end() );
+                CPPUNIT_CHECK( cit != l.cend() );
+            }
+
+
             l.clear();
             CPPUNIT_ASSERT( l.empty() );
         }