From 351c26c95192a6a1b567c455a8737c065026f0c6 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 20 Mar 2016 12:03:51 +0300 Subject: [PATCH] Migrated intrusive::CuckooSet unit test to gtest --- projects/Win/vc14/cds.sln | 15 + projects/Win/vc14/gtest-striped-set.vcxproj | 253 ++++ .../vc14/gtest-striped-set.vcxproj.filters | 30 + test/unit/CMakeLists.txt | 1 + test/unit/striped-set/CMakeLists.txt | 23 + .../unit/striped-set/intrusive_cuckoo_set.cpp | 1278 +++++++++++++++++ test/unit/striped-set/test_intrusive_set.h | 461 ++++++ 7 files changed, 2061 insertions(+) create mode 100644 projects/Win/vc14/gtest-striped-set.vcxproj create mode 100644 projects/Win/vc14/gtest-striped-set.vcxproj.filters create mode 100644 test/unit/striped-set/CMakeLists.txt create mode 100644 test/unit/striped-set/intrusive_cuckoo_set.cpp create mode 100644 test/unit/striped-set/test_intrusive_set.h diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index 4ccf4b30..ea0d622e 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -215,6 +215,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-intrusive-set", "gtes {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-striped-set", "gtest-striped-set.vcxproj", "{648021D3-6E18-4B94-88B8-F6A59609E210}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -549,6 +551,18 @@ Global {EC1EF263-7E34-4867-9ED9-77AA7963CD4A}.Release|Win32.Build.0 = Release|Win32 {EC1EF263-7E34-4867-9ED9-77AA7963CD4A}.Release|x64.ActiveCfg = Release|x64 {EC1EF263-7E34-4867-9ED9-77AA7963CD4A}.Release|x64.Build.0 = Release|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Debug|Win32.ActiveCfg = Debug|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Debug|Win32.Build.0 = Debug|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Debug|x64.ActiveCfg = Debug|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Debug|x64.Build.0 = Debug|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|Win32.ActiveCfg = Release|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|Win32.Build.0 = Release|Win32 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|x64.ActiveCfg = Release|x64 + {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -582,6 +596,7 @@ Global {51AC349E-B365-4FCF-8778-17A1534E4584} = {10E1FAF2-904D-405E-8AB5-6878A1B03346} {A589D3F1-A749-4268-ADEC-D0CE13D1E359} = {810490B7-31E5-49AE-8455-CAF99A9658B6} {EC1EF263-7E34-4867-9ED9-77AA7963CD4A} = {810490B7-31E5-49AE-8455-CAF99A9658B6} + {648021D3-6E18-4B94-88B8-F6A59609E210} = {810490B7-31E5-49AE-8455-CAF99A9658B6} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc14/gtest-striped-set.vcxproj b/projects/Win/vc14/gtest-striped-set.vcxproj new file mode 100644 index 00000000..1540a602 --- /dev/null +++ b/projects/Win/vc14/gtest-striped-set.vcxproj @@ -0,0 +1,253 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + + + {648021D3-6E18-4B94-88B8-F6A59609E210} + Win32Proj + striped-set + 8.1 + + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + true + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/projects/Win/vc14/gtest-striped-set.vcxproj.filters b/projects/Win/vc14/gtest-striped-set.vcxproj.filters new file mode 100644 index 00000000..0c3d663d --- /dev/null +++ b/projects/Win/vc14/gtest-striped-set.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index fb88bf81..9ae37177 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -4,4 +4,5 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/queue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/intrusive-set) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/set) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/striped-set) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack) diff --git a/test/unit/striped-set/CMakeLists.txt b/test/unit/striped-set/CMakeLists.txt new file mode 100644 index 00000000..0a6fe2f8 --- /dev/null +++ b/test/unit/striped-set/CMakeLists.txt @@ -0,0 +1,23 @@ +set(PACKAGE_NAME unit-striped-set) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -DCDSUNIT_ENABLE_BOOST_CONTAINER") + +set(CDSGTEST_SET_SOURCES + ../main.cpp + intrusive_cuckoo_set.cpp +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(${PACKAGE_NAME} ${CDSGTEST_SET_SOURCES}) +target_link_libraries(${PACKAGE_NAME} + ${CDS_SHARED_LIBRARY} + ${GTEST_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} +) + +add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/test/unit/striped-set/intrusive_cuckoo_set.cpp b/test/unit/striped-set/intrusive_cuckoo_set.cpp new file mode 100644 index 00000000..81097194 --- /dev/null +++ b/test/unit/striped-set/intrusive_cuckoo_set.cpp @@ -0,0 +1,1278 @@ +/* + 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_intrusive_set.h" + +#include + +namespace { + namespace ci = cds::intrusive; + + class IntrusiveCuckooSet : public cds_test::intrusive_set + { + protected: + typedef cds_test::intrusive_set base_class; + + typedef base_class::hash_int hash1; + + struct hash2: private hash1 + { + typedef hash1 base_class; + + size_t operator()( int i ) const + { + size_t h = ~(base_class::operator()( i )); + return ~h + 0x9e3779b9 + (h << 6) + (h >> 2); + } + template + size_t operator()( const Item& i ) const + { + size_t h = ~(base_class::operator()( i )); + return ~h + 0x9e3779b9 + (h << 6) + (h >> 2); + } + }; + + struct disposer2 + { + template + void operator ()( T * p ) + { + ++p->nEraseCount; + } + }; + + template + void test( Set& s ) + { + // Precondition: set is empty + // Postcondition: set is empty + + base_class::test_< Set::c_isSorted>( s ); + + ASSERT_TRUE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, 0 ); + + typedef typename Set::value_type value_type; + + std::vector< value_type > data; + std::vector< size_t> indices; + data.reserve( kSize ); + indices.reserve( kSize ); + size_t const nSetSize = kSize; + for ( size_t key = 0; key < kSize; ++key ) { + data.push_back( value_type( static_cast(key) ) ); + indices.push_back( key ); + } + shuffle( indices.begin(), indices.end() ); + + // clear_and_dispose + for ( auto& i : data ) { + i.clear_stat(); + ASSERT_TRUE( s.insert( i ) ); + } + ASSERT_FALSE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, nSetSize ); + + s.clear_and_dispose( disposer2()); + + ASSERT_TRUE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, 0 ); + for ( auto& i : data ) { + EXPECT_EQ( i.nDisposeCount, 0 ); + EXPECT_EQ( i.nEraseCount, 1 ); + } + + } + + //void SetUp() + //{} + + //void TearDown() + //{} + }; + + +//************************************************************ +// striped base hook + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_unordered ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_unordered ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::base_hook< ci::cuckoo::probeset_type< item_type::probeset_type >> hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_cmp ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s( 32, 6, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_cmp ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + , ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_less ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + , ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 4, ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_less ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_cmpmix ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_cmpmix ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_stat ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_stat ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_unordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_unordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > > + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > > + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + +//************************************************************ +// striped member hook + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_unordered ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember )> hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_unordered ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), ci::cuckoo::probeset_type< item_type::member_type::probeset_type >> hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_cmp ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s( 32, 6, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_cmp ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + , ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_less ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + , ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 4, ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_less ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_cmpmix ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_cmpmix ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_stat ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_stat ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_unordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_unordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > > + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > > + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + +//************************************************************ +// refinable base hook + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_unordered ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_unordered ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::refinable<> mutex_policy; + typedef ci::cuckoo::base_hook< ci::cuckoo::probeset_type< item_type::probeset_type >> hook; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_cmp ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s( 32, 6, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_cmp ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + , ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_less ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 4, ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_less ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_cmpmix ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_cmpmix ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_stat ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_stat ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_unordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_unordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > > + ,ci::opt::mutex_policy> + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_storehash ) + { + typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::base_hook< + ci::cuckoo::probeset_type< item_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::hash_array_size > + > > + ,ci::opt::mutex_policy> + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + +//************************************************************ +// refinable member hook + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_unordered ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember )> hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_unordered ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), ci::cuckoo::probeset_type< item_type::member_type::probeset_type >> hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_cmp ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s( 32, 6, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_cmp ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_less ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 4, ht ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_less ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_cmpmix ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_cmpmix ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_stat ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_stat ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + > > + ,ci::opt::mutex_policy> + ,ci::opt::hash< std::tuple< hash1, hash2 > > + ,ci::opt::less< less > + ,ci::opt::compare< cmp > + ,ci::opt::stat< ci::cuckoo::stat > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_unordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s; + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_unordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type; + struct set_traits: public ci::cuckoo::traits + { + typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > hook; + typedef ci::cuckoo::refinable<> mutex_policy; + typedef cds::opt::hash_tuple< hash1, hash2 > hash; + typedef base_class::equal_to equal_to; + typedef mock_disposer disposer; + typedef ci::cuckoo::stat stat; + }; + typedef ci::CuckooSet< item_type, set_traits > set_type; + + set_type s( 32, 4 ); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > > + ,ci::opt::mutex_policy> + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( 32, 6, 0, std::move( ht )); + test( s ); + } + + TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_storehash ) + { + typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type; + + typedef ci::CuckooSet< item_type + ,ci::cuckoo::make_traits< + ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ), + ci::cuckoo::probeset_type< item_type::member_type::probeset_type > + ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size > + > > + ,ci::opt::mutex_policy> + ,cds::opt::hash< std::tuple< hash1, hash2 > > + ,cds::opt::less< less > + ,cds::opt::compare< cmp > + ,ci::opt::disposer< mock_disposer > + >::type + > set_type; + + typename set_type::hash_tuple_type ht; + set_type s( std::move( ht )); + test( s ); + } + +} // namespace diff --git a/test/unit/striped-set/test_intrusive_set.h b/test/unit/striped-set/test_intrusive_set.h new file mode 100644 index 00000000..b8c673ff --- /dev/null +++ b/test/unit/striped-set/test_intrusive_set.h @@ -0,0 +1,461 @@ +/* + 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_INTRUSIVE_SET_H +#define CDSUNIT_SET_TEST_INTRUSIVE_SET_H + +#include +#include + +#include + +// forward declaration +namespace cds { namespace intrusive {}} + +namespace cds_test { + + namespace ci = cds::intrusive; + namespace co = cds::opt; + + class intrusive_set: public fixture + { + public: + static size_t const kSize = 1000; + + struct stat + { + unsigned int nDisposeCount ; // count of disposer calling + unsigned int nFindCount ; // count of find-functor calling + unsigned int nUpdateNewCount; + unsigned int nUpdateCount; + mutable unsigned int nEraseCount; + + stat() + { + clear_stat(); + } + + void clear_stat() + { + memset( this, 0, sizeof( *this ) ); + } + }; + + template + struct base_int_item + : public Node + , public stat + + { + int nKey; + int nVal; + + base_int_item() + {} + + explicit base_int_item( int key ) + : nKey( key ) + , nVal( key ) + {} + + base_int_item(int key, int val) + : nKey( key ) + , nVal(val) + {} + + base_int_item( base_int_item const& v ) + : Node() + , stat() + , nKey( v.nKey ) + , nVal( v.nVal ) + {} + + int key() const + { + return nKey; + } + }; + + template + struct member_int_item: public stat + { + typedef Node member_type; + + int nKey; + int nVal; + + Node hMember; + + stat s; + + member_int_item() + {} + + explicit member_int_item( int key ) + : nKey( key ) + , nVal( key ) + {} + + member_int_item(int key, int val) + : nKey( key ) + , nVal(val) + {} + + member_int_item(member_int_item const& v ) + : stat() + , nKey( v.nKey ) + , nVal( v.nVal ) + {} + + int key() const + { + return nKey; + } + }; + + struct hash_int { + size_t operator()( int i ) const + { + return co::v::hash()( i ); + } + template + size_t operator()( const Item& i ) const + { + return (*this)( i.key() ); + } + }; + + 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; + } + }; + + + template + struct less + { + bool operator ()(const T& v1, const T& v2 ) const + { + return v1.key() < v2.key(); + } + + template + bool operator ()(const T& v1, const Q& v2 ) const + { + return v1.key() < v2; + } + + template + bool operator ()(const Q& v1, const T& v2 ) const + { + return v1 < v2.key(); + } + }; + + template + struct cmp { + int operator ()(const T& v1, const T& v2 ) const + { + if ( v1.key() < v2.key() ) + return -1; + return v1.key() > v2.key() ? 1 : 0; + } + + template + int operator ()(const T& v1, const Q& v2 ) const + { + if ( v1.key() < v2 ) + return -1; + return v1.key() > v2 ? 1 : 0; + } + + template + int operator ()(const Q& v1, const T& v2 ) const + { + if ( v1 < v2.key() ) + return -1; + return v1 > v2.key() ? 1 : 0; + } + }; + + template + struct equal_to { + int operator ()( const T& v1, const T& v2 ) const + { + return v1.key() == v2.key(); + } + + template + int operator ()( const T& v1, const Q& v2 ) const + { + return v1.key() == v2; + } + + template + int operator ()( const Q& v1, const T& v2 ) const + { + return v1 == v2.key(); + } + }; + + struct other_item { + int nKey; + + explicit other_item( int k ) + : nKey( k ) + {} + + int key() const + { + return nKey; + } + }; + + struct other_less { + template + bool operator()( Q const& lhs, T const& rhs ) const + { + return lhs.key() < rhs.key(); + } + }; + + struct other_equal_to { + template + bool operator()( Q const& lhs, T const& rhs ) const + { + return lhs.key() == rhs.key(); + } + }; + + struct mock_disposer + { + template + void operator ()( T * p ) + { + ++p->nDisposeCount; + } + }; + + protected: + template + void test( Set& s ) + { + test_< true >( s ); + } + + template + void test_( Set& s ) + { + // Precondition: set is empty + // Postcondition: set is empty + + ASSERT_TRUE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, 0 ); + + typedef typename Set::value_type value_type; + typedef typename std::conditional< Sorted, other_less, other_equal_to >::type other_predicate; + 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( 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.contains( i )); + ASSERT_FALSE( s.contains( other_item( i.key()), other_predicate())); + ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} )); + ASSERT_FALSE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} )); + + std::pair updResult; + + updResult = s.update( i, []( bool bNew, value_type&, value_type& ) + { + ASSERT_TRUE( false ); + }, false ); + EXPECT_FALSE( updResult.first ); + EXPECT_FALSE( updResult.second ); + + switch ( i.key() % 3 ) { + case 0: + ASSERT_TRUE( s.insert( i )); + ASSERT_FALSE( s.insert( i )); + updResult = s.update( i, []( bool bNew, value_type& val, value_type& arg) + { + EXPECT_FALSE( bNew ); + EXPECT_EQ( &val, &arg ); + }, false ); + EXPECT_TRUE( updResult.first ); + EXPECT_FALSE( updResult.second ); + break; + case 1: + EXPECT_EQ( i.nUpdateNewCount, 0 ); + ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} )); + EXPECT_EQ( i.nUpdateNewCount, 1 ); + ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) ); + EXPECT_EQ( i.nUpdateNewCount, 1 ); + i.nUpdateNewCount = 0; + break; + case 2: + updResult = s.update( i, []( bool bNew, value_type& val, value_type& arg ) + { + EXPECT_TRUE( bNew ); + EXPECT_EQ( &val, &arg ); + }); + EXPECT_TRUE( updResult.first ); + EXPECT_TRUE( updResult.second ); + break; + } + + ASSERT_TRUE( s.contains( i.nKey ) ); + ASSERT_TRUE( s.contains( i ) ); + ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate())); + EXPECT_EQ( i.nFindCount, 0 ); + ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } )); + EXPECT_EQ( i.nFindCount, 1 ); + ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } )); + EXPECT_EQ( i.nFindCount, 2 ); + } + ASSERT_FALSE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, nSetSize ); + + std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); }); + + // erase + shuffle( indices.begin(), indices.end() ); + for ( auto idx : indices ) { + auto& i = data[ idx ]; + + ASSERT_TRUE( s.contains( i.nKey ) ); + ASSERT_TRUE( s.contains( i ) ); + ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate() ) ); + EXPECT_EQ( i.nFindCount, 0 ); + ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) ); + EXPECT_EQ( i.nFindCount, 1 ); + ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) ); + EXPECT_EQ( i.nFindCount, 2 ); + + value_type v( i ); + switch ( i.key() % 6 ) { + case 0: + ASSERT_FALSE( s.unlink( v )); + ASSERT_TRUE( s.unlink( i )); + ASSERT_FALSE( s.unlink( i ) ); + break; + case 1: + ASSERT_TRUE( s.erase( i.key())); + ASSERT_FALSE( s.erase( i.key() ) ); + break; + case 2: + ASSERT_TRUE( s.erase( v )); + ASSERT_FALSE( s.erase( v ) ); + break; + case 3: + ASSERT_TRUE( s.erase_with( other_item( i.key()), other_predicate())); + ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_predicate() ) ); + break; + case 4: + EXPECT_EQ( i.nEraseCount, 0 ); + ASSERT_TRUE( s.erase( v, []( value_type& val ) { ++val.nEraseCount; } )); + EXPECT_EQ( i.nEraseCount, 1 ); + ASSERT_FALSE( s.erase( v, []( value_type& val ) { ++val.nEraseCount; } )); + EXPECT_EQ( i.nEraseCount, 1 ); + break; + case 5: + EXPECT_EQ( i.nEraseCount, 0 ); + ASSERT_TRUE( s.erase_with( other_item( i.key() ), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } )); + EXPECT_EQ( i.nEraseCount, 1 ); + ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } )); + EXPECT_EQ( i.nEraseCount, 1 ); + break; + } + + ASSERT_FALSE( s.contains( i.nKey )); + ASSERT_FALSE( s.contains( i )); + ASSERT_FALSE( s.contains( other_item( i.key()), other_predicate())); + ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} )); + ASSERT_FALSE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} )); + } + ASSERT_TRUE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, 0 ); + + // clear + for ( auto& i : data ) { + i.clear_stat(); + ASSERT_TRUE( s.insert( i )); + } + ASSERT_FALSE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, nSetSize ); + + s.clear(); + + ASSERT_TRUE( s.empty() ); + ASSERT_CONTAINER_SIZE( s, 0 ); + for ( auto& i : data ) { + EXPECT_EQ( i.nDisposeCount, 1 ); + } + } + }; + +} // namespace cds_test + +#endif // #ifndef CDSUNIT_SET_TEST_INTRUSIVE_SET_H -- 2.34.1