movable exempt_ptr: MichaelSet/Map
[libcds.git] / tests / test-hdr / set / hdr_set.h
index 72c7a0e54cd31eaa36d57b891487fcb1c289c8a0..a546eb47b798709a2960940533396ff366406826 100644 (file)
@@ -437,7 +437,8 @@ namespace set {
                         CPPUNIT_CHECK( pVal->nKey == nKey );
                         CPPUNIT_CHECK( pVal->nVal == nKey );
 
-                        CPPUNIT_ASSERT( s.extract( ep, nKey ));
+                        ep = s.extract( nKey );
+                        CPPUNIT_ASSERT( ep );
                         CPPUNIT_ASSERT( !ep.empty() );
                         CPPUNIT_CHECK( pVal->nKey == ep->nKey );
                         CPPUNIT_CHECK( pVal->nVal == (*ep).nVal );
@@ -446,7 +447,8 @@ namespace set {
                     {
                         rcu_lock l;
                         CPPUNIT_CHECK( s.get( nKey ) == nullptr );
-                        CPPUNIT_CHECK( !s.extract( ep, nKey ));
+                        ep = s.extract( nKey );
+                        CPPUNIT_CHECK( !ep );
                         CPPUNIT_CHECK( ep.empty() );
 
                         nKey = arr[i+1];
@@ -455,7 +457,8 @@ namespace set {
                         CPPUNIT_CHECK( pVal->nKey == nKey );
                         CPPUNIT_CHECK( pVal->nVal == nKey );
 
-                        CPPUNIT_ASSERT( s.extract_with( ep, other_item(nKey), other_less() ));
+                        ep = s.extract_with( other_item( nKey ), other_less() );
+                        CPPUNIT_ASSERT( ep );
                         CPPUNIT_ASSERT( !ep.empty() );
                         CPPUNIT_CHECK( pVal->nKey == ep->nKey );
                         CPPUNIT_CHECK( pVal->nVal == (*ep).nVal );
@@ -464,7 +467,7 @@ namespace set {
                     {
                         rcu_lock l;
                         CPPUNIT_CHECK( s.get_with( other_item( nKey ), other_less() ) == nullptr );
-                        CPPUNIT_CHECK( !s.extract_with( ep, other_item(nKey), other_less() ));
+                        CPPUNIT_CHECK( !s.extract_with( other_item(nKey), other_less() ));
                         CPPUNIT_CHECK( ep.empty() );
                     }
                 }
@@ -473,7 +476,8 @@ namespace set {
                 {
                     rcu_lock l;
                     CPPUNIT_CHECK( s.get( int( nLimit / 2 ) ) == nullptr );
-                    CPPUNIT_CHECK( !s.extract( ep, int(nLimit / 2) ));
+                    ep = s.extract( int( nLimit / 2 ) );
+                    CPPUNIT_CHECK( !ep );
                     CPPUNIT_CHECK( ep.empty() );
                 }
             }
@@ -776,6 +780,9 @@ namespace set {
                     CPPUNIT_ASSERT( s.insert( std::make_pair( i, i * 2) ) != s.end() );
                 }
                 for ( iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
+                    iterator it2 = it;
+                    CPPUNIT_CHECK( it2 == it );
+                    CPPUNIT_CHECK( it2 != itEnd );
                     CPPUNIT_ASSERT( (*it).nKey * 2 == it->nVal );
                     it->nVal = (*it).nKey;
                 }
@@ -800,6 +807,29 @@ namespace set {
             for ( int i = 0; size_t(i) < nMaxCount; ++i ) {
                 CPPUNIT_ASSERT( s.insert( std::make_pair( i, i * 2) ));
             }
+
+            {
+                typename Set::iterator it( s.begin() );
+                typename Set::const_iterator cit( s.cbegin() );
+                CPPUNIT_CHECK( it == cit );
+                CPPUNIT_CHECK( it != s.end() );
+                CPPUNIT_CHECK( it != s.cend() );
+                CPPUNIT_CHECK( cit != s.end() );
+                CPPUNIT_CHECK( cit != s.cend() );
+                ++it;
+                CPPUNIT_CHECK( it != cit );
+                CPPUNIT_CHECK( it != s.end() );
+                CPPUNIT_CHECK( it != s.cend() );
+                CPPUNIT_CHECK( cit != s.end() );
+                CPPUNIT_CHECK( cit != s.cend() );
+                ++cit;
+                CPPUNIT_CHECK( it == cit );
+                CPPUNIT_CHECK( it != s.end() );
+                CPPUNIT_CHECK( it != s.cend() );
+                CPPUNIT_CHECK( cit != s.end() );
+                CPPUNIT_CHECK( cit != s.cend() );
+            }
+
             size_t nCount = 0;
             for ( iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
                 CPPUNIT_ASSERT_EX( (*it).nKey * 2 == it->nVal,
@@ -898,22 +928,27 @@ namespace set {
         void Split_RCU_GPI_cmp();
         void Split_RCU_GPI_less();
         void Split_RCU_GPI_cmpmix();
+        void Split_RCU_GPI_cmpmix_stat();
 
         void Split_RCU_GPB_cmp();
         void Split_RCU_GPB_less();
         void Split_RCU_GPB_cmpmix();
+        void Split_RCU_GPB_cmpmix_stat();
 
         void Split_RCU_GPT_cmp();
         void Split_RCU_GPT_less();
         void Split_RCU_GPT_cmpmix();
+        void Split_RCU_GPT_cmpmix_stat();
 
         void Split_RCU_SHB_cmp();
         void Split_RCU_SHB_less();
         void Split_RCU_SHB_cmpmix();
+        void Split_RCU_SHB_cmpmix_stat();
 
         void Split_RCU_SHT_cmp();
         void Split_RCU_SHT_less();
         void Split_RCU_SHT_cmpmix();
+        void Split_RCU_SHT_cmpmix_stat();
 
         void Split_nogc_cmp();
         void Split_nogc_less();
@@ -934,22 +969,27 @@ namespace set {
         void Split_Lazy_RCU_GPI_cmp();
         void Split_Lazy_RCU_GPI_less();
         void Split_Lazy_RCU_GPI_cmpmix();
+        void Split_Lazy_RCU_GPI_cmpmix_stat();
 
         void Split_Lazy_RCU_GPB_cmp();
         void Split_Lazy_RCU_GPB_less();
         void Split_Lazy_RCU_GPB_cmpmix();
+        void Split_Lazy_RCU_GPB_cmpmix_stat();
 
         void Split_Lazy_RCU_GPT_cmp();
         void Split_Lazy_RCU_GPT_less();
         void Split_Lazy_RCU_GPT_cmpmix();
+        void Split_Lazy_RCU_GPT_cmpmix_stat();
 
         void Split_Lazy_RCU_SHB_cmp();
         void Split_Lazy_RCU_SHB_less();
         void Split_Lazy_RCU_SHB_cmpmix();
+        void Split_Lazy_RCU_SHB_cmpmix_stat();
 
         void Split_Lazy_RCU_SHT_cmp();
         void Split_Lazy_RCU_SHT_less();
         void Split_Lazy_RCU_SHT_cmpmix();
+        void Split_Lazy_RCU_SHT_cmpmix_stat();
 
         void Split_Lazy_nogc_cmp();
         void Split_Lazy_nogc_less();
@@ -1034,22 +1074,27 @@ namespace set {
             CPPUNIT_TEST(Split_RCU_GPI_cmp)
             CPPUNIT_TEST(Split_RCU_GPI_less)
             CPPUNIT_TEST(Split_RCU_GPI_cmpmix)
+            CPPUNIT_TEST( Split_RCU_GPI_cmpmix_stat )
 
             CPPUNIT_TEST(Split_RCU_GPB_cmp)
             CPPUNIT_TEST(Split_RCU_GPB_less)
             CPPUNIT_TEST(Split_RCU_GPB_cmpmix)
+            CPPUNIT_TEST( Split_RCU_GPB_cmpmix_stat )
 
             CPPUNIT_TEST(Split_RCU_GPT_cmp)
             CPPUNIT_TEST(Split_RCU_GPT_less)
             CPPUNIT_TEST(Split_RCU_GPT_cmpmix)
+            CPPUNIT_TEST( Split_RCU_GPT_cmpmix_stat )
 
             CPPUNIT_TEST(Split_RCU_SHB_cmp)
             CPPUNIT_TEST(Split_RCU_SHB_less)
             CPPUNIT_TEST(Split_RCU_SHB_cmpmix)
+            CPPUNIT_TEST( Split_RCU_SHB_cmpmix_stat )
 
             CPPUNIT_TEST(Split_RCU_SHT_cmp)
             CPPUNIT_TEST(Split_RCU_SHT_less)
             CPPUNIT_TEST(Split_RCU_SHT_cmpmix)
+            CPPUNIT_TEST( Split_RCU_SHT_cmpmix_stat )
 
             CPPUNIT_TEST(Split_nogc_cmp)
             CPPUNIT_TEST(Split_nogc_less)
@@ -1069,22 +1114,27 @@ namespace set {
             CPPUNIT_TEST(Split_Lazy_RCU_GPI_cmp)
             CPPUNIT_TEST(Split_Lazy_RCU_GPI_less)
             CPPUNIT_TEST(Split_Lazy_RCU_GPI_cmpmix)
+            CPPUNIT_TEST( Split_Lazy_RCU_GPI_cmpmix_stat )
 
             CPPUNIT_TEST(Split_Lazy_RCU_GPB_cmp)
             CPPUNIT_TEST(Split_Lazy_RCU_GPB_less)
             CPPUNIT_TEST(Split_Lazy_RCU_GPB_cmpmix)
+            CPPUNIT_TEST( Split_Lazy_RCU_GPB_cmpmix_stat )
 
             CPPUNIT_TEST(Split_Lazy_RCU_GPT_cmp)
             CPPUNIT_TEST(Split_Lazy_RCU_GPT_less)
             CPPUNIT_TEST(Split_Lazy_RCU_GPT_cmpmix)
+            CPPUNIT_TEST( Split_Lazy_RCU_GPT_cmpmix_stat )
 
             CPPUNIT_TEST(Split_Lazy_RCU_SHB_cmp)
             CPPUNIT_TEST(Split_Lazy_RCU_SHB_less)
             CPPUNIT_TEST(Split_Lazy_RCU_SHB_cmpmix)
+            CPPUNIT_TEST( Split_Lazy_RCU_SHB_cmpmix_stat )
 
             CPPUNIT_TEST(Split_Lazy_RCU_SHT_cmp)
             CPPUNIT_TEST(Split_Lazy_RCU_SHT_less)
             CPPUNIT_TEST(Split_Lazy_RCU_SHT_cmpmix)
+            CPPUNIT_TEST( Split_Lazy_RCU_SHT_cmpmix_stat )
 
             CPPUNIT_TEST(Split_Lazy_nogc_cmp)
             CPPUNIT_TEST(Split_Lazy_nogc_less)