Updated copyright
[libcds.git] / test / stress / map / insdel_func / map_insdel_func.h
index ab9637794299c5b7998ac9445c04afc398c727e0..b2605ca5673209ea944dc157c8348175de81aa5b 100644 (file)
@@ -1,11 +1,11 @@
 /*
     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/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -227,7 +227,7 @@ namespace map {
                     operator()( bNew, val.first, val.second );
                 }
 
-                // For FeldmanHashMap
+                // For FeldmanHashMap, IterableList
                 template <typename Val>
                 void operator()( Val& cur, Val * old )
                 {
@@ -432,7 +432,8 @@ namespace map {
             cds_test::thread_pool& pool = get_pool();
             pool.add( new inserter( pool, testMap ), s_nInsertThreadCount );
             pool.add( new deleter( pool, testMap ), s_nDeleteThreadCount );
-            pool.add( new updater( pool, testMap ), s_nUpdateThreadCount );
+            if ( s_nUpdateThreadCount )
+                pool.add( new updater( pool, testMap ), s_nUpdateThreadCount );
 
             propout() << std::make_pair( "insert_thread_count", s_nInsertThreadCount )
                 << std::make_pair( "delete_thread_count", s_nDeleteThreadCount )
@@ -459,7 +460,7 @@ namespace map {
 
             for ( size_t i = 0; i < pool.size(); ++i ) {
                 cds_test::thread& thr = pool.get( i );
-                switch ( thr.type() ) {
+                switch ( thr.type()) {
                 case insert_thread:
                     {
                         inserter& t = static_cast<inserter&>( thr );
@@ -501,11 +502,11 @@ namespace map {
                 << std::make_pair( "update_failed",  nUpdateFailed )
                 << std::make_pair( "update_functor_create", nEnsFuncCreated )
                 << std::make_pair( "update_functor_modify", nEnsFuncModified )
-                << std::make_pair( "finish_map_size", testMap.size() );
+                << std::make_pair( "finish_map_size", testMap.size());
 
-            EXPECT_EQ( nDelValueFailed, 0 );
+            EXPECT_EQ( nDelValueFailed, 0u );
             EXPECT_EQ( nDelValueSuccess, nDeleteSuccess );
-            EXPECT_EQ( nUpdateFailed, 0 );
+            EXPECT_EQ( nUpdateFailed, 0u );
             EXPECT_EQ( nUpdateCreated + nUpdateModified, nEnsFuncCreated + nEnsFuncModified );
 
             // nInsFuncCalled is call count of insert functor
@@ -517,6 +518,7 @@ namespace map {
                 testMap.erase( nItem );
 
             EXPECT_TRUE( testMap.empty());
+            EXPECT_EQ( testMap.size(), 0u );
 
             additional_check( testMap );
             print_stat( propout(), testMap );
@@ -529,6 +531,19 @@ namespace map {
             Map testMap( *this );
             do_test( testMap );
         }
+
+        template <class Map>
+        void run_test2()
+        {
+            Map testMap( *this );
+            do_test( testMap );
+
+            if ( testMap.size() != 0 ) {
+                for ( auto it = testMap.begin(); it != testMap.end(); ++it ) {
+                    std::cout << "key=" << it->first << std::endl;
+                }
+            }
+        }
     };
 
     class Map_InsDel_func_LF: public Map_InsDel_func
@@ -543,6 +558,14 @@ namespace map {
             Map_InsDel_func::run_test<Set>();
         }
 
+        template <class Set>
+        void run_test2()
+        {
+            s_nLoadFactor = GetParam();
+            propout() << std::make_pair( "load_factor", s_nLoadFactor );
+            Map_InsDel_func::run_test2<Set>();
+        }
+
         static std::vector<size_t> get_load_factors();
     };