Fixed explicit ctor bugs in stress tests
[libcds.git] / test / stress / set / set_type_std.h
index 565dea5eea4039aefacccd4512ebb4414c16edb4..c4481cf42b789ee9aa406eb4ee84e59cc9f3e417 100644 (file)
@@ -5,7 +5,7 @@
 
     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:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSUNIT_SET_TYPE_STD_H
@@ -35,9 +35,9 @@
 #include <set>
 #include <mutex>    //unique_lock
 
-#include "set2/set_type.h"
+#include "set_type.h"
 
-namespace set2 {
+namespace set {
 
     struct tag_StdSet;
 
@@ -73,7 +73,7 @@ namespace set2 {
         bool contains( const Key& key )
         {
             scoped_lock al( m_lock );
-            return base_class::find( value_type(key) ) != base_class::end();
+            return base_class::find( value_type(key)) != base_class::end();
         }
 
         template <typename Key>
@@ -115,22 +115,25 @@ namespace set2 {
         bool erase( const Key& key )
         {
             scoped_lock al( m_lock );
-            return base_class::erase( value_type(key) ) != 0;
+            return base_class::erase( value_type(key)) != 0;
         }
 
         template <typename T, typename Func>
         bool erase( const T& key, Func func )
         {
             scoped_lock al( m_lock );
-            typename base_class::iterator it = base_class::find( value_type(key) );
-            if ( it != base_class::end() ) {
+            typename base_class::iterator it = base_class::find( value_type(key));
+            if ( it != base_class::end()) {
                 func( *it );
                 return base_class::erase( it ) != base_class::end();
             }
             return false;
         }
 
-        std::ostream& dump( std::ostream& stm ) { return stm; }
+        empty_stat statistics() const
+        {
+            return empty_stat();
+        }
 
         // for testing
         static CDS_CONSTEXPR bool const c_bExtractSupported = false;
@@ -161,10 +164,11 @@ namespace set2 {
             return base_class::find( v ) != base_class::end();
         }
 
-        bool insert( value_type const& v )
+        template <typename Key>
+        bool insert( Key const& k )
         {
             scoped_lock al( m_lock );
-            return base_class::insert( v ).second;
+            return base_class::insert( value_type( k )).second;
         }
 
         template <typename Key, typename Func>
@@ -198,15 +202,15 @@ namespace set2 {
         bool erase( const Key& key )
         {
             scoped_lock al( m_lock );
-            return base_class::erase( value_type(key) ) != 0;
+            return base_class::erase( value_type(key)) != 0;
         }
 
         template <typename T, typename Func>
         bool erase( const T& key, Func func )
         {
             scoped_lock al( m_lock );
-            typename base_class::iterator it = base_class::find( value_type(key) );
-            if ( it != base_class::end() ) {
+            typename base_class::iterator it = base_class::find( value_type(key));
+            if ( it != base_class::end()) {
                 func( *it );
 
                 base_class::erase( it );
@@ -215,7 +219,10 @@ namespace set2 {
             return false;
         }
 
-        std::ostream& dump( std::ostream& stm ) { return stm; }
+        empty_stat statistics() const
+        {
+            return empty_stat();
+        }
 
         // for testing
         static CDS_CONSTEXPR bool const c_bExtractSupported = false;
@@ -233,13 +240,26 @@ namespace set2 {
 
         typedef StdSet< key_val, less, cds::sync::spin > StdSet_Spin;
         typedef StdSet< key_val, less, std::mutex > StdSet_Mutex;
-        typedef StdSet< key_val, less, lock::NoLock>     StdSet_NoLock;
+        //typedef StdSet< key_val, less, lock::NoLock>     StdSet_NoLock;
 
         typedef StdHashSet< key_val, hash, less, equal_to, cds::sync::spin > StdHashSet_Spin;
         typedef StdHashSet< key_val, hash, less, equal_to, std::mutex > StdHashSet_Mutex;
-        typedef StdHashSet< key_val, hash, less, equal_to, lock::NoLock >    StdHashSet_NoLock;
+        //typedef StdHashSet< key_val, hash, less, equal_to, lock::NoLock >    StdHashSet_NoLock;
     };
 
-} // namespace set2
+} // namespace set
+
+#define CDSSTRESS_StdSet_case( fixture, test_case, std_set_type, key_type, value_type ) \
+    TEST_F( fixture, std_set_type ) \
+    { \
+        typedef set::set_type< tag_StdSet, key_type, value_type >::std_set_type set_type; \
+        test_case<set_type>(); \
+    }
+
+#define CDSSTRESS_StdSet( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_StdSet_case( fixture, test_case, StdSet_Spin,      key_type, value_type ) \
+    CDSSTRESS_StdSet_case( fixture, test_case, StdSet_Mutex,     key_type, value_type ) \
+    CDSSTRESS_StdSet_case( fixture, test_case, StdHashSet_Spin,  key_type, value_type ) \
+    CDSSTRESS_StdSet_case( fixture, test_case, StdHashSet_Mutex, key_type, value_type )
 
 #endif // #ifndef CDSUNIT_SET_TYPE_STD_H