Uses different pass count for different parallel queue test cases
[libcds.git] / test / unit / set / test_michael_iterable.h
index 394483dbfda6809c9dadc867a28b0b8240a0f1cb..44b5e437e144a243fda3497560952f371ffb63a2 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -44,7 +44,7 @@ namespace cds_test {
             // Precondition: set is empty
             // Postcondition: set is empty
 
-            EXPECT_TRUE( s.empty() );
+            EXPECT_TRUE( s.empty());
             EXPECT_CONTAINER_SIZE( s, 0 );
             size_t const nSetSize = kSize;
 
@@ -55,24 +55,24 @@ namespace cds_test {
             data.reserve( kSize );
             indices.reserve( kSize );
             for ( size_t key = 0; key < kSize; ++key ) {
-                data.push_back( value_type( static_cast<int>(key) ) );
+                data.push_back( value_type( static_cast<int>(key)));
                 indices.push_back( key );
             }
-            shuffle( indices.begin(), indices.end() );
+            shuffle( indices.begin(), indices.end());
 
             // insert/find
             for ( auto idx : indices ) {
                 auto& i = data[idx];
 
-                EXPECT_FALSE( s.contains( i.nKey ) );
-                EXPECT_FALSE( s.contains( i ) );
-                EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+                EXPECT_FALSE( s.contains( i.nKey ));
+                EXPECT_FALSE( s.contains( i ));
+                EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
                 EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
                 EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
                 EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
                 EXPECT_TRUE( s.find( i ) == s.end());
-                EXPECT_TRUE( s.find( i.nKey ) == s.end() );
-                EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end() );
+                EXPECT_TRUE( s.find( i.nKey ) == s.end());
+                EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
 
                 std::pair<bool, bool> updResult;
 
@@ -91,18 +91,18 @@ namespace cds_test {
                     updResult = s.update( i, []( value_type& val, value_type* old)
                         {
                             ASSERT_FALSE( old == nullptr );
-                            EXPECT_EQ( val.key(), old->key() );
+                            EXPECT_EQ( val.key(), old->key());
                         }, false );
                     EXPECT_TRUE( updResult.first );
                     EXPECT_FALSE( updResult.second );
                     break;
                 case 1:
-                    EXPECT_TRUE( s.insert( i.key() ));
-                    EXPECT_FALSE( s.insert( i.key() ));
+                    EXPECT_TRUE( s.insert( i.key()));
+                    EXPECT_FALSE( s.insert( i.key()));
                     updResult = s.update( i.key(), []( value_type& val, value_type* old)
                         {
                             ASSERT_FALSE( old == nullptr );
-                            EXPECT_EQ( val.key(), old->key() );
+                            EXPECT_EQ( val.key(), old->key());
                         }, false );
                     EXPECT_TRUE( updResult.first );
                     EXPECT_FALSE( updResult.second );
@@ -129,7 +129,7 @@ namespace cds_test {
                     updResult = s.update( i, [&i]( value_type& v, value_type* old )
                         {
                             EXPECT_TRUE( old == nullptr );
-                            EXPECT_EQ( v.key(), i.key() );
+                            EXPECT_EQ( v.key(), i.key());
                             ++v.nUpdateNewCount;
                         });
                     EXPECT_TRUE( updResult.first );
@@ -138,7 +138,7 @@ namespace cds_test {
                     updResult = s.update( i, []( value_type& v, value_type* old )
                         {
                             ASSERT_FALSE( old == nullptr );
-                            EXPECT_EQ( v.key(), old->key() );
+                            EXPECT_EQ( v.key(), old->key());
                             EXPECT_EQ( old->nUpdateNewCount, 1u );
                             v.nUpdateNewCount = old->nUpdateNewCount;
                             ++v.nUpdateCount;
@@ -157,7 +157,7 @@ namespace cds_test {
                     updResult = s.update( i.key(), [&i]( value_type& v, value_type* old )
                         {
                             EXPECT_TRUE( old == nullptr );
-                            EXPECT_EQ( v.key(), i.key() );
+                            EXPECT_EQ( v.key(), i.key());
                             ++v.nUpdateNewCount;
                         });
                     EXPECT_TRUE( updResult.first );
@@ -166,7 +166,7 @@ namespace cds_test {
                     updResult = s.update( i.key(), []( value_type& v, value_type* old )
                         {
                             EXPECT_FALSE( old == nullptr );
-                            EXPECT_EQ( v.key(), old->key() );
+                            EXPECT_EQ( v.key(), old->key());
                             EXPECT_EQ( old->nUpdateNewCount, 1u );
                             v.nUpdateNewCount = old->nUpdateNewCount;
                             ++v.nUpdateCount;
@@ -176,7 +176,7 @@ namespace cds_test {
 
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                         {
-                            EXPECT_EQ( v.key(), arg.key() );
+                            EXPECT_EQ( v.key(), arg.key());
                             EXPECT_EQ( v.nUpdateNewCount, 1u );
                             EXPECT_EQ( v.nUpdateCount, 1u );
                     }));
@@ -185,7 +185,7 @@ namespace cds_test {
                     EXPECT_TRUE( s.emplace( i.key()));
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                         {
-                            EXPECT_EQ( v.key(), arg.key() );
+                            EXPECT_EQ( v.key(), arg.key());
                             EXPECT_EQ( v.nVal, arg.nVal );
                         }));
                     break;
@@ -195,21 +195,21 @@ namespace cds_test {
                     EXPECT_TRUE( str.empty());
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                         {
-                            EXPECT_EQ( v.key(), arg.key() );
+                            EXPECT_EQ( v.key(), arg.key());
                             EXPECT_EQ( v.nVal, arg.nVal );
                             EXPECT_EQ( v.strVal, std::string( "Hello!" ));
                         } ));
                     break;
                 case 8:
                     str = "Hello!";
-                    EXPECT_TRUE( s.insert( value_type( i.key(), std::move( str ))) );
-                    EXPECT_TRUE( str.empty() );
+                    EXPECT_TRUE( s.insert( value_type( i.key(), std::move( str ))));
+                    EXPECT_TRUE( str.empty());
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                     {
-                        EXPECT_EQ( v.key(), arg.key() );
+                        EXPECT_EQ( v.key(), arg.key());
                         EXPECT_EQ( v.nVal, arg.nVal );
-                        EXPECT_EQ( v.strVal, std::string( "Hello!" ) );
-                    } ) );
+                        EXPECT_EQ( v.strVal, std::string( "Hello!" ));
+                    } ));
                     break;
                 case 9:
                     updResult = s.upsert( i.key(), false );
@@ -226,8 +226,8 @@ namespace cds_test {
 
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                     {
-                        EXPECT_EQ( v.key(), arg.key() );
-                    } ) );
+                        EXPECT_EQ( v.key(), arg.key());
+                    } ));
                     break;
                 case 10:
                     updResult = s.upsert( i, false );
