Merged branch 'master' of https://github.com/Nemo1369/libcds
[libcds.git] / test / unit / map / michael_michael_hp.cpp
index b69aa597745bc894237946c4f11381bc164037a1..aa91047b601402de71d620862c6a089ac635bd18 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:
 
@@ -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.
 */
 
 #include "test_map_hp.h"
@@ -68,7 +68,7 @@ namespace {
             >::type
         > list_type;
 
-        typedef cc::MichaelHashMap< gc_type, list_type, 
+        typedef cc::MichaelHashMap< gc_type, list_type,
             typename cc::michael_map::make_traits<
                 cds::opt::hash< hash1 >
             >::type
@@ -86,7 +86,7 @@ namespace {
             >::type
         > list_type;
 
-        typedef cc::MichaelHashMap< gc_type, list_type, 
+        typedef cc::MichaelHashMap< gc_type, list_type,
             typename cc::michael_map::make_traits<
                 cds::opt::hash< hash1 >
             >::type
@@ -105,7 +105,7 @@ namespace {
             >::type
         > list_type;
 
-        typedef cc::MichaelHashMap< gc_type, list_type, 
+        typedef cc::MichaelHashMap< gc_type, list_type,
             typename cc::michael_map::make_traits<
                 cds::opt::hash< hash1 >
             >::type
@@ -155,5 +155,47 @@ namespace {
         test( s );
     }
 
+    TEST_F( MichaelMap_HP, stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::michael_list::stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 8 );
+        test( m );
+        EXPECT_GE( m.statistics().m_nInsertSuccess, 0u );
+    }
+
+    TEST_F( MichaelMap_HP, wrapped_stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::michael_list::wrapped_stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 8 );
+        test( m );
+        EXPECT_GE( m.statistics().m_nInsertSuccess, 0u );
+    }
+
 } // namespace