Migrated FeldmanHashSet unit test to gtest framework
authorkhizmax <libcds.dev@gmail.com>
Sat, 19 Mar 2016 16:00:20 +0000 (19:00 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 19 Mar 2016 16:00:20 +0000 (19:00 +0300)
13 files changed:
projects/Win/vc14/gtest-set.vcxproj
projects/Win/vc14/gtest-set.vcxproj.filters
test/unit/set/CMakeLists.txt
test/unit/set/feldman_hashset_dhp.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_hp.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_rcu_gpb.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_rcu_gpi.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_rcu_gpt.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_rcu_shb.cpp [new file with mode: 0644]
test/unit/set/feldman_hashset_rcu_sht.cpp [new file with mode: 0644]
test/unit/set/test_feldman_hashset.h [new file with mode: 0644]
test/unit/set/test_feldman_hashset_hp.h [new file with mode: 0644]
test/unit/set/test_feldman_hashset_rcu.h [new file with mode: 0644]

index df5b23b61db239939dfabcb9cb07bdc674e3ca85..4aacc4701e70e1dd506a0348ea1608459094a8f3 100644 (file)
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\test\unit\main.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_dhp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_hp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpb.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpi.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpt.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_shb.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_sht.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\set\michael_lazy_dhp.cpp">\r
       <DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4503</DisableSpecificWarnings>\r
       <DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">4503</DisableSpecificWarnings>\r
     <ClCompile Include="..\..\..\test\unit\set\split_michael_rcu_sht.cpp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset.h" />\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset_hp.h" />\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\set\test_michael_lazy_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\set\test_michael_michael_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\set\test_set.h" />\r
index aad25aaadd5f1ddb1ba63bfd95a4b16e04f563b7..e86e1df2fb73255627d9ab296496e5254b50937d 100644 (file)
@@ -22,6 +22,9 @@
     <Filter Include="Source Files\SkipList">\r
       <UniqueIdentifier>{5c30de7f-5e68-4ef5-b9a5-63a1ec626010}</UniqueIdentifier>\r
     </Filter>\r
+    <Filter Include="Source Files\FeldmanHashSet">\r
+      <UniqueIdentifier>{0f6f4b41-97bc-411f-b24e-790ff162e314}</UniqueIdentifier>\r
+    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\test\unit\main.cpp">\r
     <ClCompile Include="..\..\..\test\unit\set\skiplist_rcu_sht.cpp">\r
       <Filter>Source Files\SkipList</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_hp.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_dhp.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpb.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpi.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_gpt.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_shb.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\set\feldman_hashset_rcu_sht.cpp">\r
+      <Filter>Source Files\FeldmanHashSet</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\..\test\unit\set\test_set.h">\r
     <ClInclude Include="..\..\..\test\unit\set\test_skiplist_rcu.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset_hp.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\set\test_feldman_hashset_rcu.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 0dae6f46f28f954e04de9df8cfddda90f427ab42..dcd684a157299728f382e7a8fa46f9601948d517 100644 (file)
@@ -2,6 +2,13 @@ set(PACKAGE_NAME unit-set)
 
 set(CDSGTEST_SET_SOURCES
     ../main.cpp
+    feldman_hashset_hp.cpp
+    feldman_hashset_dhp.cpp
+    feldman_hashset_rcu_gpb.cpp
+    feldman_hashset_rcu_gpi.cpp
+    feldman_hashset_rcu_gpt.cpp
+    feldman_hashset_rcu_shb.cpp
+    feldman_hashset_rcu_sht.cpp
     michael_lazy_hp.cpp
     michael_lazy_dhp.cpp
     michael_lazy_nogc.cpp
diff --git a/test/unit/set/feldman_hashset_dhp.cpp b/test/unit/set/feldman_hashset_dhp.cpp
new file mode 100644 (file)
index 0000000..af80c86
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+    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_feldman_hashset_hp.h"
+
+#include <cds/container/feldman_hashset_dhp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::DHP gc_type;
+
+    class FeldmanHashSet_DHP : public cds_test::feldman_hashset_hp
+    {
+    protected:
+        typedef cds_test::feldman_hashset_hp base_class;
+
+        void SetUp()
+        {
+            struct set_traits: public cc::feldman_hashset::traits
+            {
+                typedef get_hash hash_accessor;
+            };
+            typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+            cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::dhp::GarbageCollector::Destruct();
+        }
+    };
+
+    TEST_F( FeldmanHashSet_DHP, defaulted )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+            >::type
+        > set_type;
+
+        set_type s;
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, compare )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                ,cds::opt::compare< cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 5 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, less )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                ,cds::opt::less< std::less<int> >
+            >::type
+        > set_type;
+
+        set_type s( 3, 2 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, cmpmix )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                , cds::opt::less< std::less<int> >
+                ,cds::opt::compare< cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 4 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, item_counting )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cmp compare;
+            typedef std::less<int> less;
+            typedef simple_item_counter item_counter;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 3, 3 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, backoff )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cmp compare;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::yield back_off;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 8, 2 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_DHP, stat )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cds::backoff::yield back_off;
+            typedef cc::feldman_hashset::stat<> stat;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 1, 1 );
+        test( s );
+    }
+
+} // namespace
diff --git a/test/unit/set/feldman_hashset_hp.cpp b/test/unit/set/feldman_hashset_hp.cpp
new file mode 100644 (file)
index 0000000..d5f6e18
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+    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_feldman_hashset_hp.h"
+
+#include <cds/container/feldman_hashset_hp.h>
+
+namespace {
+    namespace cc = cds::container;
+    typedef cds::gc::HP gc_type;
+
+    class FeldmanHashSet_HP : public cds_test::feldman_hashset_hp
+    {
+    protected:
+        typedef cds_test::feldman_hashset_hp base_class;
+
+        void SetUp()
+        {
+            struct set_traits: public cc::feldman_hashset::traits
+            {
+                typedef get_hash hash_accessor;
+            };
+            typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+            // +1 - for guarded_ptr
+            cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct( true );
+        }
+    };
+
+    TEST_F( FeldmanHashSet_HP, defaulted )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+            >::type
+        > set_type;
+
+        set_type s;
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, compare )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                ,cds::opt::compare< cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 5 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, less )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                ,cds::opt::less< std::less<int> >
+            >::type
+        > set_type;
+
+        set_type s( 3, 2 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, cmpmix )
+    {
+        typedef cc::FeldmanHashSet< gc_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                , cds::opt::less< std::less<int> >
+                ,cds::opt::compare< cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 4 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, item_counting )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cmp compare;
+            typedef std::less<int> less;
+            typedef simple_item_counter item_counter;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 3, 3 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, backoff )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cmp compare;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::yield back_off;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 8, 2 );
+        test( s );
+    }
+
+    TEST_F( FeldmanHashSet_HP, stat )
+    {
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cds::backoff::yield back_off;
+            typedef cc::feldman_hashset::stat<> stat;
+        };
+        typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
+
+        set_type s( 1, 1 );
+        test( s );
+    }
+
+} // namespace
diff --git a/test/unit/set/feldman_hashset_rcu_gpb.cpp b/test/unit/set/feldman_hashset_rcu_gpb.cpp
new file mode 100644 (file)
index 0000000..9e01f1d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    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 <cds/urcu/general_buffered.h>
+
+#include "test_feldman_hashset_rcu.h"
+
+namespace {
+
+    typedef cds::urcu::general_buffered<> rcu_implementation;
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPB, FeldmanHashSet, rcu_implementation );
diff --git a/test/unit/set/feldman_hashset_rcu_gpi.cpp b/test/unit/set/feldman_hashset_rcu_gpi.cpp
new file mode 100644 (file)
index 0000000..478c69b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    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 <cds/urcu/general_instant.h>
+
+#include "test_feldman_hashset_rcu.h"
+
+namespace {
+
+    typedef cds::urcu::general_instant<> rcu_implementation;
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPI, FeldmanHashSet, rcu_implementation );
diff --git a/test/unit/set/feldman_hashset_rcu_gpt.cpp b/test/unit/set/feldman_hashset_rcu_gpt.cpp
new file mode 100644 (file)
index 0000000..33c4fb7
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    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 <cds/urcu/general_threaded.h>
+
+#include "test_feldman_hashset_rcu.h"
+
+namespace {
+
+    typedef cds::urcu::general_threaded<> rcu_implementation;
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P( RCU_GPT, FeldmanHashSet, rcu_implementation );
diff --git a/test/unit/set/feldman_hashset_rcu_shb.cpp b/test/unit/set/feldman_hashset_rcu_shb.cpp
new file mode 100644 (file)
index 0000000..bacf830
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    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 <cds/urcu/signal_buffered.h>
+
+#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
+
+#include "test_feldman_hashset_rcu.h"
+
+namespace {
+
+    typedef cds::urcu::signal_buffered<> rcu_implementation;
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHB, FeldmanHashSet, rcu_implementation );
+
+#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED
diff --git a/test/unit/set/feldman_hashset_rcu_sht.cpp b/test/unit/set/feldman_hashset_rcu_sht.cpp
new file mode 100644 (file)
index 0000000..e169b41
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    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 <cds/urcu/signal_threaded.h>
+
+#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
+
+#include "test_feldman_hashset_rcu.h"
+
+namespace {
+
+    typedef cds::urcu::signal_threaded<> rcu_implementation;
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P( RCU_SHT, FeldmanHashSet, rcu_implementation );
+
+#endif // CDS_URCU_SIGNAL_HANDLING_ENABLED
diff --git a/test/unit/set/test_feldman_hashset.h b/test/unit/set/test_feldman_hashset.h
new file mode 100644 (file)
index 0000000..1bfbe3a
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+    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_SET_TEST_FELDMAN_HASHSET_H
+#define CDSUNIT_SET_TEST_FELDMAN_HASHSET_H
+
+#include <cds_test/check_size.h>
+#include <cds_test/fixture.h>
+
+#include <cds/opt/hash.h>
+
+// forward declaration
+namespace cds { namespace container {}}
+namespace co = cds::opt;
+namespace cc = cds::container;
+
+namespace cds_test {
+
+    class feldman_hashset : public fixture
+    {
+    public:
+        static size_t const kSize = 1000;
+
+        struct stat
+        {
+            unsigned int nFindCount;
+            unsigned int nUpdateNewCount;
+            unsigned int nUpdateCount;
+
+            stat()
+            {
+                clear_stat();
+            }
+
+            void clear_stat()
+            {
+                memset( this, 0, sizeof( *this ) );
+            }
+        };
+
+        struct other_item {
+            int nKey;
+
+            explicit other_item( int k )
+                : nKey( k )
+            {}
+
+            int key() const
+            {
+                return nKey;
+            }
+        };
+
+        struct int_item: public stat
+        {
+            int nKey;
+            int nVal;
+            std::string strVal;
+
+            int_item()
+                : nKey( 0 )
+                , nVal( 0 )
+            {}
+
+            explicit int_item( int k )
+                : nKey( k )
+                , nVal( k * 2 )
+            {}
+
+            template <typename Q>
+            explicit int_item( Q const& src )
+                : nKey( src.key() )
+                , nVal( 0 )
+            {}
+
+            int_item( int_item const& src )
+                : nKey( src.nKey )
+                , nVal( src.nVal )
+                , strVal( src.strVal )
+            {}
+
+            int_item( int_item&& src )
+                : nKey( src.nKey )
+                , nVal( src.nVal )
+                , strVal( std::move( src.strVal ) )
+            {}
+
+            int_item( int k, std::string&& s )
+                : nKey( k )
+                , nVal( k * 2 )
+                , strVal( std::move( s ) )
+            {}
+
+            explicit int_item( other_item const& s )
+                : nKey( s.key() )
+                , nVal( s.key() * 2 )
+            {}
+
+            int key() const
+            {
+                return nKey;
+            }
+        };
+
+        struct get_hash {
+            int operator()( int_item const& i ) const
+            {
+                return i.key();
+            }
+
+            int operator()( other_item const& i ) const
+            {
+                return i.key();
+            }
+
+            int operator()( int i ) const
+            {
+                return i;
+            }
+        };
+
+        struct simple_item_counter {
+            size_t  m_nCount;
+
+            simple_item_counter()
+                : m_nCount( 0 )
+            {}
+
+            size_t operator ++()
+            {
+                return ++m_nCount;
+            }
+
+            size_t operator --()
+            {
+                return --m_nCount;
+            }
+
+            void reset()
+            {
+                m_nCount = 0;
+            }
+
+            operator size_t() const
+            {
+                return m_nCount;
+            }
+
+        };
+
+        struct cmp {
+            int operator ()( int v1, int v2 ) const
+            {
+                if ( v1 < v2 )
+                    return -1;
+                return v1 > v2 ? 1 : 0;
+            }
+        };
+
+        struct other_less {
+            template <typename Q, typename T>
+            bool operator()( Q const& lhs, T const& rhs ) const
+            {
+                return lhs.key() < rhs.key();
+            }
+        };
+
+    protected:
+        template <typename Set>
+        void test( Set& s )
+        {
+            // Precondition: set is empty
+            // Postcondition: set is empty
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+            size_t const nSetSize = kSize;
+
+            typedef typename Set::value_type value_type;
+
+            std::vector< value_type > data;
+            std::vector< size_t> indices;
+            data.reserve( kSize );
+            indices.reserve( kSize );
+            for ( size_t key = 0; key < kSize; ++key ) {
+                data.push_back( value_type( static_cast<int>(key) ) );
+                indices.push_back( key );
+            }
+            shuffle( indices.begin(), indices.end() );
+
+            // insert/find
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                ASSERT_FALSE( s.contains( i.nKey ) );
+                ASSERT_FALSE( s.find( i.nKey, []( value_type& ) {} ));
+
+                std::pair<bool, bool> updResult;
+
+                std::string str;
+                updResult = s.update( i.key(), []( value_type&, value_type * )
+                {
+                    ASSERT_TRUE( false );
+                }, false );
+                EXPECT_FALSE( updResult.first );
+                EXPECT_FALSE( updResult.second );
+
+                switch ( idx % 8 ) {
+                case 0:
+                    ASSERT_TRUE( s.insert( i ));
+                    ASSERT_FALSE( s.insert( i ));
+                    updResult = s.update( i, []( value_type& val, value_type * prev ) 
+                        {
+                            ASSERT_TRUE( prev != nullptr );
+                            EXPECT_EQ( val.key(), prev->key() );
+                        }, false );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+                    break;
+                case 1:
+                    ASSERT_TRUE( s.insert( i.key() ));
+                    ASSERT_FALSE( s.insert( i.key() ));
+                    updResult = s.update( i.key(), []( value_type& val, value_type * prev )
+                        {
+                            ASSERT_TRUE( prev != nullptr );
+                            EXPECT_EQ( val.key(), prev->key() );
+                        }, false );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+                    break;
+                case 2:
+                    ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
+                    ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
+                    ASSERT_TRUE( s.find( i.nKey, []( value_type const& v ) 
+                        {
+                            EXPECT_EQ( v.nFindCount, 1 );
+                        }));
+                    break;
+                case 3:
+                    ASSERT_TRUE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
+                    ASSERT_FALSE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
+                    ASSERT_TRUE( s.find( i.nKey, []( value_type const& v ) 
+                        {
+                            EXPECT_EQ( v.nFindCount, 1 );
+                        }));
+                    break;
+                case 4:
+                    updResult = s.update( i, []( value_type& v, value_type * prev )
+                        {
+                            EXPECT_TRUE( prev == nullptr );
+                            ++v.nUpdateNewCount;
+                        });
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
+
+                    updResult = s.update( i, []( value_type& v, value_type * prev )
+                        {
+                            ASSERT_TRUE( prev != nullptr );
+                            EXPECT_EQ( prev->nUpdateNewCount, 1 );
+                            EXPECT_EQ( v.key(), prev->key() );
+                            ++v.nUpdateCount;
+                        }, false );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+
+                    ASSERT_TRUE( s.find( i.nKey, []( value_type const& v )
+                        {
+                            EXPECT_EQ( v.nUpdateCount, 1 );
+                            EXPECT_EQ( v.nUpdateNewCount, 0 );
+                        }));
+                    break;
+                case 5:
+                    updResult = s.update( i.key(), []( value_type& v, value_type * prev )
+                        {
+                            EXPECT_TRUE( prev == nullptr );
+                            ++v.nUpdateNewCount;
+                        });
+                        EXPECT_TRUE( updResult.first );
+                        EXPECT_TRUE( updResult.second );
+
+                        updResult = s.update( i.key(), []( value_type& v, value_type * prev )
+                        {
+                            ASSERT_TRUE( prev != nullptr );
+                            EXPECT_EQ( v.key(), prev->key() );
+                            EXPECT_EQ( prev->nUpdateNewCount, 1 );
+                            EXPECT_EQ( v.nUpdateNewCount, 0 );
+                            ++v.nUpdateNewCount;
+                        }, false );
+                        EXPECT_TRUE( updResult.first );
+                        EXPECT_FALSE( updResult.second );
+
+                        ASSERT_TRUE( s.find( i.key(), []( value_type const& v )
+                        {
+                            EXPECT_EQ( v.nUpdateNewCount, 1 );
+                        } ) );
+                        break;
+                case 6:
+                    ASSERT_TRUE( s.emplace( i.key() ) );
+                    ASSERT_TRUE( s.contains( i.key() ) );
+                    break;
+                case 7:
+                    str = "Hello!";
+                    ASSERT_TRUE( s.emplace( i.key(), std::move( str ) ) );
+                    EXPECT_TRUE( str.empty() );
+                    ASSERT_TRUE( s.find( i.key(), []( value_type const& v )
+                    {
+                        EXPECT_EQ( v.strVal, std::string( "Hello!" ) );
+                    } ) );
+                    break;
+                default:
+                    // forgot anything?..
+                    ASSERT_TRUE( false );
+                }
+
+                ASSERT_TRUE( s.contains( i.nKey ) );
+                ASSERT_TRUE( s.find( i.nKey, []( value_type& ) {} ) );
+            }
+
+            ASSERT_FALSE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, nSetSize );
+
+            // erase
+            shuffle( indices.begin(), indices.end() );
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                ASSERT_TRUE( s.contains( i.nKey ) );
+                ASSERT_TRUE( s.find( i.nKey, []( value_type& v )
+                {
+                    v.nFindCount = 1;
+                } ) );
+
+                int nKey = i.key() - 1;
+                switch ( idx % 2 ) {
+                case 0:
+                    ASSERT_TRUE( s.erase( i.key() ) );
+                    ASSERT_FALSE( s.erase( i.key() ) );
+                    break;
+                case 1:
+                    ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
+                    {
+                        EXPECT_EQ( v.nFindCount, 1 );
+                        nKey = v.key();
+                    } ) );
+                    EXPECT_EQ( i.key(), nKey );
+
+                    nKey = i.key() - 1;
+                    ASSERT_FALSE( s.erase( i.key(), [&nKey]( value_type const& v )
+                    {
+                        nKey = v.key();
+                    } ) );
+                    EXPECT_EQ( i.key(), nKey + 1 );
+                    break;
+                }
+
+                ASSERT_FALSE( s.contains( i.nKey ) );
+                ASSERT_FALSE( s.find( i.nKey, []( value_type const& ) {} ) );
+            }
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+
+
+            // clear
+            for ( auto& i : data ) {
+                ASSERT_TRUE( s.insert( i ) );
+            }
+
+            {
+                typename Set::stat const& statistics = s.statistics();
+                CDS_UNUSED( statistics );
+
+                std::vector< typename Set::level_statistics > lstat;
+                s.get_level_statistics( lstat );
+                EXPECT_EQ( lstat[0].node_capacity, s.head_size() );
+                for ( size_t i = 1; i < lstat.size(); ++i ) {
+                    EXPECT_EQ( lstat[i].node_capacity, s.array_node_size());
+                }
+            }
+
+            ASSERT_FALSE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, nSetSize );
+
+            s.clear();
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+
+            ASSERT_TRUE( s.begin() == s.end() );
+            ASSERT_TRUE( s.cbegin() == s.cend() );
+            ASSERT_TRUE( s.rbegin() == s.rend() );
+            ASSERT_TRUE( s.crbegin() == s.crend() );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // CDSUNIT_SET_TEST_FELDMAN_HASHSET_H
diff --git a/test/unit/set/test_feldman_hashset_hp.h b/test/unit/set/test_feldman_hashset_hp.h
new file mode 100644 (file)
index 0000000..aa06b34
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+    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_SET_TEST_FELDMAN_HASHSET_HP_H
+#define CDSUNIT_SET_TEST_FELDMAN_HASHSET_HP_H
+
+#include "test_feldman_hashset.h"
+
+namespace cds_test {
+
+    class feldman_hashset_hp: public feldman_hashset
+    {
+        typedef feldman_hashset base_class;
+
+    protected:
+        template <typename Set>
+        void test( Set& s )
+        {
+            // Precondition: set is empty
+            // Postcondition: set is empty
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+
+            base_class::test( s );
+
+            typedef typename Set::value_type value_type;
+
+            size_t const nSetSize = kSize;
+            std::vector< value_type > data;
+            std::vector< size_t> indices;
+            data.reserve( kSize );
+            indices.reserve( kSize );
+            for ( size_t key = 0; key < kSize; ++key ) {
+                data.push_back( value_type( static_cast<int>(key) ) );
+                indices.push_back( key );
+            }
+            shuffle( indices.begin(), indices.end() );
+
+            for ( auto& i : data ) {
+                ASSERT_TRUE( s.insert( i ) );
+            }
+            ASSERT_FALSE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, nSetSize );
+
+            // iterator test
+            for ( auto it = s.begin(); it != s.end(); ++it ) {
+                it->nFindCount = it->key() * 3;
+                it.release();
+            }
+
+            for ( auto it = s.cbegin(); it != s.cend(); ++it ) {
+                EXPECT_EQ( it->nFindCount, it->key() * 3 );
+            }
+
+            // reverse iterator set
+            for ( auto it = s.rbegin(); it != s.rend(); ++it ) {
+                it->nFindCount = it->key() * 2;
+            }
+
+            for ( auto it = s.crbegin(); it != s.crend(); ++it ) {
+                EXPECT_EQ( it->nFindCount, it->key() * 2 );
+            }
+
+            typedef typename Set::guarded_ptr guarded_ptr;
+            guarded_ptr gp;
+
+            // get()
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                ASSERT_TRUE( !gp );
+
+                gp = s.get( i.key());
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->key(), i.key() );
+                EXPECT_EQ( gp->nFindCount, i.key() * 2 );
+                gp->nFindCount *= 2;
+
+                gp.release();
+            }
+
+            // extract()
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                ASSERT_TRUE( !gp );
+                gp = s.extract( i.key() );
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->key(), i.key() );
+                EXPECT_EQ( gp->nFindCount, i.key() * 4 );
+
+                gp = s.extract( i.key() );
+                ASSERT_TRUE( !gp );
+            }
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+
+            // erase_at()
+            for ( auto& i : data ) {
+                ASSERT_TRUE( s.insert( i ) );
+            }
+            ASSERT_FALSE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, nSetSize );
+
+            for ( auto it = s.begin(); it != s.end(); ++it ) {
+                int key = it->key();
+                ASSERT_TRUE( s.erase_at( it ));
+                ASSERT_TRUE( &*it != nullptr );
+                EXPECT_EQ( it->key(), key );
+                ASSERT_FALSE( s.erase_at( it ) );
+            }
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+        }
+
+    };
+} // namespace cds_test
+
+#endif // CDSUNIT_SET_TEST_FELDMAN_HASHSET_HP_H
diff --git a/test/unit/set/test_feldman_hashset_rcu.h b/test/unit/set/test_feldman_hashset_rcu.h
new file mode 100644 (file)
index 0000000..b5afb6a
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+    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_SET_TEST_FELDMAN_HASHSET_RCU_H
+#define CDSUNIT_SET_TEST_FELDMAN_HASHSET_RCU_H
+
+#include "test_feldman_hashset.h"
+
+#include <cds/container/feldman_hashset_rcu.h>
+
+namespace {
+
+    namespace cc = cds::container;
+
+    template <typename RCU>
+    class FeldmanHashSet: public cds_test::feldman_hashset
+    {
+        typedef cds_test::feldman_hashset base_class;
+
+    protected:
+        typedef cds::urcu::gc<RCU> rcu_type;
+
+        template <typename Set>
+        void test( Set& s )
+        {
+            // Precondition: set is empty
+            // Postcondition: set is empty
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+
+            base_class::test( s );
+
+            typedef typename Set::value_type value_type;
+
+            size_t const nSetSize = kSize;
+            std::vector< value_type > data;
+            std::vector< size_t> indices;
+            data.reserve( kSize );
+            indices.reserve( kSize );
+            for ( size_t key = 0; key < kSize; ++key ) {
+                data.push_back( value_type( static_cast<int>(key) ) );
+                indices.push_back( key );
+            }
+            shuffle( indices.begin(), indices.end() );
+
+            for ( auto& i : data ) {
+                ASSERT_TRUE( s.insert( i ) );
+            }
+            ASSERT_FALSE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, nSetSize );
+
+            typedef typename Set::rcu_lock rcu_lock;
+
+            // iterator test
+            {
+                rcu_lock l;
+
+                for ( auto it = s.begin(); it != s.end(); ++it ) {
+                    it->nFindCount = it->key() * 3;
+                }
+
+                for ( auto it = s.cbegin(); it != s.cend(); ++it ) {
+                    EXPECT_EQ( it->nFindCount, it->key() * 3 );
+                }
+
+                for ( auto it = s.rbegin(); it != s.rend(); ++it ) {
+                    it->nFindCount = it->key() * 2;
+                }
+
+                for ( auto it = s.crbegin(); it != s.crend(); ++it ) {
+                    EXPECT_EQ( it->nFindCount, it->key() * 2 );
+                }
+            }
+
+            typedef typename Set::exempt_ptr exempt_ptr;
+
+            // get()
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                {
+                    rcu_lock l;
+                    value_type * p = s.get( i.key());
+                    ASSERT_TRUE( p != nullptr );
+                    EXPECT_EQ( p->key(), i.key() );
+                    EXPECT_EQ( p->nFindCount, i.key() * 2 );
+                    p->nFindCount *= 2;
+                }
+            }
+
+            // extract()
+            exempt_ptr xp;
+            for ( auto idx : indices ) {
+                auto& i = data[idx];
+
+                ASSERT_TRUE( !xp );
+                xp = s.extract( i.key() );
+                ASSERT_FALSE( !xp );
+                EXPECT_EQ( xp->key(), i.key() );
+                EXPECT_EQ( xp->nFindCount, i.key() * 4 );
+
+                xp = s.extract( i.key() );
+                ASSERT_TRUE( !xp );
+
+                {
+                    rcu_lock l;
+                    value_type * p = s.get( i.key() );
+                    EXPECT_TRUE( p == nullptr );
+                }
+            }
+
+            ASSERT_TRUE( s.empty() );
+            ASSERT_CONTAINER_SIZE( s, 0 );
+        }
+
+        void SetUp()
+        {
+            RCU::Construct();
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            RCU::Destruct();
+        }
+    };
+
+    TYPED_TEST_CASE_P( FeldmanHashSet );
+
+    TYPED_TEST_P( FeldmanHashSet, defaulted )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        typedef cc::FeldmanHashSet< rcu_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+            >::type
+        > set_type;
+
+        set_type s;
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, compare )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        typedef cc::FeldmanHashSet< rcu_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                , cds::opt::compare<  typename TestFixture::cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 5 );
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, less )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        typedef cc::FeldmanHashSet< rcu_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                , cds::opt::less< std::less<int> >
+            >::type
+        > set_type;
+
+        set_type s( 3, 2 );
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, cmpmix )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        typedef cc::FeldmanHashSet< rcu_type, int_item,
+            typename cc::feldman_hashset::make_traits<
+                cc::feldman_hashset::hash_accessor< get_hash >
+                , cds::opt::less< std::less<int> >
+                , cds::opt::compare<  typename TestFixture::cmp >
+            >::type
+        > set_type;
+
+        set_type s( 4, 4 );
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, item_counting )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef typename TestFixture::cmp compare;
+            typedef std::less<int> less;
+            typedef typename TestFixture::simple_item_counter item_counter;
+        };
+        typedef cc::FeldmanHashSet< rcu_type, int_item, set_traits > set_type;
+
+        set_type s( 3, 3 );
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, backoff )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef typename TestFixture::cmp compare;
+            typedef cds::atomicity::item_counter item_counter;
+            typedef cds::backoff::yield back_off;
+        };
+        typedef cc::FeldmanHashSet< rcu_type, int_item, set_traits > set_type;
+
+        set_type s( 8, 2 );
+        this->test( s );
+    }
+
+    TYPED_TEST_P( FeldmanHashSet, stat )
+    {
+        typedef typename TestFixture::rcu_type rcu_type;
+        typedef typename TestFixture::int_item int_item;
+        typedef typename TestFixture::get_hash get_hash;
+
+        struct set_traits: public cc::feldman_hashset::traits
+        {
+            typedef get_hash hash_accessor;
+            typedef cds::backoff::yield back_off;
+            typedef cc::feldman_hashset::stat<> stat;
+        };
+        typedef cc::FeldmanHashSet< rcu_type, int_item, set_traits > set_type;
+
+        set_type s( 1, 1 );
+        this->test( s );
+    }
+
+    // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
+    // "No test named <test_name> can be found in this test case"
+    REGISTER_TYPED_TEST_CASE_P( FeldmanHashSet,
+        defaulted, compare, less, cmpmix, item_counting, backoff, stat
+        );
+} // namespace
+
+#endif // CDSUNIT_SET_TEST_FELDMAN_HASHSET_RCU_H