Moved HP-based KV-list unit test to gtest framework
authorkhizmax <libcds.dev@gmail.com>
Tue, 16 Feb 2016 20:08:45 +0000 (23:08 +0300)
committerkhizmax <libcds.dev@gmail.com>
Tue, 16 Feb 2016 20:08:45 +0000 (23:08 +0300)
13 files changed:
cds/container/details/make_lazy_kvlist.h
cds/container/details/make_michael_kvlist.h
cds/container/impl/lazy_kvlist.h
cds/container/impl/michael_kvlist.h
projects/Win/vc14/gtest-list.vcxproj
projects/Win/vc14/gtest-list.vcxproj.filters
test/unit/list/CMakeLists.txt
test/unit/list/kv_lazy_dhp.cpp [new file with mode: 0644]
test/unit/list/kv_lazy_hp.cpp [new file with mode: 0644]
test/unit/list/kv_michael_dhp.cpp [new file with mode: 0644]
test/unit/list/kv_michael_hp.cpp [new file with mode: 0644]
test/unit/list/test_kv_list.h [new file with mode: 0644]
test/unit/list/test_kv_list_hp.h [new file with mode: 0644]

index ae5d0c9209354ea36c43664bc5bbcbd234483446..2d3a469295855227501ee09f3a30adcdf0def0a5 100644 (file)
@@ -52,9 +52,13 @@ namespace cds { namespace container {
             {
                 value_type   m_Data;
 
+                node_type( key_type const& key )
+                    : m_Data( key, mapped_type() )
+                {}
+
                 template <typename Q>
                 node_type( Q const& key )
-                    : m_Data( key, mapped_type() )
+                    : m_Data( key_type( key ), mapped_type() )
                 {}
 
                 template <typename Q, typename R>
@@ -62,9 +66,23 @@ namespace cds { namespace container {
                     : m_Data( pair )
                 {}
 
+                node_type( key_type const& key, mapped_type const& value )
+                    : m_Data( key, value )
+                {}
+
+                template <typename R>
+                node_type( key_type const& key, R const& value )
+                    : m_Data( key, mapped_type( value ) )
+                {}
+
+                template <typename Q>
+                node_type( Q const& key, mapped_type const& value )
+                    : m_Data( key_type( key ), value )
+                {}
+
                 template <typename Q, typename R>
                 node_type( Q const& key, R const& value )
-                    : m_Data( key, value )
+                    : m_Data( key_type( key ), mapped_type( value ))
                 {}
 
                 template <typename Ky, typename... Args>
@@ -109,7 +127,7 @@ namespace cds { namespace container {
 
             struct intrusive_traits: public original_type_traits
             {
-                typedef intrusive::lazy_list::base_hook< opt::gc<gc> >  hook;
+                typedef intrusive::lazy_list::base_hook< opt::gc<gc>, opt::lock_type< typename original_type_traits::lock_type >> hook;
                 typedef node_deallocator disposer;
 
                 typedef typename std::conditional< std::is_same< typename original_type_traits::equal_to, cds::opt::none >::value,
index 9419068c4ea045c4c616d6efd800f71c002cf992..b1513061c6a682c3adc8d98c631c41947baec59e 100644 (file)
@@ -52,9 +52,13 @@ namespace cds { namespace container {
             {
                 pair_type               m_Data;
 
+                node_type( key_type const& key )
+                    : m_Data( key, value_type() )
+                {}
+
                 template <typename Q>
                 node_type( Q const& key )
-                    : m_Data( key, value_type() )
+                    : m_Data( key_type(key), value_type() )
                 {}
 
                 template <typename Q, typename R>
@@ -62,14 +66,28 @@ namespace cds { namespace container {
                     : m_Data( pair )
                 {}
 
+                node_type( key_type const& key, value_type const& value )
+                    : m_Data( key, value )
+                {}
+
+                template <typename R>
+                node_type( key_type const& key, R const& value )
+                    : m_Data( key, value_type( value ))
+                {}
+
+                template <typename Q>
+                node_type( Q const& key, value_type const& value )
+                    : m_Data( key_type( key ), value )
+                {}
+
                 template <typename Q, typename R>
                 node_type( Q const& key, R const& value )
-                    : m_Data( key, value )
+                    : m_Data( key_type( key ), value_type( value ))
                 {}
 
                 template< typename Ky, typename... Args>
                 node_type( Ky&& key, Args&&... args )
-                    : m_Data( std::forward<Ky>(key), std::move( value_type( std::forward<Args>(args)...)))
+                    : m_Data( key_type( std::forward<Ky>(key)), std::move( value_type( std::forward<Args>(args)...)))
                 {}
             };
 
index a8a96dab65b34a363e53ea338f682797aa3e0cc4..5db39fc912feea0b8c326f3052e88e2918752f98 100644 (file)
@@ -134,6 +134,8 @@ namespace cds { namespace container {
         typedef typename maker::key_comparator    key_comparator; ///< key comparing functor
         typedef typename base_class::memory_model memory_model;   ///< Memory ordering. See \p cds::opt::memory_model
 
+        static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
+
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
index dd4fa428eea9a0d49fabdec76e2766f4f8e829c5..c1053ee7190d3897f600efe3d9d8a5acc8e39bda 100644 (file)
@@ -137,6 +137,8 @@ namespace cds { namespace container {
         typedef typename maker::key_comparator    key_comparator; ///< key comparison functor
         typedef typename base_class::memory_model memory_model;   ///< Memory ordering. See cds::opt::memory_model option
 
+        static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
+
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
index 4ab86dde2a0bc26196da9bd14c1ae0ad2de6cd30..a954d055b66c393b1ed729f4f0d76daf3d7e3a6f 100644 (file)
@@ -33,6 +33,8 @@
     <ClInclude Include="..\..\..\test\unit\list\test_intrusive_list_nogc.h" />\r
     <ClInclude Include="..\..\..\test\unit\list\test_intrusive_list_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\list\test_intrusive_michael_rcu.h" />\r
+    <ClInclude Include="..\..\..\test\unit\list\test_kv_list.h" />\r
+    <ClInclude Include="..\..\..\test\unit\list\test_kv_list_hp.h" />\r
     <ClInclude Include="..\..\..\test\unit\list\test_lazy_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\list\test_list.h" />\r
     <ClInclude Include="..\..\..\test\unit\list\test_list_hp.h" />\r
     <ClCompile Include="..\..\..\test\unit\list\intrusive_michael_rcu_shb.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\list\intrusive_michael_rcu_sht.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\list\intrusive_michael_nogc.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_lazy_dhp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_lazy_hp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_michael_dhp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_michael_hp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\list\lazy_dhp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\list\lazy_hp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\list\lazy_nogc.cpp" />\r
index 16c832760720a853d70e96d0c1956f800948bfd5..dcbca55c35bde91ef2837943439e0fe499e85131 100644 (file)
     <ClInclude Include="..\..\..\test\unit\list\test_lazy_rcu.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\list\test_kv_list.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\list\test_kv_list_hp.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\test\unit\list\intrusive_michael_hp.cpp">\r
     <ClCompile Include="..\..\..\test\unit\list\lazy_rcu_sht.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_michael_hp.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_michael_dhp.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_lazy_hp.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\list\kv_lazy_dhp.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index dbe84711be2d1a1c1a9ccc9f0081947c5bcb2e6a..4acc54593a9a38b5852bd912f44e7057611a67f5 100644 (file)
@@ -18,6 +18,10 @@ set(CDSGTEST_LIST_SOURCES
     intrusive_michael_rcu_gpt.cpp
     intrusive_michael_rcu_shb.cpp
     intrusive_michael_rcu_sht.cpp
+    kv_lazy_hp.cpp
+    kv_lazy_dhp.cpp
+    kv_michael_hp.cpp
+    kv_michael_dhp.cpp
     lazy_hp.cpp
     lazy_dhp.cpp
     lazy_nogc.cpp
diff --git a/test/unit/list/kv_lazy_dhp.cpp b/test/unit/list/kv_lazy_dhp.cpp
new file mode 100644 (file)
index 0000000..9b24297
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#include "test_kv_list_hp.h"
+#include <cds/container/lazy_kvlist_dhp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::DHP gc_type;
+
+    class LazyKVList_DHP : public cds_test::kv_list_hp
+    {
+    protected:
+        void SetUp()
+        {
+            typedef cc::LazyKVList< gc_type, key_type, value_type > list_type;
+
+            cds::gc::dhp::GarbageCollector::Construct( 16, list_type::c_nHazardPtrCount );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct();
+        }
+    };
+
+    TEST_F( LazyKVList_DHP, less_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, compare_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, mix_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::compare< cmp >
+                ,cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, item_counting )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, backoff )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::empty back_off;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, seq_cst )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_DHP, mutex )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef std::mutex lock_type;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+} // namespace
diff --git a/test/unit/list/kv_lazy_hp.cpp b/test/unit/list/kv_lazy_hp.cpp
new file mode 100644 (file)
index 0000000..fd5f0c8
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#include "test_kv_list_hp.h"
+#include <cds/container/lazy_kvlist_hp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::HP gc_type;
+
+    class LazyKVList_HP : public cds_test::kv_list_hp
+    {
+    protected:
+        void SetUp()
+        {
+            typedef cc::LazyKVList< gc_type, key_type, value_type > list_type;
+
+            // +1 - for guarded_ptr
+            cds::gc::hp::GarbageCollector::Construct( list_type::c_nHazardPtrCount + 1, 1, 16 );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct( true );
+        }
+    };
+
+    TEST_F( LazyKVList_HP, less_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, compare_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, mix_ordered )
+    {
+        typedef cc::LazyKVList< gc_type, key_type, value_type,
+            typename cc::lazy_list::make_traits<
+                cds::opt::compare< cmp >
+                ,cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, item_counting )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, backoff )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::empty back_off;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, seq_cst )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( LazyKVList_HP, mutex )
+    {
+        struct traits : public cc::lazy_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef std::mutex lock_type;
+        };
+        typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+} // namespace
diff --git a/test/unit/list/kv_michael_dhp.cpp b/test/unit/list/kv_michael_dhp.cpp
new file mode 100644 (file)
index 0000000..f942b96
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#include "test_kv_list_hp.h"
+#include <cds/container/michael_kvlist_dhp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::DHP gc_type;
+
+    class MichaelKVList_DHP : public cds_test::kv_list_hp
+    {
+    protected:
+        void SetUp()
+        {
+            typedef cc::MichaelKVList< gc_type, key_type, value_type > list_type;
+
+            cds::gc::dhp::GarbageCollector::Construct( 16, list_type::c_nHazardPtrCount );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct();
+        }
+    };
+
+    TEST_F( MichaelKVList_DHP, less_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_DHP, compare_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_DHP, mix_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+                ,cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_DHP, item_counting )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_DHP, backoff )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::empty back_off;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_DHP, seq_cst )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+} // namespace
diff --git a/test/unit/list/kv_michael_hp.cpp b/test/unit/list/kv_michael_hp.cpp
new file mode 100644 (file)
index 0000000..baca4a3
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#include "test_kv_list_hp.h"
+#include <cds/container/michael_kvlist_hp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::HP gc_type;
+
+    class MichaelKVList_HP : public cds_test::kv_list_hp
+    {
+    protected:
+        void SetUp()
+        {
+            typedef cc::MichaelKVList< gc_type, key_type, value_type > list_type;
+
+            // +1 - for guarded_ptr
+            cds::gc::hp::GarbageCollector::Construct( list_type::c_nHazardPtrCount + 1, 1, 16 );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct( true );
+        }
+    };
+
+    TEST_F( MichaelKVList_HP, less_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_HP, compare_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_HP, mix_ordered )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+                ,cds::opt::less< lt >
+            >::type
+        > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_HP, item_counting )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_HP, backoff )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::empty back_off;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+    TEST_F( MichaelKVList_HP, seq_cst )
+    {
+        struct traits : public cc::michael_list::traits
+        {
+            typedef lt less;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::MichaelKVList<gc_type, key_type, value_type, traits > list_type;
+
+        list_type l;
+        test_common( l );
+        test_ordered_iterator( l );
+        test_hp( l );
+    }
+
+} // namespace
diff --git a/test/unit/list/test_kv_list.h b/test/unit/list/test_kv_list.h
new file mode 100644 (file)
index 0000000..ee87209
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#ifndef CDSUNIT_LIST_TEST_KV_LIST_H
+#define CDSUNIT_LIST_TEST_KV_LIST_H
+
+#include <cds_test/check_size.h>
+#include <cds_test/fixture.h>
+
+namespace cds_test {
+
+    class kv_list_common : public fixture
+    {
+    public:
+        struct key_type {
+            int nKey;
+
+            key_type() = delete;
+            explicit key_type( int n )
+                : nKey( n )
+            {}
+
+            key_type( key_type const& s )
+                : nKey( s.nKey )
+            {}
+
+            key_type( key_type&& s )
+                : nKey( s.nKey )
+            {
+                s.nKey = 0;
+            }
+
+            int key() const 
+            { 
+                return nKey; 
+            }
+        };
+
+        struct value_type {
+            int val;
+
+            value_type()
+                : val( 0 )
+            {}
+
+            explicit value_type( int n )
+                : val( n )
+            {}
+        };
+
+        struct lt
+        {
+            bool operator()( key_type const& lhs, key_type const& rhs ) const
+            {
+                return lhs.key() < rhs.key();
+            }
+
+            bool operator()( key_type const& lhs, int rhs ) const
+            {
+                return lhs.key() < rhs;
+            }
+
+            bool operator()( int lhs, key_type const& rhs ) const
+            {
+                return lhs < rhs.key();
+            }
+
+            template <typename T>
+            bool operator ()( T const& v1, T const& v2 ) const
+            {
+                return v1.key() < v2.key();
+            }
+        };
+
+        struct cmp 
+        {
+            int operator()( key_type const& lhs, key_type const& rhs ) const
+            {
+                return lhs.key() - rhs.key();
+            }
+
+            int operator()( key_type const& lhs, int rhs ) const
+            {
+                return lhs.key() - rhs;
+            }
+
+            int operator()( int lhs, key_type const& rhs ) const
+            {
+                return lhs - rhs.key();
+            }
+
+            template <typename T>
+            int operator ()( T const& lhs, T const& rhs ) const
+            {
+                return lhs.key() - rhs.key();
+            }
+        };
+
+        struct other_key
+        {
+            int nKey;
+
+            other_key()
+            {}
+
+            other_key( int n )
+                : nKey( n )
+            {}
+
+            int key() const
+            {
+                return nKey;
+            }
+        };
+
+        struct other_less
+        {
+            template <typename T1, typename T2>
+            bool operator()( T1 const& t1, T2 const& t2 ) const
+            {
+                return t1.key() < t2.key();
+            }
+        };
+
+    protected:
+        template <typename List>
+        void test_common( List& l )
+        {
+            // Precondition: list is empty
+            // Postcondition: list is empty
+
+            static const size_t nSize = 20;
+            typedef typename List::key_type    list_key_type;
+            typedef typename List::mapped_type list_mapped_type;
+            typedef typename List::value_type  list_value_type;
+            struct key_val {
+                int key;
+                int val;
+            };
+            key_val arr[nSize];
+
+            for ( size_t i = 0; i < nSize; ++i ) {
+                arr[i].key = static_cast<int>(i) + 1;
+                arr[i].val = arr[i].key * 10;
+            }
+            shuffle( arr, arr + nSize );
+
+            ASSERT_TRUE( l.empty() );
+            ASSERT_CONTAINER_SIZE( l, 0 );
+
+            // insert/find
+            for ( auto const& i : arr ) {
+                EXPECT_FALSE( l.contains( i.key ));
+                EXPECT_FALSE( l.contains( key_type( i.key )));
+                EXPECT_FALSE( l.contains( other_key( i.key ), other_less()));
+                EXPECT_FALSE( l.find( i.key, []( list_value_type& ) {} ));
+                EXPECT_FALSE( l.find( key_type( i.key ), []( list_value_type& ) {} ));
+                EXPECT_FALSE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& ) {} ));
+
+                switch ( i.key % 5 ) {
+                    case 0:
+                        EXPECT_TRUE( l.insert( i.key ));
+                        EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                            EXPECT_EQ( n.second.val, 0 );
+                        } ));
+                        EXPECT_FALSE( l.insert( i.key ));
+                        break;
+
+                    case 1:
+                        EXPECT_TRUE( l.insert( i.key, i.val ));
+                        EXPECT_TRUE( l.find( key_type(i.key), []( list_value_type& n ) {
+                            EXPECT_EQ( n.second.val, n.first.nKey * 10 );
+                        } ));
+                        EXPECT_FALSE( l.insert( key_type( i.key )));
+                        break;
+
+                    case 2:
+                        EXPECT_TRUE( l.insert_with( i.key, []( list_value_type& n ) {
+                            n.second.val = n.first.nKey * 2;
+                        }));
+                        EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                            EXPECT_EQ( n.second.val, n.first.key() * 2 );
+                        } ));
+                        EXPECT_FALSE( l.insert_with( i.key, []( list_value_type& n ) {
+                            n.second.val = n.first.nKey * 3;
+                        } ));
+                        EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                            EXPECT_EQ( n.second.val, n.first.key() * 2 );
+                        } ));
+                        break;
+
+                    case 3:
+                        {
+                            key_type k( i.key );
+                            EXPECT_TRUE( l.emplace( std::move(k), i.key * 100 ));
+                            EXPECT_EQ( k.key(), 0 );
+                            EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                                EXPECT_EQ( n.second.val, n.first.nKey * 100 );
+                            } ));
+                            k.nKey = i.key;
+                            EXPECT_FALSE( l.emplace( std::move( k ), i.key ));
+                            //EXPECT_EQ( k.key(), i.key ); // ???
+                            EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                                EXPECT_EQ( n.second.val, n.first.nKey * 100 );
+                            } ));
+                        }
+                        break;
+                    case 4:
+                        {
+                            auto pair = l.update( i.key, []( bool bNew, list_value_type& n ) {
+                                ASSERT_TRUE( false );
+                            }, false );
+                            EXPECT_FALSE( pair.first );
+                            EXPECT_FALSE( pair.second );
+
+                            pair = l.update( list_key_type(i.key), []( bool bNew, list_value_type& n ) {
+                                EXPECT_TRUE( bNew );
+                                n.second.val = n.first.nKey * 3;
+                            });
+                            EXPECT_TRUE( pair.first );
+                            EXPECT_TRUE( pair.second );
+
+                            EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                                EXPECT_EQ( n.second.val, n.first.key() * 3 );
+                            } ));
+
+                            pair = l.update( list_key_type(i.key), []( bool bNew, list_value_type& n ) {
+                                EXPECT_FALSE( bNew );
+                                n.second.val = n.first.nKey * 5;
+                            });
+                            EXPECT_TRUE( pair.first );
+                            EXPECT_FALSE( pair.second );
+
+                            EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                                EXPECT_EQ( n.second.val, n.first.key() * 5 );
+                            } ));
+                        }
+                        break;
+                }
+
+                EXPECT_TRUE( l.contains( i.key ));
+                EXPECT_TRUE( l.contains( list_key_type(i.key)));
+                EXPECT_TRUE( l.contains( other_key( i.key ), other_less()));
+                EXPECT_TRUE( l.find( i.key, []( list_value_type& n  ) { 
+                    n.second.val = n.first.nKey;
+                } ));
+                EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+                    EXPECT_EQ( n.first.nKey, n.second.val );
+                    n.second.val = n.first.nKey * 5;
+                } ));
+                EXPECT_TRUE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& n ) {
+                    EXPECT_EQ( n.first.nKey * 5, n.second.val );
+                } ));
+
+                auto pair = l.update( i.key, []( bool bNew, list_value_type& n ) {
+                    EXPECT_FALSE( bNew );
+                    EXPECT_EQ( n.first.nKey * 5, n.second.val );
+                    n.second.val = n.first.nKey * 3;
+                }, false );
+                EXPECT_TRUE( pair.first );
+                EXPECT_FALSE( pair.second );
+
+                EXPECT_FALSE( l.empty() );
+            }
+
+            ASSERT_FALSE( l.empty() );
+            EXPECT_CONTAINER_SIZE( l, nSize );
+
+            // erase
+            for ( auto const&i : arr ) {
+                switch ( i.key & 3 ) {
+                    case 0:
+                        EXPECT_TRUE( l.erase( i.key ));
+                        break;
+                    case 1:
+                        EXPECT_TRUE( l.erase_with( other_key( i.key ), other_less()));
+                        break;
+                    case 2:
+                        EXPECT_TRUE( l.erase( i.key, [ &i ]( list_value_type const& n ) {
+                            EXPECT_EQ( n.first.nKey, i.key );
+                            EXPECT_EQ( n.first.nKey * 3, n.second.val );
+                        }));
+                        break;
+                    case 3:
+                        EXPECT_TRUE( l.erase_with( other_key( i.key ), other_less(), [ &i ]( list_value_type const& n) {
+                            EXPECT_EQ( n.first.nKey, i.key );
+                            EXPECT_EQ( n.first.nKey * 3, n.second.val );
+                        } ));
+                }
+
+                EXPECT_FALSE( l.contains( i.key ));
+                EXPECT_FALSE( l.contains( key_type( i.key )));
+                EXPECT_FALSE( l.contains( other_key( i.key ), other_less()));
+                EXPECT_FALSE( l.find( key_type( i.key ), []( list_value_type& ) {} ));
+                EXPECT_FALSE( l.find( i.key, []( list_value_type& ) {} ));
+                EXPECT_FALSE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& ) {} ));
+            }
+
+            ASSERT_TRUE( l.empty() );
+            EXPECT_CONTAINER_SIZE( l, 0 );
+
+            // clear test
+            for ( auto& i : arr ) 
+                EXPECT_TRUE( l.insert( i.key, i.val ));
+
+            ASSERT_FALSE( l.empty() );
+            EXPECT_CONTAINER_SIZE( l, nSize );
+
+            l.clear();
+
+            ASSERT_TRUE( l.empty() );
+            EXPECT_CONTAINER_SIZE( l, 0 );
+
+            // empty list iterator test
+            {
+                List const& cl = l;
+                EXPECT_TRUE( l.begin() == l.end());
+                EXPECT_TRUE( l.cbegin() == l.cend());
+                EXPECT_TRUE( cl.begin() == cl.end());
+                EXPECT_TRUE( l.begin() == l.cend());
+                EXPECT_TRUE( cl.begin() == l.end());
+            }
+        }
+
+        template <typename List>
+        void test_ordered_iterator( List& l )
+        {
+            // Precondition: list is empty
+            // Postcondition: list is empty
+
+            static const size_t nSize = 20;
+            struct key_val {
+                int key;
+                int val;
+            };
+            key_val arr[nSize];
+
+            for ( size_t i = 0; i < nSize; ++i ) {
+                arr[i].key = static_cast<int>(i);
+                arr[i].val = arr[i].key;
+            }
+            shuffle( arr, arr + nSize );
+
+            ASSERT_TRUE( l.empty() );
+            ASSERT_CONTAINER_SIZE( l, 0 );
+
+            for ( auto& i : arr )
+                EXPECT_TRUE( l.insert( i.key, i.val ));
+
+            int key = 0;
+            for ( auto& it : l ) {
+                EXPECT_EQ( key, it.first.key() );
+                EXPECT_EQ( it.second.val, it.first.key() );
+                it.second.val = it.first.key() * 10;
+                ++key;
+            }
+            EXPECT_EQ( static_cast<size_t>(key), nSize );
+
+            key = 0;
+            for ( auto it = l.cbegin(); it != l.cend(); ++it ) {
+                EXPECT_EQ( key, it->first.key() );
+                EXPECT_EQ( it->first.key() * 10, it->second.val );
+                ++key;
+            }
+            EXPECT_EQ( static_cast<size_t>(key), nSize );
+
+            key = 0;
+            for ( auto it = l.begin(); it != l.end(); ++it ) {
+                EXPECT_EQ( key, it->first.key() );
+                EXPECT_EQ( it->first.key() * 10, it->second.val );
+                it->second.val = it->first.key() * 2;
+                ++key;
+            }
+            EXPECT_EQ( static_cast<size_t>(key), nSize );
+
+            List const& cl = l;
+            key = 0;
+            for ( auto it = cl.begin(); it != cl.end(); ++it ) {
+                EXPECT_EQ( key, it->first.nKey );
+                EXPECT_EQ( it->first.nKey * 2, it->second.val );
+                ++key;
+            }
+            EXPECT_EQ( static_cast<size_t>(key), nSize );
+
+            l.clear();
+            ASSERT_TRUE( l.empty() );
+            EXPECT_CONTAINER_SIZE( l, 0 );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // CDSUNIT_LIST_TEST_KV_LIST_H
diff --git a/test/unit/list/test_kv_list_hp.h b/test/unit/list/test_kv_list_hp.h
new file mode 100644 (file)
index 0000000..c401e66
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.     
+*/
+
+#ifndef CDSUNIT_LIST_TEST_KV_LIST_HP_H
+#define CDSUNIT_LIST_TEST_KV_LIST_HP_H
+
+#include "test_kv_list.h"
+
+namespace cds_test {
+
+    class kv_list_hp : public kv_list_common
+    {
+    protected:
+        template <typename List>
+        void test_hp( List& l )
+        {
+            // Precondition: list is empty
+            // Postcondition: list is empty
+
+            static const size_t nSize = 20;
+            typedef typename List::key_type    list_key_type;
+            typedef typename List::mapped_type list_mapped_type;
+            typedef typename List::value_type  list_value_type;
+            typedef typename List::guarded_ptr guarded_ptr;
+
+            struct key_val {
+                int key;
+                int val;
+            };
+            key_val arr[nSize];
+
+            for ( size_t i = 0; i < nSize; ++i ) {
+                arr[i].key = static_cast<int>(i);
+                arr[i].val = arr[i].key * 10;
+            }
+            shuffle( arr, arr + nSize );
+
+            ASSERT_TRUE( l.empty() );
+            ASSERT_CONTAINER_SIZE( l, 0 );
+
+            guarded_ptr gp;
+            size_t nCount = 0;
+
+            // get() test
+            for ( auto& i : arr ) {
+                gp = l.get( i.key );
+                EXPECT_TRUE( !gp );
+                gp = l.get_with( other_key( i.key ), other_less());
+                EXPECT_TRUE( !gp );
+
+                EXPECT_TRUE( l.insert( i.key, i.val ));
+
+                gp = l.get( i.key );
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.key );
+                EXPECT_EQ( gp->second.val, gp->first.nKey * 10 );
+                gp->second.val = gp->first.nKey * 5;
+
+                gp = l.get_with( other_key( i.key ), other_less());
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.key );
+                EXPECT_EQ( gp->second.val, gp->first.nKey * 5 );
+                gp->second.val = gp->first.nKey * 10;
+
+                ++nCount;
+                ASSERT_FALSE( l.empty() );
+                ASSERT_CONTAINER_SIZE( l, nCount );
+            }
+
+            ASSERT_FALSE( l.empty() );
+            ASSERT_CONTAINER_SIZE( l, nSize );
+
+            // extract() test
+            for ( auto const& i : arr ) {
+                ASSERT_FALSE( l.empty() );
+                ASSERT_CONTAINER_SIZE( l, nCount );
+                --nCount;
+
+                gp = l.get( i.key );
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.key );
+
+                switch ( i.key & 1 ) {
+                    case 0:
+                        gp = l.extract( i.key );
+                        break;
+                    case 1:
+                        gp = l.extract_with( other_key( i.key ), other_less());
+                        break;
+                }
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.key );
+                EXPECT_EQ( gp->second.val, gp->first.nKey * 10 );
+
+                gp = l.get( i.key );
+                EXPECT_FALSE( gp );
+
+                gp = l.extract( i.key );
+                EXPECT_FALSE( gp );
+                gp = l.extract_with( other_key( i.key ), other_less());
+                EXPECT_FALSE( gp );
+            }
+
+            ASSERT_TRUE( l.empty() );
+            ASSERT_CONTAINER_SIZE( l, 0 );
+        }
+    };
+
+} // namespace cds_list
+
+#endif // CDSUNIT_LIST_TEST_KV_LIST_HP_H