@@ -244,36 +244,36 @@ namespace cds_test {
 
                     EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
                     {
-                        EXPECT_EQ( v.key(), arg.key() );
-                    } ) );
+                        EXPECT_EQ( v.key(), arg.key());
+                    } ));
                     break;
                 default:
                     // forgot anything?..
                     EXPECT_TRUE( false );
                 }
 
-                EXPECT_TRUE( s.contains( i.nKey ) );
-                EXPECT_TRUE( s.contains( i ) );
-                EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
-                EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
-                EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
-                EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+                EXPECT_TRUE( s.contains( i.nKey ));
+                EXPECT_TRUE( s.contains( i ));
+                EXPECT_TRUE( s.contains( other_item( i.key()), other_less()));
+                EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+                EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+                EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
                 EXPECT_FALSE( s.find( i.nKey ) == s.end());
-                EXPECT_FALSE( s.find( i ) == s.end() );
-                EXPECT_FALSE( s.find_with( other_item( i.key() ), other_less()) == s.end() );
+                EXPECT_FALSE( s.find( i ) == s.end());
+                EXPECT_FALSE( s.find_with( other_item( i.key()), other_less()) == s.end());
             }
 
-            EXPECT_FALSE( s.empty() );
+            EXPECT_FALSE( s.empty());
             EXPECT_CONTAINER_SIZE( s, nSetSize );
 
             // erase
-            shuffle( indices.begin(), indices.end() );
+            shuffle( indices.begin(), indices.end());
             for ( auto idx : indices ) {
                 auto& i = data[idx];
 
-                EXPECT_TRUE( s.contains( i.nKey ) );
-                EXPECT_TRUE( s.contains( i ) );
-                EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+                EXPECT_TRUE( s.contains( i.nKey ));
+                EXPECT_TRUE( s.contains( i ));
+                EXPECT_TRUE( s.contains( other_item( i.key()), other_less()));
                 EXPECT_TRUE( s.find( i.nKey, []( value_type& v, int )
                     {
                         v.nFindCount = 1;
@@ -282,7 +282,7 @@ namespace cds_test {
                     {
                         EXPECT_EQ( ++v.nFindCount, 2u );
                     }));
-                EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+                EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
                     {
                         EXPECT_EQ( ++v.nFindCount, 3u );
                     }));
@@ -299,7 +299,7 @@ namespace cds_test {
                     break;
                 case 2:
                     EXPECT_TRUE( s.erase_with( other_item( i.key()), other_less()));
-                    EXPECT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+                    EXPECT_FALSE( s.erase_with( other_item( i.key()), other_less()));
                     break;
                 case 3:
                     EXPECT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
@@ -345,32 +345,32 @@ namespace cds_test {
                     break;
                 }
 
-                EXPECT_FALSE( s.contains( i.nKey ) );
-                EXPECT_FALSE( s.contains( i ) );
-                EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+                EXPECT_FALSE( s.contains( i.nKey ));
+                EXPECT_FALSE( s.contains( i ));
+                EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
                 EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
                 EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
                 EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
             }
-            EXPECT_TRUE( s.empty() );
+            EXPECT_TRUE( s.empty());
             EXPECT_CONTAINER_SIZE( s, 0u );
 
 
             // clear
             for ( auto& i : data ) {
-                EXPECT_TRUE( s.insert( i ) );
+                EXPECT_TRUE( s.insert( i ));
             }
 
-            EXPECT_FALSE( s.empty() );
+            EXPECT_FALSE( s.empty());
             EXPECT_CONTAINER_SIZE( s, nSetSize );
 
             s.clear();
 
-            EXPECT_TRUE( s.empty() );
+            EXPECT_TRUE( s.empty());
             EXPECT_CONTAINER_SIZE( s, 0u );
 
-            EXPECT_TRUE( s.begin() == s.end() );
-            EXPECT_TRUE( s.cbegin() == s.cend() );
+            EXPECT_TRUE( s.begin() == s.end());
+            EXPECT_TRUE( s.cbegin() == s.cend());
         }
     };