From: khizmax Date: Mon, 30 Mar 2015 15:38:06 +0000 (+0300) Subject: Renamed test-hdr/ordered_list dir to test-hdr/list, added unordered LazyList tests --- diff --git a/cds/container/details/make_lazy_kvlist.h b/cds/container/details/make_lazy_kvlist.h index 29555e87..8169f32b 100644 --- a/cds/container/details/make_lazy_kvlist.h +++ b/cds/container/details/make_lazy_kvlist.h @@ -89,8 +89,15 @@ namespace cds { namespace container { typename equal_to_wrapper< typename original_type_traits::equal_to >::type >::type equal_to; - typedef typename std::conditional< original_type_traits::sort, - cds::details::compare_wrapper< node_type, key_comparator, key_field_accessor >, + typedef typename std::conditional< + original_type_traits::sort + || !std::is_same< typename original_type_traits::compare, cds::opt::none >::value + || !std::is_same< typename original_type_traits::less, cds::opt::none >::value, + cds::details::compare_wrapper< + node_type, + typename opt::details::make_comparator< value_type, original_type_traits >::type, + key_field_accessor + >, cds::opt::none >::type compare; diff --git a/cds/container/details/make_lazy_list.h b/cds/container/details/make_lazy_list.h index 498b689e..57d8b816 100644 --- a/cds/container/details/make_lazy_list.h +++ b/cds/container/details/make_lazy_list.h @@ -78,8 +78,15 @@ namespace cds { namespace container { typename equal_to_wrapper< typename original_type_traits::equal_to >::type >::type equal_to; - typedef typename std::conditional< original_type_traits::sort, - typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor >, + typedef typename std::conditional< + original_type_traits::sort + || !std::is_same::value + || !std::is_same::value, + cds::details::compare_wrapper< + node_type, + typename opt::details::make_comparator< value_type, original_type_traits >::type, + value_accessor + >, cds::opt::none >::type compare; }; diff --git a/projects/Win/vc12/cds.sln b/projects/Win/vc12/cds.sln index f378a1b4..0c883200 100644 --- a/projects/Win/vc12/cds.sln +++ b/projects/Win/vc12/cds.sln @@ -62,7 +62,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-misc", "hdr-test-m {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-ordered-list", "hdr-test-ordered-list.vcxproj", "{EFCBBADE-2CF4-4E2B-ADB2-98C8D139E805}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-list", "hdr-test-list.vcxproj", "{EFCBBADE-2CF4-4E2B-ADB2-98C8D139E805}" ProjectSection(ProjectDependencies) = postProject {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} diff --git a/projects/Win/vc12/hdr-test-list.vcxproj b/projects/Win/vc12/hdr-test-list.vcxproj new file mode 100644 index 00000000..20990826 --- /dev/null +++ b/projects/Win/vc12/hdr-test-list.vcxproj @@ -0,0 +1,602 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Debug + x64 + + + ICL-Debug + Win32 + + + ICL-Debug + x64 + + + ICL-Release + Win32 + + + ICL-Release + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {EFCBBADE-2CF4-4E2B-ADB2-98C8D139E805} + hdrtestordlist + Win32Proj + $(VCTargetsPath11) + hdr-test-list + + + + Application + MultiByte + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + Intel C++ Compiler XE 13.0 + + + Application + MultiByte + v120 + + + Application + MultiByte + Intel C++ Compiler XE 13.0 + + + Application + MultiByte + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + Intel C++ Compiler XE 13.0 + + + Application + MultiByte + v120 + + + Application + MultiByte + Intel C++ Compiler XE 13.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ + false + false + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ + false + false + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ + false + false + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ + false + false + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + false + $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + $(ProjectName)_d + $(ProjectName)_d + $(ProjectName)_d + $(ProjectName)_d + $(ProjectName)_d + $(ProjectName)_d + + + + /bigobj /Zc:inline %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + Cdecl + 4520 + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX86 + + + + + /bigobj %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + Cdecl + true + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX86 + + + + + X64 + + + /bigobj /Zc:inline %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + Cdecl + 4520 + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX64 + + + + + X64 + + + /bigobj %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + Cdecl + true + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX64 + + + + + /bigobj /Zc:inline %(AdditionalOptions) + Full + AnySuitable + true + Speed + false + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + StreamingSIMDExtensions2 + + + Level3 + ProgramDatabase + Cdecl + false + 4520 + + + unit-prerequisites.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + true + true + false + + + MachineX86 + true + + + + + /bigobj %(AdditionalOptions) + Full + AnySuitable + true + Speed + false + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + StreamingSIMDExtensions2 + + + Level3 + ProgramDatabase + Cdecl + false + true + + + unit-prerequisites.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + true + true + false + + + MachineX86 + true + + + + + X64 + + + /bigobj /Zc:inline %(AdditionalOptions) + Full + AnySuitable + true + Speed + false + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + + + Level3 + ProgramDatabase + Cdecl + false + 4520 + + + unit-prerequisites.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + true + true + UseLinkTimeCodeGeneration + false + + + MachineX64 + true + + + + + X64 + + + /bigobj %(AdditionalOptions) + Full + AnySuitable + true + Speed + false + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + + + Level3 + ProgramDatabase + Cdecl + false + true + HOST + + + unit-prerequisites.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + true + true + UseLinkTimeCodeGeneration + false + + + MachineX64 + true + + + + + /bigobj /Zc:inline %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + Cdecl + 4520 + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX86 + + + + + X64 + + + /bigobj /Zc:inline %(AdditionalOptions) + Disabled + $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) + CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + Cdecl + 4520 + + + unit-prerequisites_d.lib;%(AdditionalDependencies) + $(TargetPath) + $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) + true + Console + false + + + MachineX64 + + + + + + \ No newline at end of file diff --git a/projects/Win/vc12/hdr-test-list.vcxproj.filters b/projects/Win/vc12/hdr-test-list.vcxproj.filters new file mode 100644 index 00000000..24f6289b --- /dev/null +++ b/projects/Win/vc12/hdr-test-list.vcxproj.filters @@ -0,0 +1,186 @@ + + + + + {fff45fc3-9c35-4f00-94ac-a2403b1caed6} + + + {b0d8933f-3fbc-49c2-ad77-89bd74461395} + + + + + intrusive + + + intrusive + + + container + + + container + + + container + + + container + + + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + intrusive + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + container + + + intrusive + + + container + + + container + + + \ No newline at end of file diff --git a/projects/Win/vc12/hdr-test-ordered-list.vcxproj b/projects/Win/vc12/hdr-test-ordered-list.vcxproj deleted file mode 100644 index ec291a9d..00000000 --- a/projects/Win/vc12/hdr-test-ordered-list.vcxproj +++ /dev/null @@ -1,598 +0,0 @@ - - - - - DebugVLD - Win32 - - - DebugVLD - x64 - - - Debug - Win32 - - - Debug - x64 - - - ICL-Debug - Win32 - - - ICL-Debug - x64 - - - ICL-Release - Win32 - - - ICL-Release - x64 - - - Release - Win32 - - - Release - x64 - - - - {EFCBBADE-2CF4-4E2B-ADB2-98C8D139E805} - hdrtestordlist - Win32Proj - $(VCTargetsPath11) - - - - Application - MultiByte - v120 - - - Application - MultiByte - true - v120 - - - Application - MultiByte - true - Intel C++ Compiler XE 13.0 - - - Application - MultiByte - v120 - - - Application - MultiByte - Intel C++ Compiler XE 13.0 - - - Application - MultiByte - v120 - - - Application - MultiByte - true - v120 - - - Application - MultiByte - true - Intel C++ Compiler XE 13.0 - - - Application - MultiByte - v120 - - - Application - MultiByte - Intel C++ Compiler XE 13.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ - false - false - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ - false - false - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ - false - false - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\bin\vc12-icl\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\..\..\obj\vc12-icl\$(Platform)\$(ProjectName)\$(Configuration)\ - false - false - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc12\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc12\$(Platform)\$(ProjectName)\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - /bigobj %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - Cdecl - true - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - X64 - - - /bigobj %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - Cdecl - true - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - /bigobj /Zc:inline %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - Cdecl - false - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - false - - - MachineX86 - true - - - - - /bigobj %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - Cdecl - false - true - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - false - - - MachineX86 - true - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - - - Level3 - ProgramDatabase - Cdecl - false - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX64 - true - - - - - X64 - - - /bigobj %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - - - Level3 - ProgramDatabase - Cdecl - false - true - HOST - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX64 - true - - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/projects/Win/vc12/hdr-test-ordered-list.vcxproj.filters b/projects/Win/vc12/hdr-test-ordered-list.vcxproj.filters deleted file mode 100644 index f4e393ae..00000000 --- a/projects/Win/vc12/hdr-test-ordered-list.vcxproj.filters +++ /dev/null @@ -1,177 +0,0 @@ - - - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - intrusive - - - intrusive - - - intrusive - - - intrusive - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - container - - - intrusive - - - container - - - container - - - intrusive - - - container - - - container - - - - - intrusive - - - intrusive - - - container - - - container - - - container - - - container - - - - - {fff45fc3-9c35-4f00-94ac-a2403b1caed6} - - - {b0d8933f-3fbc-49c2-ad77-89bd74461395} - - - \ No newline at end of file diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index 7f6a46b7..4be0271f 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -60,42 +60,42 @@ CDS_TESTHDR_MAP := \ CDS_TESTHDR_DEQUE := \ tests/test-hdr/deque/hdr_fcdeque.cpp -CDS_TESTHDR_ORDLIST := \ - tests/test-hdr/ordered_list/hdr_lazy_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_hp.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_rcu_sht.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_hp.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_sht.cpp \ - tests/test-hdr/ordered_list/hdr_michael_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_michael_hp.cpp \ - tests/test-hdr/ordered_list/hdr_michael_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_michael_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_michael_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_michael_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_michael_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_michael_rcu_sht.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_hp.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_michael_kv_rcu_sht.cpp +CDS_TESTHDR_LIST := \ + tests/test-hdr/list/hdr_lazy_dhp.cpp \ + tests/test-hdr/list/hdr_lazy_hp.cpp \ + tests/test-hdr/list/hdr_lazy_nogc.cpp \ + tests/test-hdr/list/hdr_lazy_nogc_unord.cpp \ + tests/test-hdr/list/hdr_lazy_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_lazy_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_lazy_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_lazy_rcu_shb.cpp \ + tests/test-hdr/list/hdr_lazy_rcu_sht.cpp \ + tests/test-hdr/list/hdr_lazy_kv_dhp.cpp \ + tests/test-hdr/list/hdr_lazy_kv_hp.cpp \ + tests/test-hdr/list/hdr_lazy_kv_nogc.cpp \ + tests/test-hdr/list/hdr_lazy_kv_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_lazy_kv_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_lazy_kv_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_lazy_kv_rcu_shb.cpp \ + tests/test-hdr/list/hdr_lazy_kv_rcu_sht.cpp \ + tests/test-hdr/list/hdr_michael_dhp.cpp \ + tests/test-hdr/list/hdr_michael_hp.cpp \ + tests/test-hdr/list/hdr_michael_nogc.cpp \ + tests/test-hdr/list/hdr_michael_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_michael_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_michael_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_michael_rcu_shb.cpp \ + tests/test-hdr/list/hdr_michael_rcu_sht.cpp \ + tests/test-hdr/list/hdr_michael_kv_dhp.cpp \ + tests/test-hdr/list/hdr_michael_kv_hp.cpp \ + tests/test-hdr/list/hdr_michael_kv_nogc.cpp \ + tests/test-hdr/list/hdr_michael_kv_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_michael_kv_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_michael_kv_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp \ + tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp CDS_TESTHDR_UNORDLIST := \ - tests/test-hdr/unordered_list/hdr_lazy_nogc.cpp \ tests/test-hdr/unordered_list/hdr_lazy_kv_nogc.cpp CDS_TESTHDR_PQUEUE := \ @@ -279,8 +279,7 @@ CDS_TESTHDR_SOURCES := \ $(CDS_TESTHDR_STACK) \ $(CDS_TESTHDR_MAP) \ $(CDS_TESTHDR_DEQUE) \ - $(CDS_TESTHDR_ORDLIST) \ - $(CDS_TESTHDR_UNORDLIST) \ + $(CDS_TESTHDR_LIST) \ $(CDS_TESTHDR_SET) \ $(CDS_TESTHDR_TREE) \ $(CDS_TESTHDR_MISC) diff --git a/projects/source.test-hdr.offsetof.mk b/projects/source.test-hdr.offsetof.mk index cca42544..2a6eb523 100644 --- a/projects/source.test-hdr.offsetof.mk +++ b/projects/source.test-hdr.offsetof.mk @@ -48,26 +48,24 @@ CDS_TESTHDR_OFFSETOF_SET := \ tests/test-hdr/set/hdr_intrusive_splitlist_set_rcu_shb_lazy.cpp \ tests/test-hdr/set/hdr_intrusive_splitlist_set_rcu_sht_lazy.cpp -CDS_TESTHDR_OFFSETOF_ORDLIST := \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_hp.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_sht.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_dhp.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_hp.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_nogc.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpb.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpi.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpt.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_shb.cpp \ - tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_sht.cpp - -CDS_TESTHDR_OFFSETOF_UNORDLIST := \ - tests/test-hdr/unordered_list/hdr_intrusive_lazy_nogc.cpp +CDS_TESTHDR_OFFSETOF_LIST := \ + tests/test-hdr/list/hdr_intrusive_lazy_dhp.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_hp.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_nogc.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_nogc_unord.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_rcu_shb.cpp \ + tests/test-hdr/list/hdr_intrusive_lazy_rcu_sht.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_dhp.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_hp.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_nogc.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpb.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpi.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpt.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_list_rcu_shb.cpp \ + tests/test-hdr/list/hdr_intrusive_michael_list_rcu_sht.cpp CDS_TESTHDR_OFFSETOF_QUEUE := \ tests/test-hdr/queue/hdr_intrusive_basketqueue_hp.cpp \ @@ -100,6 +98,5 @@ CDS_TESTHDR_OFFSETOF_SOURCES := \ $(CDS_TESTHDR_OFFSETOF_DEQUE) \ $(CDS_TESTHDR_OFFSETOF_MAP) \ $(CDS_TESTHDR_OFFSETOF_SET) \ - $(CDS_TESTHDR_OFFSETOF_ORDLIST) \ - $(CDS_TESTHDR_OFFSETOF_UNORDLIST) \ + $(CDS_TESTHDR_OFFSETOF_LIST) \ $(CDS_TESTHDR_OFFSETOF_TREE) diff --git a/tests/test-hdr/list/hdr_intrusive_lazy.h b/tests/test-hdr/list/hdr_intrusive_lazy.h new file mode 100644 index 00000000..83615fff --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy.h @@ -0,0 +1,1068 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H +#define CDSTEST_HDR_INTRUSIVE_LAZY_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace ci = cds::intrusive; + namespace co = cds::opt; + + class IntrusiveLazyListHeaderTest: public CppUnitMini::TestCase + { + public: + + struct stat { + int nDisposeCount; + int nEnsureExistsCall; + int nEnsureNewCall; + int nFindCall; + int nEraseCall; + + stat() + : nDisposeCount(0) + , nEnsureExistsCall(0) + , nEnsureNewCall(0) + , nFindCall(0) + , nEraseCall(0) + {} + + stat( const stat& s ) + { + *this = s; + } + + stat& operator =(const stat& s) + { + memcpy( this, &s, sizeof(s)); + return *this; + } + }; + + template + struct base_int_item: public ci::lazy_list::node< GC > + { + int nKey; + int nVal; + + mutable stat s; + + base_int_item() + {} + + base_int_item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + base_int_item(const base_int_item& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + const int& key() const + { + return nKey; + } + }; + + template + struct member_int_item + { + int nKey; + int nVal; + + ci::lazy_list::node< GC > hMember; + + mutable stat s; + + member_int_item() + {} + + member_int_item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + member_int_item(const member_int_item& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + const int& key() const + { + return nKey; + } + }; + + 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 { + 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(); + } + }; + + struct other_item { + int nKey; + + other_item( int n ) + : nKey(n) + {} + }; + + struct other_less { + template + bool operator()( T const& i1, Q const& i2) const + { + return i1.nKey < i2.nKey; + } + }; + + struct other_equal { + template + bool operator()( T const& i1, Q const& i2) const + { + return i1.nKey == i2.nKey; + } + }; + + struct faked_disposer + { + template + void operator ()( T * p ) + { + ++p->s.nDisposeCount; + } + }; + + struct ensure_functor + { + template + void operator ()(bool bNew, T& item, T& /*val*/ ) + { + if ( bNew ) + ++item.s.nEnsureNewCall; + else + ++item.s.nEnsureExistsCall; + } + }; + + struct find_functor + { + template + void operator ()( T& item, Q& /*val*/ ) + { + ++item.s.nFindCall; + } + }; + + struct erase_functor + { + template + void operator()( T const& item ) + { + item.s.nEraseCall++; + } + }; + + template + void test_int_common() + { + typedef typename OrdList::value_type value_type; + + value_type v1( 10, 50 ); + value_type v2( 5, 25 ); + value_type v3( 20, 100 ); + { + OrdList l; + CPPUNIT_ASSERT( l.empty() ); + + CPPUNIT_ASSERT( l.insert( v1 )) ; // true + CPPUNIT_ASSERT( l.find( v1.key() )); + + CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find_with( v2.key(), less() )); + CPPUNIT_ASSERT( !l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( !l.empty() ); + + //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised + + { + value_type v( v1 ); + CPPUNIT_ASSERT( !l.insert( v )) ; // false + } + + std::pair ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + + //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" + + CPPUNIT_ASSERT( l.find( v1.key() )) ; // true + + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); + + CPPUNIT_ASSERT( l.find( v2.key() )); + + CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find_with( v2.key(), less(), find_functor() )); + CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v3.key() )); + + { + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + + value_type v( v2 ); + ret = l.ensure( v, ensure_functor() ); + + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( !ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 ); + CPPUNIT_ASSERT( v.s.nEnsureNewCall == 0 ); + } + + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.insert( v3 )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() )); + + CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( l.unlink( v2 ) ); + CPPUNIT_ASSERT( l.find( v1.key() )) ; // true + CPPUNIT_ASSERT( !l.find( v2.key() )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() )) ; // true + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + + { + // v1 key is in the list but v NODE is not in the list + value_type v( v1 ); + CPPUNIT_ASSERT( !l.unlink( v ) ); + } + + CPPUNIT_ASSERT( l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.find( v1.key() )); + CPPUNIT_ASSERT( !l.find( v2.key() )); + CPPUNIT_ASSERT( l.find( v3.key() )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + + CPPUNIT_ASSERT( l.unlink( v3 ) ); + CPPUNIT_ASSERT( !l.find( v1.key() )); + CPPUNIT_ASSERT( !l.find_with( v2.key(), less() )); + CPPUNIT_ASSERT( !l.find( v3.key() )); + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + CPPUNIT_ASSERT( !l.unlink( v3 ) ); + + // Apply retired pointer to clean links + OrdList::gc::force_dispose(); + + stat s( v3.s ); + ret = l.ensure( v3, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v3.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v3.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + s = v2.s; + ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + s = v1.s; + ret = l.ensure( v1, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v1.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v1.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + // Erase test + CPPUNIT_ASSERT( l.erase( v1.key()) ); + //CPPUNIT_ASSERT( v1.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase_with( v2.key(), less(), erase_functor()) ); + CPPUNIT_ASSERT( v2.s.nEraseCall == 1 ); + CPPUNIT_ASSERT( !l.erase_with( v2.key(), less())); + CPPUNIT_ASSERT( v2.s.nEraseCall == 1 ); + //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.erase( v2 )); + CPPUNIT_ASSERT( !l.erase( v1 )); + //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( v3.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase( v3, erase_functor() )); + CPPUNIT_ASSERT( v3.s.nEraseCall == 1 ); + //CPPUNIT_ASSERT( v3.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( l.empty() ); + + // Apply retired pointer to clean links + OrdList::gc::force_dispose(); + + // Unlink test + CPPUNIT_ASSERT( l.insert( v1 )); + CPPUNIT_ASSERT( l.insert( v3 )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v2 )); + CPPUNIT_ASSERT( l.unlink( v1 )); + CPPUNIT_ASSERT( !l.unlink( v1 )); + CPPUNIT_ASSERT( l.unlink( v3 )); + CPPUNIT_ASSERT( !l.unlink( v3 )); + CPPUNIT_ASSERT( l.empty() ); + + // Apply retired pointer + OrdList::gc::force_dispose(); + CPPUNIT_ASSERT( v1.s.nDisposeCount == 3 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 2 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 3 ); + + // Destructor test (call disposer) + CPPUNIT_ASSERT( l.insert( v1 )); + CPPUNIT_ASSERT( l.insert( v3 )); + CPPUNIT_ASSERT( l.insert( v2 )); + + // Iterator test + { + typename OrdList::iterator it = l.begin(); + typename OrdList::const_iterator cit = l.cbegin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( cit != l.end() ); + CPPUNIT_ASSERT( cit != l.cend() ); + CPPUNIT_ASSERT( cit == it ); + + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( ++it == l.end() ); + } + + { + OrdList const & lref = l; + typename OrdList::const_iterator it = lref.begin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != lref.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( ++it == l.end() ); + } + } + + // Apply retired pointer + OrdList::gc::force_dispose(); + + CPPUNIT_ASSERT( v1.s.nDisposeCount == 4 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 3 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 4 ); + } + + template + void test_int() + { + test_int_common(); + + OrdList l; + typename OrdList::guarded_ptr gp; + + static int const nLimit = 20; + typename OrdList::value_type arrItem[nLimit]; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + for (int i = 0; i < nLimit; ++i) { + arrItem[i].nKey = a[i]; + arrItem[i].nVal = a[i] * 2; + } + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + for ( int i=0; i < nLimit; ++i ) { + gp = l.get( arrItem[i].nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); + CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); + + gp = l.extract( arrItem[i].nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); + CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); + + gp = l.get( arrItem[i].nKey ); + CPPUNIT_ASSERT( !gp ); + CPPUNIT_ASSERT( gp.empty()); + CPPUNIT_ASSERT( !l.extract( arrItem[i].nKey )); + CPPUNIT_ASSERT( gp.empty()); + } + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.get( nLimit/2 )); + CPPUNIT_ASSERT( !l.extract( nLimit/2 )); + + // Apply retired pointer + OrdList::gc::force_dispose(); + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + for ( int i=0; i < nLimit; ++i ) { + other_item itm( arrItem[i].nKey ); + gp = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); + CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); + + gp = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); + CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); + + gp = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( !gp ); + CPPUNIT_ASSERT( gp.empty()); + CPPUNIT_ASSERT( !l.extract_with( itm, other_less() )); + CPPUNIT_ASSERT( gp.empty()); + } + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() )); + CPPUNIT_ASSERT( gp.empty()); + CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() )); + CPPUNIT_ASSERT( gp.empty()); + + // Apply retired pointer + OrdList::gc::force_dispose(); + + for ( int i=0; i < nLimit; i++ ) { + CPPUNIT_ASSERT( arrItem[i].s.nDisposeCount == 2 ); + } + } + } + + template + void test_rcu_int() + { + test_int_common(); + + OrdList l; + static int const nLimit = 20; + typename OrdList::value_type arrItem[nLimit]; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + for (int i = 0; i < nLimit; ++i) { + arrItem[i].nKey = a[i]; + arrItem[i].nVal = a[i] * 2; + } + + typename OrdList::exempt_ptr ep; + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[i] ) ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + ep = l.extract( a[0] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + // Apply retired pointer + OrdList::gc::force_dispose(); + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + other_item itm( a[i] ); + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + // Apply retired pointer + OrdList::gc::force_dispose(); + } + } + + template + void test_nogc_int() + { + typedef typename OrdList::value_type value_type; + + { + value_type v1( 10, 50 ); + value_type v2( 5, 25 ); + value_type v3( 20, 100 ); + { + OrdList l; + CPPUNIT_ASSERT( l.empty() ); + + CPPUNIT_ASSERT( l.insert( v1 )) ; // true + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); + + CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( l.find_with( v2.key(), less() ) == nullptr ); + CPPUNIT_ASSERT( l.find( v3.key() ) == nullptr ); + CPPUNIT_ASSERT( !l.empty() ); + + //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised + + { + value_type v( v1 ); + CPPUNIT_ASSERT( !l.insert( v )) ; // false + } + + std::pair ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + + //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" + + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true + + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); + + CPPUNIT_ASSERT( l.find_with( v2.key(), less() ) == &v2 ); + + CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find_with( v2.key(), less(), find_functor() )); + CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v3.key() )); + + { + value_type v( v2 ); + ret = l.ensure( v, ensure_functor() ); + + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( !ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); + CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); + } + + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.insert( v3 )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); + + CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); + + { + typename OrdList::iterator it = l.begin(); + typename OrdList::const_iterator cit = l.cbegin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( cit != l.end() ); + CPPUNIT_ASSERT( cit != l.cend() ); + CPPUNIT_ASSERT( cit == it ); + + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + + { + OrdList const & lref = l; + typename OrdList::const_iterator it = lref.begin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != lref.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != lref.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + } + + // Disposer called on list destruction + CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); + } + } + + template + void test_nogc_int_unordered() + { + typedef typename UnordList::value_type value_type; + { + value_type v1( 10, 50 ); + value_type v2( 5, 25 ); + value_type v3( 20, 100 ); + { + UnordList l; + CPPUNIT_ASSERT( l.empty() ); + + CPPUNIT_ASSERT( l.insert( v1 )); // true + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); + + CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to() ) == nullptr ); + CPPUNIT_ASSERT( l.find( v3.key() ) == nullptr ); + CPPUNIT_ASSERT( !l.empty() ); + + //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised + + { + value_type v( v1 ); + CPPUNIT_ASSERT( !l.insert( v )) ; // false + } + + std::pair ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + + //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" + + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true + + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); + + CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to() ) == &v2 ); + + CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find_with( v2.key(), equal_to(), find_functor() )); + CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v3.key() )); + + { + value_type v( v2 ); + ret = l.ensure( v, ensure_functor() ); + + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( !ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); + CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); + } + + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.insert( v3 )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); + + CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); + + { + typename UnordList::iterator it = l.begin(); + typename UnordList::const_iterator cit = l.cbegin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( cit != l.end() ); + CPPUNIT_ASSERT( cit != l.cend() ); + CPPUNIT_ASSERT( cit == it ); + + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + + { + UnordList const & lref = l; + typename UnordList::const_iterator it = lref.begin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != lref.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != lref.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + } + + // Disposer called on list destruction + CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); + } + } + + + void HP_base_cmp(); + void HP_base_less(); + void HP_base_cmpmix(); + void HP_base_ic(); + void HP_member_cmp(); + void HP_member_less(); + void HP_member_cmpmix(); + void HP_member_ic(); + + void DHP_base_cmp(); + void DHP_base_less(); + void DHP_base_cmpmix(); + void DHP_base_ic(); + void DHP_member_cmp(); + void DHP_member_less(); + void DHP_member_cmpmix(); + void DHP_member_ic(); + + void RCU_GPI_base_cmp(); + void RCU_GPI_base_less(); + void RCU_GPI_base_cmpmix(); + void RCU_GPI_base_ic(); + void RCU_GPI_member_cmp(); + void RCU_GPI_member_less(); + void RCU_GPI_member_cmpmix(); + void RCU_GPI_member_ic(); + + void RCU_GPB_base_cmp(); + void RCU_GPB_base_less(); + void RCU_GPB_base_cmpmix(); + void RCU_GPB_base_ic(); + void RCU_GPB_member_cmp(); + void RCU_GPB_member_less(); + void RCU_GPB_member_cmpmix(); + void RCU_GPB_member_ic(); + + void RCU_GPT_base_cmp(); + void RCU_GPT_base_less(); + void RCU_GPT_base_cmpmix(); + void RCU_GPT_base_ic(); + void RCU_GPT_member_cmp(); + void RCU_GPT_member_less(); + void RCU_GPT_member_cmpmix(); + void RCU_GPT_member_ic(); + + void RCU_SHB_base_cmp(); + void RCU_SHB_base_less(); + void RCU_SHB_base_cmpmix(); + void RCU_SHB_base_ic(); + void RCU_SHB_member_cmp(); + void RCU_SHB_member_less(); + void RCU_SHB_member_cmpmix(); + void RCU_SHB_member_ic(); + + void RCU_SHT_base_cmp(); + void RCU_SHT_base_less(); + void RCU_SHT_base_cmpmix(); + void RCU_SHT_base_ic(); + void RCU_SHT_member_cmp(); + void RCU_SHT_member_less(); + void RCU_SHT_member_cmpmix(); + void RCU_SHT_member_ic(); + + void nogc_base_cmp(); + void nogc_base_less(); + void nogc_base_cmpmix(); + void nogc_base_ic(); + void nogc_member_cmp(); + void nogc_member_less(); + void nogc_member_cmpmix(); + void nogc_member_ic(); + + void nogc_base_cmp_unord(); + void nogc_base_less_unord(); + void nogc_base_equal_to_unord(); + void nogc_base_cmpmix_unord(); + void nogc_base_equal_to_mix_unord(); + void nogc_base_ic_unord(); + void nogc_member_cmp_unord(); + void nogc_member_less_unord(); + void nogc_member_equal_to_unord(); + void nogc_member_cmpmix_unord(); + void nogc_member_equal_to_mix_unord(); + void nogc_member_ic_unord(); + + CPPUNIT_TEST_SUITE(IntrusiveLazyListHeaderTest) + CPPUNIT_TEST(HP_base_cmp) + CPPUNIT_TEST(HP_base_less) + CPPUNIT_TEST(HP_base_cmpmix) + CPPUNIT_TEST(HP_base_ic) + CPPUNIT_TEST(HP_member_cmp) + CPPUNIT_TEST(HP_member_less) + CPPUNIT_TEST(HP_member_cmpmix) + CPPUNIT_TEST(HP_member_ic) + + CPPUNIT_TEST(DHP_base_cmp) + CPPUNIT_TEST(DHP_base_less) + CPPUNIT_TEST(DHP_base_cmpmix) + CPPUNIT_TEST(DHP_base_ic) + CPPUNIT_TEST(DHP_member_cmp) + CPPUNIT_TEST(DHP_member_less) + CPPUNIT_TEST(DHP_member_cmpmix) + CPPUNIT_TEST(DHP_member_ic) + + CPPUNIT_TEST(RCU_GPI_base_cmp) + CPPUNIT_TEST(RCU_GPI_base_less) + CPPUNIT_TEST(RCU_GPI_base_cmpmix) + CPPUNIT_TEST(RCU_GPI_base_ic) + CPPUNIT_TEST(RCU_GPI_member_cmp) + CPPUNIT_TEST(RCU_GPI_member_less) + CPPUNIT_TEST(RCU_GPI_member_cmpmix) + CPPUNIT_TEST(RCU_GPI_member_ic) + + CPPUNIT_TEST(RCU_GPB_base_cmp) + CPPUNIT_TEST(RCU_GPB_base_less) + CPPUNIT_TEST(RCU_GPB_base_cmpmix) + CPPUNIT_TEST(RCU_GPB_base_ic) + CPPUNIT_TEST(RCU_GPB_member_cmp) + CPPUNIT_TEST(RCU_GPB_member_less) + CPPUNIT_TEST(RCU_GPB_member_cmpmix) + CPPUNIT_TEST(RCU_GPB_member_ic) + + CPPUNIT_TEST(RCU_GPT_base_cmp) + CPPUNIT_TEST(RCU_GPT_base_less) + CPPUNIT_TEST(RCU_GPT_base_cmpmix) + CPPUNIT_TEST(RCU_GPT_base_ic) + CPPUNIT_TEST(RCU_GPT_member_cmp) + CPPUNIT_TEST(RCU_GPT_member_less) + CPPUNIT_TEST(RCU_GPT_member_cmpmix) + CPPUNIT_TEST(RCU_GPT_member_ic) + + CPPUNIT_TEST(RCU_SHB_base_cmp) + CPPUNIT_TEST(RCU_SHB_base_less) + CPPUNIT_TEST(RCU_SHB_base_cmpmix) + CPPUNIT_TEST(RCU_SHB_base_ic) + CPPUNIT_TEST(RCU_SHB_member_cmp) + CPPUNIT_TEST(RCU_SHB_member_less) + CPPUNIT_TEST(RCU_SHB_member_cmpmix) + CPPUNIT_TEST(RCU_SHB_member_ic) + + CPPUNIT_TEST(RCU_SHT_base_cmp) + CPPUNIT_TEST(RCU_SHT_base_less) + CPPUNIT_TEST(RCU_SHT_base_cmpmix) + CPPUNIT_TEST(RCU_SHT_base_ic) + CPPUNIT_TEST(RCU_SHT_member_cmp) + CPPUNIT_TEST(RCU_SHT_member_less) + CPPUNIT_TEST(RCU_SHT_member_cmpmix) + CPPUNIT_TEST(RCU_SHT_member_ic) + + CPPUNIT_TEST(nogc_base_cmp) + CPPUNIT_TEST(nogc_base_less) + CPPUNIT_TEST(nogc_base_cmpmix) + CPPUNIT_TEST(nogc_base_ic) + CPPUNIT_TEST(nogc_member_cmp) + CPPUNIT_TEST(nogc_member_less) + CPPUNIT_TEST(nogc_member_cmpmix) + CPPUNIT_TEST(nogc_member_ic) + + CPPUNIT_TEST(nogc_base_cmp_unord) + CPPUNIT_TEST(nogc_base_less_unord) + CPPUNIT_TEST(nogc_base_equal_to_unord) + CPPUNIT_TEST(nogc_base_cmpmix_unord) + CPPUNIT_TEST(nogc_base_equal_to_mix_unord) + CPPUNIT_TEST(nogc_base_ic_unord) + CPPUNIT_TEST(nogc_member_cmp_unord) + CPPUNIT_TEST(nogc_member_less_unord) + CPPUNIT_TEST(nogc_member_equal_to_unord) + CPPUNIT_TEST(nogc_member_cmpmix_unord) + CPPUNIT_TEST(nogc_member_equal_to_mix_unord) + CPPUNIT_TEST(nogc_member_ic_unord) + + CPPUNIT_TEST_SUITE_END() + }; +} // namespace ordlist + +#endif // #ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_dhp.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_dhp.cpp new file mode 100644 index 00000000..a9c423b4 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_dhp.cpp @@ -0,0 +1,128 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include + +namespace ordlist { + void IntrusiveLazyListHeaderTest::DHP_base_cmp() + { + typedef base_int_item< cds::gc::DHP > item; + struct traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::LazyList< cds::gc::DHP, item, traits > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_base_less() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_base_cmpmix() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_base_ic() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_member_cmp() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_member_less() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_member_cmpmix() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::DHP_member_ic() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::LazyList< cds::gc::DHP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_hp.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_hp.cpp new file mode 100644 index 00000000..57f23a7f --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_hp.cpp @@ -0,0 +1,125 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include + +namespace ordlist { + void IntrusiveLazyListHeaderTest::HP_base_cmp() + { + typedef base_int_item< cds::gc::HP > item; + struct traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::LazyList< cds::gc::HP, item, traits > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_base_less() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_base_cmpmix() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_base_ic() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_member_cmp() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_member_less() + { + typedef member_int_item< cds::gc::HP > item; + struct traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::member_hook< offsetof( item, hMember ), co::gc> hook; + typedef IntrusiveLazyListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::LazyList< cds::gc::HP, item, traits > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_member_cmpmix() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveLazyListHeaderTest::HP_member_ic() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::LazyList< cds::gc::HP + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::IntrusiveLazyListHeaderTest); diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_nogc.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_nogc.cpp new file mode 100644 index 00000000..caaf50bd --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_nogc.cpp @@ -0,0 +1,134 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include + +namespace ordlist { + void IntrusiveLazyListHeaderTest::nogc_base_cmp() + { + typedef base_int_item< cds::gc::nogc > item; + struct traits : public ci::lazy_list::traits { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::LazyList< cds::gc::nogc, item, traits > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_base_less() + { + typedef base_int_item< cds::gc::nogc > item; + struct traits: public + ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + {}; + typedef ci::LazyList< cds::gc::nogc, item, traits > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_base_cmpmix() + { + typedef base_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_base_ic() + { + typedef base_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_member_cmp() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_member_less() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_member_cmpmix() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + + void IntrusiveLazyListHeaderTest::nogc_member_ic() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::LazyList< cds::gc::nogc + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_nogc_int(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_nogc_unord.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_nogc_unord.cpp new file mode 100644 index 00000000..f06ba6f9 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_nogc_unord.cpp @@ -0,0 +1,166 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include + +namespace ordlist { + namespace { + typedef IntrusiveLazyListHeaderTest::base_int_item< cds::gc::nogc > base_item; + typedef IntrusiveLazyListHeaderTest::member_int_item< cds::gc::nogc > member_item; + + struct cmp_traits : public ci::lazy_list::traits { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef IntrusiveLazyListHeaderTest::cmp compare; + typedef IntrusiveLazyListHeaderTest::faked_disposer disposer; + static const bool sort = false; + }; + + struct less_traits: public ci::lazy_list::traits { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef IntrusiveLazyListHeaderTest::less less; + typedef IntrusiveLazyListHeaderTest::faked_disposer disposer; + static const bool sort = false; + }; + + struct equal_to_traits: public ci::lazy_list::traits { + typedef ci::lazy_list::base_hook< co::gc > hook; + typedef IntrusiveLazyListHeaderTest::equal_to equal_to; + typedef IntrusiveLazyListHeaderTest::faked_disposer disposer; + static const bool sort = false; + }; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< IntrusiveLazyListHeaderTest::less > + ,co::compare< IntrusiveLazyListHeaderTest::cmp > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type cmpmix_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< IntrusiveLazyListHeaderTest::cmp > + ,co::equal_to< IntrusiveLazyListHeaderTest::equal_to > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type equal_to_mix_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::equal_to< IntrusiveLazyListHeaderTest::equal_to > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + ,co::sort< false > >::type ic_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ) + ,co::gc > > + ,co::compare< IntrusiveLazyListHeaderTest::cmp > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type member_cmp_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ) + ,co::gc > > + ,co::less< IntrusiveLazyListHeaderTest::less > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type member_less_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ) + ,co::gc > > + ,co::equal_to< IntrusiveLazyListHeaderTest::equal_to > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type member_equal_to_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ) + ,co::gc > > + ,co::less< IntrusiveLazyListHeaderTest::less > + ,co::compare< IntrusiveLazyListHeaderTest::cmp > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type member_cmpmix_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ) + ,co::gc > > + ,co::compare< IntrusiveLazyListHeaderTest::cmp > + ,co::equal_to< IntrusiveLazyListHeaderTest::equal_to > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::sort< false > >::type member_equal_to_mix_traits; + + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item, hMember ), + co::gc > > + ,co::equal_to< IntrusiveLazyListHeaderTest::equal_to > + ,ci::opt::disposer< IntrusiveLazyListHeaderTest::faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + ,co::sort< false > >::type member_ic_traits; + + } + void IntrusiveLazyListHeaderTest::nogc_base_cmp_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, cmp_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_base_less_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, less_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_base_equal_to_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, equal_to_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_base_cmpmix_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, cmpmix_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_base_equal_to_mix_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, equal_to_mix_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_base_ic_unord() + { + typedef ci::LazyList< cds::gc::nogc, base_item, ic_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_cmp_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_cmp_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_less_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_less_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_equal_to_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_equal_to_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_cmpmix_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_cmpmix_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_equal_to_mix_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_equal_to_mix_traits > list; + test_nogc_int_unordered(); + } + void IntrusiveLazyListHeaderTest::nogc_member_ic_unord() + { + typedef ci::LazyList< cds::gc::nogc, member_item, member_ic_traits > list; + test_nogc_int_unordered(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpb.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpb.cpp new file mode 100644 index 00000000..63629425 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpb.cpp @@ -0,0 +1,132 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > RCU; + } + + void IntrusiveLazyListHeaderTest::RCU_GPB_base_cmp() + { + typedef base_int_item< RCU > item; + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type list_traits; + typedef ci::LazyList< RCU, item, list_traits > list; + + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_base_less() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_member_cmp() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_member_less() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_member_cmpmix() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPB_member_ic() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpi.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpi.cpp new file mode 100644 index 00000000..d5e1831f --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpi.cpp @@ -0,0 +1,133 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > RCU; + } + + void IntrusiveLazyListHeaderTest::RCU_GPI_base_cmp() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_base_less() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_member_cmp() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_member_less() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_member_cmpmix() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPI_member_ic() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpt.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpt.cpp new file mode 100644 index 00000000..d241329b --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_gpt.cpp @@ -0,0 +1,133 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > RCU; + } + + void IntrusiveLazyListHeaderTest::RCU_GPT_base_cmp() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_base_less() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_member_cmp() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_member_less() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_member_cmpmix() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveLazyListHeaderTest::RCU_GPT_member_ic() + { + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_rcu_shb.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_shb.cpp new file mode 100644 index 00000000..8e55e246 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_shb.cpp @@ -0,0 +1,158 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > RCU; + } +#endif + + void IntrusiveLazyListHeaderTest::RCU_SHB_base_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type list_traits; + typedef ci::LazyList< RCU, item, list_traits > list; + + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_base_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_base_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_base_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_member_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_member_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_member_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + + void IntrusiveLazyListHeaderTest::RCU_SHB_member_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_lazy_rcu_sht.cpp b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_sht.cpp new file mode 100644 index 00000000..84ccd651 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_lazy_rcu_sht.cpp @@ -0,0 +1,151 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_lazy.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > RCU; + } +#endif + + void IntrusiveLazyListHeaderTest::RCU_SHT_base_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_base_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_base_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_base_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_member_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_member_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_member_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveLazyListHeaderTest::RCU_SHT_member_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::LazyList< RCU + ,item + ,ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_michael.h b/tests/test-hdr/list/hdr_intrusive_michael.h new file mode 100644 index 00000000..05248f66 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael.h @@ -0,0 +1,911 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_INTRUSIVE_MICHAEL_H +#define CDSTEST_HDR_INTRUSIVE_MICHAEL_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace ci = cds::intrusive; + namespace co = cds::opt; + + class IntrusiveMichaelListHeaderTest: public CppUnitMini::TestCase + { + public: + + struct stat { + int nDisposeCount; + int nEnsureExistsCall; + int nEnsureNewCall; + int nFindCall; + int nEraseCall; + + stat() + : nDisposeCount(0) + , nEnsureExistsCall(0) + , nEnsureNewCall(0) + , nFindCall(0) + , nEraseCall(0) + {} + + stat( const stat& s ) + { + *this = s; + } + + stat& operator =(const stat& s) + { + memcpy( this, &s, sizeof(s)); + return *this; + } + }; + + template + struct base_int_item: public ci::michael_list::node< GC > + { + int nKey; + int nVal; + + mutable stat s; + + base_int_item() + {} + + base_int_item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + base_int_item(const base_int_item& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + const int& key() const + { + return nKey; + } + }; + + template + struct member_int_item + { + int nKey; + int nVal; + + ci::michael_list::node< GC > hMember; + + mutable stat s; + + member_int_item() + {} + + member_int_item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + member_int_item(const member_int_item& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + const int& key() const + { + return nKey; + } + }; + + 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(); + } + }; + + struct other_item { + int nKey; + + other_item( int n ) + : nKey(n) + {} + }; + + struct other_less { + template + bool operator()( T const& i1, Q const& i2) const + { + return i1.nKey < i2.nKey; + } + }; + + 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; + } + }; + + struct faked_disposer + { + template + void operator ()( T * p ) + { + ++p->s.nDisposeCount; + } + }; + + struct ensure_functor + { + template + void operator ()(bool bNew, T& item, T& /*val*/ ) + { + if ( bNew ) + ++item.s.nEnsureNewCall; + else + ++item.s.nEnsureExistsCall; + } + }; + + struct find_functor + { + template + void operator ()( T& item, Q& /*val*/ ) + { + ++item.s.nFindCall; + } + }; + + struct erase_functor + { + template + void operator()( T const& item ) + { + item.s.nEraseCall++; + } + }; + + template + void test_int_common() + { + typedef typename OrdList::value_type value_type; + + value_type v1( 10, 50 ); + value_type v2( 5, 25 ); + value_type v3( 20, 100 ); + { + OrdList l; + CPPUNIT_ASSERT( l.empty() ); + + CPPUNIT_ASSERT( l.insert( v1 )) ; // true + CPPUNIT_ASSERT( l.find( v1.key() )); + + CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v2.key() )); + CPPUNIT_ASSERT( !l.find_with( v3.key(), less() )); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr + + { + value_type v( v1 ); + CPPUNIT_ASSERT( !l.insert( v )) ; // false + } + + std::pair ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + + //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" + + CPPUNIT_ASSERT( l.find_with( v1.key(), less() )) ; // true + + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + CPPUNIT_ASSERT( l.find_with( v1.key(), less(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); + + CPPUNIT_ASSERT( l.find( v2.key() )); + + CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v2.key(), find_functor() )); + CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v3.key() )); + + { + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + + value_type v( v2 ); + ret = l.ensure( v, ensure_functor() ); + + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( !ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 ); + CPPUNIT_ASSERT( v.s.nEnsureNewCall == 0 ); + } + + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.insert( v3 )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() )); + + CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( l.unlink( v2 ) ); + CPPUNIT_ASSERT( l.find( v1.key() )) ; // true + CPPUNIT_ASSERT( !l.find( v2.key() )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() )) ; // true + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + + { + // v1 key is in the list but v NODE is not in the list + value_type v( v1 ); + CPPUNIT_ASSERT( !l.unlink( v ) ); + } + + CPPUNIT_ASSERT( l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.find( v1.key() )); + CPPUNIT_ASSERT( !l.find( v2.key() )); + CPPUNIT_ASSERT( l.find( v3.key() )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + + CPPUNIT_ASSERT( l.unlink( v3 ) ); + CPPUNIT_ASSERT( !l.find_with( v1.key(), less() )); + CPPUNIT_ASSERT( !l.find_with( v2.key(), less(), find_functor() )); + CPPUNIT_ASSERT( !l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v1 ) ); + CPPUNIT_ASSERT( !l.unlink( v2 ) ); + CPPUNIT_ASSERT( !l.unlink( v3 ) ); + + // Apply retired pointer to clean links + OrdList::gc::force_dispose(); + + stat s( v3.s ); + ret = l.ensure( v3, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v3.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v3.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + s = v2.s; + ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + s = v1.s; + ret = l.ensure( v1, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v1.s.nEnsureNewCall == s.nEnsureNewCall + 1); + CPPUNIT_ASSERT( v1.s.nEnsureExistsCall == s.nEnsureExistsCall ); + CPPUNIT_ASSERT( !l.empty() ); + + // Erase test + CPPUNIT_ASSERT( v1.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase( v1.key(), erase_functor()) ); + CPPUNIT_ASSERT( v1.s.nEraseCall == 1 ); + //CPPUNIT_ASSERT( v1.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.erase_with( v2.key(), less() ) ); + CPPUNIT_ASSERT( !l.erase( v2.key())); + //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( !l.erase( v2, erase_functor() )); + CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( !l.erase( v1 )); + //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( v3.s.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase_with( v3, less(), erase_functor() )); + CPPUNIT_ASSERT( v3.s.nEraseCall == 1 ); + //CPPUNIT_ASSERT( v3.s.nDisposeCount == 0 ); + CPPUNIT_ASSERT( l.empty() ); + + // Apply retired pointer to clean links + OrdList::gc::force_dispose(); + + // Unlink test + CPPUNIT_ASSERT( l.insert( v1 )); + CPPUNIT_ASSERT( l.insert( v3 )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( !l.unlink( v2 )); + CPPUNIT_ASSERT( l.unlink( v1 )); + CPPUNIT_ASSERT( !l.unlink( v1 )); + CPPUNIT_ASSERT( l.unlink( v3 )); + CPPUNIT_ASSERT( !l.unlink( v3 )); + CPPUNIT_ASSERT( l.empty() ); + + // Apply retired pointer + OrdList::gc::force_dispose(); + CPPUNIT_ASSERT( v1.s.nDisposeCount == 3 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 2 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 3 ); + + // Destructor test (call disposer) + CPPUNIT_ASSERT( l.insert( v1 )); + CPPUNIT_ASSERT( l.insert( v3 )); + CPPUNIT_ASSERT( l.insert( v2 )); + + // Iterator test + // begin/end + { + typename OrdList::iterator it = l.begin(); + typename OrdList::const_iterator cit = l.cbegin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( cit != l.end() ); + CPPUNIT_ASSERT( cit != l.cend() ); + CPPUNIT_ASSERT( cit == it ); + + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( ++it == l.end() ); + } + + // cbegin/cend + { + typename OrdList::const_iterator it = l.cbegin(); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != l.cend() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.cend() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( ++it == l.cend() ); + } + + // const begin/end + { + OrdList const & lref = l; + typename OrdList::const_iterator it = lref.begin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != lref.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( ++it == l.end() ); + } + } + + // Apply retired pointer + OrdList::gc::force_dispose(); + + CPPUNIT_ASSERT( v1.s.nDisposeCount == 4 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 3 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 4 ); + } + + template + void test_int() + { + test_int_common(); + + OrdList l; + typename OrdList::guarded_ptr gp; + + static int const nLimit = 20; + typename OrdList::value_type arrItem[nLimit]; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + for (int i = 0; i < nLimit; ++i) { + arrItem[i].nKey = a[i]; + arrItem[i].nVal = a[i] * 2; + } + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + for ( int i=0; i < nLimit; ++i ) { + gp = l.get( arrItem[i].nKey ); + CPPUNIT_ASSERT_EX( gp, "i=" << i ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); + CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); + gp.release(); + + gp = l.extract( arrItem[i].nKey ); + CPPUNIT_ASSERT_EX( gp, "i=" << i ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); + CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); + gp.release(); + + gp = l.get( arrItem[i].nKey ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( arrItem[i].nKey )); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.get( nLimit/2 )); + CPPUNIT_ASSERT( gp.empty()); + CPPUNIT_ASSERT( !l.extract( nLimit/2 )); + CPPUNIT_ASSERT( gp.empty()); + + // Apply retired pointer + OrdList::gc::force_dispose(); + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + for ( int i=0; i < nLimit; ++i ) { + other_item itm( arrItem[i].nKey ); + gp = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT_EX( gp, "i=" << i ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); + CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); + gp.release(); + + gp = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT_EX( gp, "i=" << i ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); + CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); + gp.release(); + + gp = l.get_with( itm, other_less() ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( itm, other_less() )); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() )); + CPPUNIT_ASSERT( gp.empty()); + CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() )); + CPPUNIT_ASSERT( gp.empty()); + + // Apply retired pointer + OrdList::gc::force_dispose(); + + for ( int i=0; i < nLimit; i++ ) { + CPPUNIT_ASSERT( arrItem[i].s.nDisposeCount == 2 ); + } + } + } + + template + void test_rcu_int() + { + test_int_common(); + + OrdList l; + static int const nLimit = 20; + typename OrdList::value_type arrItem[nLimit]; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + for (int i = 0; i < nLimit; ++i) { + arrItem[i].nKey = a[i]; + arrItem[i].nVal = a[i] * 2; + } + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + + typename OrdList::exempt_ptr ep; + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + } + + { + rcu_lock lock; + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); + } + ep.release(); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[i] )); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + ep = l.extract( a[0] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + // Apply retired pointer + OrdList::gc::force_dispose(); + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + other_item itm( a[i] ); + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + } + + { + rcu_lock lock; + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); + } + ep.release(); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + // Apply retired pointer + OrdList::gc::force_dispose(); + } + } + + template + void test_nogc_int() + { + typedef typename OrdList::value_type value_type; + { + value_type v1( 10, 50 ); + value_type v2( 5, 25 ); + value_type v3( 20, 100 ); + { + OrdList l; + CPPUNIT_ASSERT( l.empty() ); + + CPPUNIT_ASSERT( l.insert( v1 )) ; // true + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); + + CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( l.find_with( v2.key(), less() ) == nullptr ); + CPPUNIT_ASSERT( !l.find_with( v3.key(), less(), find_functor() )); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr + + { + value_type v( v1 ); + CPPUNIT_ASSERT( !l.insert( v )) ; // false + } + + std::pair ret = l.ensure( v2, ensure_functor() ); + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); + + //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" + + CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true + + CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); + CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); + CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); + + CPPUNIT_ASSERT( l.find( v2.key() ) == &v2 ); + + CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v2.key(), find_functor() )); + CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); + + CPPUNIT_ASSERT( !l.find( v3.key() )); + + { + value_type v( v2 ); + ret = l.ensure( v, ensure_functor() ); + + CPPUNIT_ASSERT( ret.first ); + CPPUNIT_ASSERT( !ret.second ); + CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); + CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); + } + + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.insert( v3 )) ; // true + CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); + + CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); + CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); + CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); + + { + typename OrdList::iterator it = l.begin(); + typename OrdList::const_iterator cit = l.cbegin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it != l.cend() ); + CPPUNIT_ASSERT( cit != l.end() ); + CPPUNIT_ASSERT( cit != l.cend() ); + CPPUNIT_ASSERT( cit == it ); + + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + + { + OrdList const & lref = l; + typename OrdList::const_iterator it = lref.begin(); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == v2.nKey ); + CPPUNIT_ASSERT( it->nVal == v2.nVal ); + CPPUNIT_ASSERT( ++it != lref.end() ); + CPPUNIT_ASSERT( it->nKey == v1.nKey ); + CPPUNIT_ASSERT( it->nVal == v1.nVal ); + CPPUNIT_ASSERT( it++ != l.end() ); + CPPUNIT_ASSERT( it->nKey == v3.nKey ); + CPPUNIT_ASSERT( it->nVal == v3.nVal ); + CPPUNIT_ASSERT( it++ != lref.end() ); + CPPUNIT_ASSERT( it == l.end() ); + } + } + + // Disposer called on list destruction + CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); + CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); + } + } + + void HP_base_cmp(); + void HP_base_less(); + void HP_base_cmpmix(); + void HP_base_ic(); + void HP_member_cmp(); + void HP_member_less(); + void HP_member_cmpmix(); + void HP_member_ic(); + + void DHP_base_cmp(); + void DHP_base_less(); + void DHP_base_cmpmix(); + void DHP_base_ic(); + void DHP_member_cmp(); + void DHP_member_less(); + void DHP_member_cmpmix(); + void DHP_member_ic(); + + void RCU_GPI_base_cmp(); + void RCU_GPI_base_less(); + void RCU_GPI_base_cmpmix(); + void RCU_GPI_base_ic(); + void RCU_GPI_member_cmp(); + void RCU_GPI_member_less(); + void RCU_GPI_member_cmpmix(); + void RCU_GPI_member_ic(); + + void RCU_GPB_base_cmp(); + void RCU_GPB_base_less(); + void RCU_GPB_base_cmpmix(); + void RCU_GPB_base_ic(); + void RCU_GPB_member_cmp(); + void RCU_GPB_member_less(); + void RCU_GPB_member_cmpmix(); + void RCU_GPB_member_ic(); + + void RCU_GPT_base_cmp(); + void RCU_GPT_base_less(); + void RCU_GPT_base_cmpmix(); + void RCU_GPT_base_ic(); + void RCU_GPT_member_cmp(); + void RCU_GPT_member_less(); + void RCU_GPT_member_cmpmix(); + void RCU_GPT_member_ic(); + + void RCU_SHB_base_cmp(); + void RCU_SHB_base_less(); + void RCU_SHB_base_cmpmix(); + void RCU_SHB_base_ic(); + void RCU_SHB_member_cmp(); + void RCU_SHB_member_less(); + void RCU_SHB_member_cmpmix(); + void RCU_SHB_member_ic(); + + void RCU_SHT_base_cmp(); + void RCU_SHT_base_less(); + void RCU_SHT_base_cmpmix(); + void RCU_SHT_base_ic(); + void RCU_SHT_member_cmp(); + void RCU_SHT_member_less(); + void RCU_SHT_member_cmpmix(); + void RCU_SHT_member_ic(); + + void nogc_base_cmp(); + void nogc_base_less(); + void nogc_base_cmpmix(); + void nogc_base_ic(); + void nogc_member_cmp(); + void nogc_member_less(); + void nogc_member_cmpmix(); + void nogc_member_ic(); + + + CPPUNIT_TEST_SUITE(IntrusiveMichaelListHeaderTest) + CPPUNIT_TEST(HP_base_cmp) + CPPUNIT_TEST(HP_base_less) + CPPUNIT_TEST(HP_base_cmpmix) + CPPUNIT_TEST(HP_base_ic) + CPPUNIT_TEST(HP_member_cmp) + CPPUNIT_TEST(HP_member_less) + CPPUNIT_TEST(HP_member_cmpmix) + CPPUNIT_TEST(HP_member_ic) + + CPPUNIT_TEST(DHP_base_cmp) + CPPUNIT_TEST(DHP_base_less) + CPPUNIT_TEST(DHP_base_cmpmix) + CPPUNIT_TEST(DHP_base_ic) + CPPUNIT_TEST(DHP_member_cmp) + CPPUNIT_TEST(DHP_member_less) + CPPUNIT_TEST(DHP_member_cmpmix) + CPPUNIT_TEST(DHP_member_ic) + + CPPUNIT_TEST(RCU_GPI_base_cmp) + CPPUNIT_TEST(RCU_GPI_base_less) + CPPUNIT_TEST(RCU_GPI_base_cmpmix) + CPPUNIT_TEST(RCU_GPI_base_ic) + CPPUNIT_TEST(RCU_GPI_member_cmp) + CPPUNIT_TEST(RCU_GPI_member_less) + CPPUNIT_TEST(RCU_GPI_member_cmpmix) + CPPUNIT_TEST(RCU_GPI_member_ic) + + CPPUNIT_TEST(RCU_GPB_base_cmp) + CPPUNIT_TEST(RCU_GPB_base_less) + CPPUNIT_TEST(RCU_GPB_base_cmpmix) + CPPUNIT_TEST(RCU_GPB_base_ic) + CPPUNIT_TEST(RCU_GPB_member_cmp) + CPPUNIT_TEST(RCU_GPB_member_less) + CPPUNIT_TEST(RCU_GPB_member_cmpmix) + CPPUNIT_TEST(RCU_GPB_member_ic) + + CPPUNIT_TEST(RCU_GPT_base_cmp) + CPPUNIT_TEST(RCU_GPT_base_less) + CPPUNIT_TEST(RCU_GPT_base_cmpmix) + CPPUNIT_TEST(RCU_GPT_base_ic) + CPPUNIT_TEST(RCU_GPT_member_cmp) + CPPUNIT_TEST(RCU_GPT_member_less) + CPPUNIT_TEST(RCU_GPT_member_cmpmix) + CPPUNIT_TEST(RCU_GPT_member_ic) + + CPPUNIT_TEST(nogc_base_cmp) + CPPUNIT_TEST(nogc_base_less) + CPPUNIT_TEST(nogc_base_cmpmix) + CPPUNIT_TEST(nogc_base_ic) + CPPUNIT_TEST(nogc_member_cmp) + CPPUNIT_TEST(nogc_member_less) + CPPUNIT_TEST(nogc_member_cmpmix) + CPPUNIT_TEST(nogc_member_ic) + + CPPUNIT_TEST_SUITE_END() + }; +} // namespace ordlist + +#endif // CDSTEST_HDR_INTRUSIVE_MICHAEL_H diff --git a/tests/test-hdr/list/hdr_intrusive_michael_dhp.cpp b/tests/test-hdr/list/hdr_intrusive_michael_dhp.cpp new file mode 100644 index 00000000..cbeb7797 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_dhp.cpp @@ -0,0 +1,127 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include + +namespace ordlist { + void IntrusiveMichaelListHeaderTest::DHP_base_cmp() + { + typedef base_int_item< cds::gc::DHP > item; + struct traits : public ci::michael_list::traits { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< cds::gc::DHP, item, traits > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_base_less() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_base_cmpmix() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_base_ic() + { + typedef base_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_member_cmp() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_member_less() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_member_cmpmix() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::DHP_member_ic() + { + typedef member_int_item< cds::gc::DHP > item; + typedef ci::MichaelList< cds::gc::DHP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_michael_hp.cpp b/tests/test-hdr/list/hdr_intrusive_michael_hp.cpp new file mode 100644 index 00000000..d81029d4 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_hp.cpp @@ -0,0 +1,128 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include + +namespace ordlist { + void IntrusiveMichaelListHeaderTest::HP_base_cmp() + { + typedef base_int_item< cds::gc::HP > item; + struct traits : public ci::michael_list::traits { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< cds::gc::HP, item, traits > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_base_less() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_base_cmpmix() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_base_ic() + { + typedef base_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_member_cmp() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_member_less() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_member_cmpmix() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_int(); + } + void IntrusiveMichaelListHeaderTest::HP_member_ic() + { + typedef member_int_item< cds::gc::HP > item; + typedef ci::MichaelList< cds::gc::HP + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_int(); + } +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::IntrusiveMichaelListHeaderTest); diff --git a/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpb.cpp b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpb.cpp new file mode 100644 index 00000000..f281a236 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpb.cpp @@ -0,0 +1,132 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > RCU; + } + + void IntrusiveMichaelListHeaderTest::RCU_GPB_base_cmp() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_base_less() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_member_cmp() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_member_less() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_member_cmpmix() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPB_member_ic() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + +} diff --git a/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpi.cpp b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpi.cpp new file mode 100644 index 00000000..a19b9821 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpi.cpp @@ -0,0 +1,131 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > RCU; + } + + void IntrusiveMichaelListHeaderTest::RCU_GPI_base_cmp() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_base_less() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_member_cmp() + { + typedef member_int_item< RCU > item; + struct traits: public + ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + {}; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_member_less() + { + typedef member_int_item< RCU > item; + struct traits: public + ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + {}; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_member_cmpmix() + { + typedef member_int_item< RCU > item; + struct traits: public + ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + {}; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPI_member_ic() + { + typedef member_int_item< RCU > item; + struct traits: public + ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + {}; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpt.cpp b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpt.cpp new file mode 100644 index 00000000..684f0e23 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_gpt.cpp @@ -0,0 +1,132 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > RCU; + } + + void IntrusiveMichaelListHeaderTest::RCU_GPT_base_cmp() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_base_less() + { + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_base_cmpmix() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_base_ic() + { + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_member_cmp() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_member_less() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_member_cmpmix() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); + } + void IntrusiveMichaelListHeaderTest::RCU_GPT_member_ic() + { + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); + } + +} diff --git a/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_shb.cpp b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_shb.cpp new file mode 100644 index 00000000..450038dd --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_shb.cpp @@ -0,0 +1,150 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > RCU; + } +#endif + + void IntrusiveMichaelListHeaderTest::RCU_SHB_base_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_base_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_base_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_base_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_member_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_member_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_member_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHB_member_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + +} diff --git a/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_sht.cpp b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_sht.cpp new file mode 100644 index 00000000..b028b934 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_list_rcu_sht.cpp @@ -0,0 +1,150 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > RCU; + } +#endif + + void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_base_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< RCU, item, traits > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_base_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef base_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_member_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_rcu_int(); +#endif + } + void IntrusiveMichaelListHeaderTest::RCU_SHT_member_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + typedef member_int_item< RCU > item; + typedef ci::MichaelList< RCU + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_rcu_int(); +#endif + } + +} diff --git a/tests/test-hdr/list/hdr_intrusive_michael_nogc.cpp b/tests/test-hdr/list/hdr_intrusive_michael_nogc.cpp new file mode 100644 index 00000000..9656f565 --- /dev/null +++ b/tests/test-hdr/list/hdr_intrusive_michael_nogc.cpp @@ -0,0 +1,127 @@ +//$$CDS-header$$ + +#include "list/hdr_intrusive_michael.h" +#include + +namespace ordlist { + void IntrusiveMichaelListHeaderTest::nogc_base_cmp() + { + typedef base_int_item< cds::gc::nogc > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef cmp compare; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< cds::gc::nogc, item, traits > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_base_less() + { + typedef base_int_item< cds::gc::nogc > item; + struct traits : public ci::michael_list::traits + { + typedef ci::michael_list::base_hook< co::gc > hook; + typedef IntrusiveMichaelListHeaderTest::less less; + typedef faked_disposer disposer; + }; + typedef ci::MichaelList< cds::gc::nogc, item, traits > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_base_cmpmix() + { + typedef base_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_base_ic() + { + typedef base_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::base_hook< co::gc > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_member_cmp() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_member_less() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_member_cmpmix() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::less< less > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + >::type + > list; + test_nogc_int(); + } + void IntrusiveMichaelListHeaderTest::nogc_member_ic() + { + typedef member_int_item< cds::gc::nogc > item; + typedef ci::MichaelList< cds::gc::nogc + ,item + ,ci::michael_list::make_traits< + ci::opt::hook< ci::michael_list::member_hook< + offsetof( item, hMember ), + co::gc + > > + ,co::compare< cmp > + ,ci::opt::disposer< faked_disposer > + ,co::item_counter< cds::atomicity::item_counter > + >::type + > list; + test_nogc_int(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_lazy.h b/tests/test-hdr/list/hdr_lazy.h new file mode 100644 index 00000000..a77ffd7c --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy.h @@ -0,0 +1,948 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_LAZY_H +#define CDSTEST_HDR_LAZY_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace cc = cds::container; + namespace co = cds::container::opt; + + class LazyListTestHeader: public CppUnitMini::TestCase + { + public: + struct stat { + int nEnsureExistsCall; + int nEnsureNewCall; + + stat() + { + nEnsureExistsCall + = nEnsureNewCall + = 0; + } + }; + + struct item { + int nKey; + int nVal; + + stat s; + + item(int key) + : nKey( key ) + , nVal( key * 2 ) + , s() + {} + + item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + item( item const& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + int key() const + { + return nKey; + } + }; + + template + struct lt + { + 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 equal_to + { + 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; + } + }; + + struct insert_functor { + void operator ()( item& i ) + { + i.nVal = i.nKey * 1033; + } + }; + struct dummy_insert_functor { + void operator ()( item& /*i*/ ) + { + // This functor should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_functor should not be called", __FILE__, __LINE__ ); + } + }; + + static void insert_function( item& i ) + { + i.nVal = i.nKey * 1024; + } + static void dummy_insert_function( item& /*i*/ ) + { + // This function should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_function should not be called", __FILE__, __LINE__ ); + } + + struct erase_functor { + unsigned int nEraseCall; + + erase_functor() + : nEraseCall(0) + {} + + void operator()( item const& /*i*/) + { + ++nEraseCall; + } + }; + + struct check_value { + unsigned int m_nMultiplier; + + check_value( unsigned int nMultiplier ) + : m_nMultiplier( nMultiplier ) + {} + + check_value( const check_value& s ) + : m_nMultiplier( s.m_nMultiplier ) + {} + + void operator()( item& i, int ) + { + CPPUNIT_ASSERT_CURRENT( int(i.nKey * m_nMultiplier) == i.nVal ); + } + }; + + struct check_exact_value { + int m_nExpected; + + check_exact_value( int nExpected ) + : m_nExpected( nExpected ) + {} + + check_exact_value( check_exact_value const& s) + : m_nExpected( s.m_nExpected ) + {} + + void operator()( item& i, int ) + { + CPPUNIT_ASSERT_CURRENT( i.nVal == m_nExpected ); + } + }; + + struct dummy_check_value { + void operator()( item& /*i*/, int ) + { + // This functor should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_check_value should not be called", __FILE__, __LINE__ ); + } + }; + + struct ensure_functor { + void operator()( bool /*bNew*/, item& i, int /*n*/ ) + { + i.nVal = i.nKey * 1024; + } + }; + + static void ensure_func( bool /*bNew*/, item& i, int n ) + { + i.nVal = n * 1033; + } + + struct other_item + { + int nKey; + + other_item() + {} + + other_item(int n) + : nKey(n) + {} + }; + + struct other_less + { + template + bool operator()( T1 const& t1, T2 const& t2 ) const + { + return t1.nKey < t2.nKey; + } + }; + + protected: + template + void test_with( OrdList& l ) + { + typedef typename OrdList::value_type value_type; + + // The list should be empty + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.insert( 50 ) ); + CPPUNIT_ASSERT( l.insert( item( 25 )) ); + CPPUNIT_ASSERT( l.insert( item( 100 )) ); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.insert( 50 ) ); + CPPUNIT_ASSERT( !l.insert( item( 100 )) ); + + // clear test + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + // and now the list is empty + CPPUNIT_ASSERT( l.empty() ); + + // Test insert with functor + + CPPUNIT_ASSERT( l.insert( 100, insert_functor() ) ); + // passed by ref + { + insert_functor f; + CPPUNIT_ASSERT( l.insert( item( 25 ), std::ref( f ) ) ); + CPPUNIT_ASSERT( !l.insert( item( 100 ), std::ref( f ) ) ); + } + // Test insert with function + CPPUNIT_ASSERT( l.insert( 50, insert_function )); + CPPUNIT_ASSERT( !l.insert( 25, dummy_insert_function )); + CPPUNIT_ASSERT( !l.insert( 100, dummy_insert_functor() )); + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + + // Check inserted values + { + int i; + i = 100; + + CPPUNIT_ASSERT( l.find( 100 )); + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + { + check_value f(1033); + i = 25; + CPPUNIT_ASSERT( l.find_with( 25, lt() )); + CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( f ) ) ); + } + i = 50; + CPPUNIT_ASSERT( l.find( 50 )); + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + + i = 10; + CPPUNIT_ASSERT( !l.find_with( 10, lt() )); + CPPUNIT_ASSERT( !l.find_with( i, lt(), dummy_check_value() )); + i = 75; + CPPUNIT_ASSERT( !l.find( 75 )); + CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); + i = 150; + CPPUNIT_ASSERT( !l.find( 150 )); + CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); + } + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + // and now the list is empty + CPPUNIT_ASSERT( l.empty() ); + + // Ensure test + { + std::pair ensureResult; + ensure_functor f; + ensureResult = l.ensure( 100, ensure_functor() ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + ensureResult = l.ensure( 200, std::ref( f ) ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + ensureResult = l.ensure( 50, ensure_func ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + int i; + i = 100; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + i = 50; + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + i = 200; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + + // ensure existing key + ensureResult = l.ensure( 200, ensure_func ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( !ensureResult.second ); + i = 200; + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + + ensureResult = l.ensure( 50, ensure_functor() ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( !ensureResult.second ); + i = 50; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + } + + // erase test (list: 50, 100, 200) + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.insert(160)); + CPPUNIT_ASSERT( l.insert(250)); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.erase( 150 )); + + CPPUNIT_ASSERT( l.erase( 100 )); + CPPUNIT_ASSERT( !l.erase( 100 )); + + CPPUNIT_ASSERT( l.erase_with( 200, lt() )); + CPPUNIT_ASSERT( !l.erase_with( 200, lt() )); + + { + erase_functor ef; + CPPUNIT_ASSERT( ef.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase_with( 160, lt(), std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 1 ); + CPPUNIT_ASSERT( !l.erase_with( 160, lt(), std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 1 ); + + CPPUNIT_ASSERT( l.erase( 250, std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 2 ); + CPPUNIT_ASSERT( !l.erase( 250, std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 2 ); + } + + CPPUNIT_ASSERT( l.erase( 50 )); + CPPUNIT_ASSERT( !l.erase( 50 )); + + CPPUNIT_ASSERT( l.empty() ); + + // clear empty list + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + { + int i; + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) ); + CPPUNIT_ASSERT( l.emplace( 251, 152 )); + CPPUNIT_ASSERT( l.emplace( item( 1001 )) ); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); + CPPUNIT_ASSERT( !l.emplace( 251, 10) ); + + i = 501; + CPPUNIT_ASSERT( l.find( i, check_exact_value(501*2) )); + i = 251; + CPPUNIT_ASSERT( l.find( i, check_exact_value(152) )); + i = 1001; + CPPUNIT_ASSERT( l.find( i, check_exact_value(1001*2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert( i ) ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { + it->nVal = i * 2; + CPPUNIT_ASSERT( it->nKey == i ); + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.find( i, check_value(2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i) ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { + // it->nVal = i * 2 ; // not! + CPPUNIT_ASSERT( it->nKey == i ); + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.find_with( i, lt(), check_value(2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + } + + template + void test() + { + typedef typename OrdList::guarded_ptr guarded_ptr; + typedef typename OrdList::value_type value_type; + + OrdList l; + test_with( l ); + + static int const nLimit = 20; + int arr[nLimit]; + for ( int i = 0; i < nLimit; i++ ) + arr[i] = i; + std::random_shuffle( arr, arr + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i] ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + + gp = l.get( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey * 2 ); + gp.release(); + + gp = l.extract( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey*2 ); + gp.release(); + + gp = l.get( nKey ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( nKey)); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get(arr[0])); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( arr[0])); + CPPUNIT_CHECK( gp.empty()); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i] ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + other_item key( nKey ); + + gp = l.get_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey * 2 ); + gp.release(); + + gp = l.extract_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey*2 ); + gp.release(); + + gp = l.get_with( key, other_less() ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( key, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less())); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less())); + CPPUNIT_CHECK( gp.empty()); + } + + } + + template + void test_rcu() + { + OrdList l; + test_with( l ); + + static int const nLimit = 20; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( a[i] ) ); + + typename OrdList::exempt_ptr ep; + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[i] )); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + ep = l.extract( a[0] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( a[i] ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + other_item itm( a[i] ); + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + } + } + + template + void nogc_test() + { + typedef OrdList list; + typedef typename list::value_type value_type; + typedef std::pair ensure_result; + + typename list::iterator it; + + list l; + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( l.insert(50) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + + ensure_result eres = l.ensure( item(100, 33) ); + CPPUNIT_ASSERT( eres.second ); + CPPUNIT_ASSERT( eres.first != l.end() ); + CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); + + CPPUNIT_ASSERT( l.insert(100) == l.end() ); + eres = l.ensure( item(50, 33) ); + CPPUNIT_ASSERT( !eres.second ); + CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); + eres.first->nVal = 63; + + it = l.find( 33 ); + CPPUNIT_ASSERT( it == l.end() ); + + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 50 ); + CPPUNIT_ASSERT( it->nVal == 63 ); + + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 100 ); + CPPUNIT_ASSERT( it->nVal == 33 ); + + it = l.find_with( 150, lt() ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 150 ); + CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); + + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end()); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); + + it = l.find( 501 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 501 ); + CPPUNIT_ASSERT( it->nVal == 501 * 2 ); + + it = l.find_with( 251, lt() ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 251 ); + CPPUNIT_ASSERT( it->nVal == 152 ); + + it = l.find( 1001 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 1001 ); + CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + template + void nogc_unord_test() + { + typedef UnordList list; + typedef typename list::value_type value_type; + typedef std::pair ensure_result; + + typename list::iterator it; + + list l; + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( l.insert(50) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + + ensure_result eres = l.ensure( item(100, 33) ); + CPPUNIT_ASSERT( eres.second ); + CPPUNIT_ASSERT( eres.first != l.end() ); + CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); + + CPPUNIT_ASSERT( l.insert(100) == l.end() ); + eres = l.ensure( item(50, 33) ); + CPPUNIT_ASSERT( !eres.second ); + CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); + eres.first->nVal = 63; + + it = l.find( 33 ); + CPPUNIT_ASSERT( it == l.end() ); + + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 50 ); + CPPUNIT_ASSERT( it->nVal == 63 ); + + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 100 ); + CPPUNIT_ASSERT( it->nVal == 33 ); + + it = l.find_with( 150, equal_to() ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 150 ); + CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); + + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end()); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); + + it = l.find( 501 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 501 ); + CPPUNIT_ASSERT( it->nVal == 501 * 2 ); + + it = l.find( 1001 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 1001 ); + CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); + + { + typename UnordList::iterator it( l.begin() ); + typename UnordList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + void HP_cmp(); + void HP_less(); + void HP_cmpmix(); + void HP_ic(); + + void DHP_cmp(); + void DHP_less(); + void DHP_cmpmix(); + void DHP_ic(); + + void RCU_GPI_cmp(); + void RCU_GPI_less(); + void RCU_GPI_cmpmix(); + void RCU_GPI_ic(); + + void RCU_GPB_cmp(); + void RCU_GPB_less(); + void RCU_GPB_cmpmix(); + void RCU_GPB_ic(); + + void RCU_GPT_cmp(); + void RCU_GPT_less(); + void RCU_GPT_cmpmix(); + void RCU_GPT_ic(); + + void RCU_SHB_cmp(); + void RCU_SHB_less(); + void RCU_SHB_cmpmix(); + void RCU_SHB_ic(); + + void RCU_SHT_cmp(); + void RCU_SHT_less(); + void RCU_SHT_cmpmix(); + void RCU_SHT_ic(); + + void NOGC_cmp(); + void NOGC_less(); + void NOGC_cmpmix(); + void NOGC_ic(); + + void NOGC_cmp_unord(); + void NOGC_less_unord(); + void NOGC_equal_to_unord(); + void NOGC_cmpmix_unord(); + void NOGC_equal_to_mix_unord(); + void NOGC_ic_unord(); + + + CPPUNIT_TEST_SUITE(LazyListTestHeader) + CPPUNIT_TEST(HP_cmp) + CPPUNIT_TEST(HP_less) + CPPUNIT_TEST(HP_cmpmix) + CPPUNIT_TEST(HP_ic) + + CPPUNIT_TEST(DHP_cmp) + CPPUNIT_TEST(DHP_less) + CPPUNIT_TEST(DHP_cmpmix) + CPPUNIT_TEST(DHP_ic) + + CPPUNIT_TEST(RCU_GPI_cmp) + CPPUNIT_TEST(RCU_GPI_less) + CPPUNIT_TEST(RCU_GPI_cmpmix) + CPPUNIT_TEST(RCU_GPI_ic) + + CPPUNIT_TEST(RCU_GPB_cmp) + CPPUNIT_TEST(RCU_GPB_less) + CPPUNIT_TEST(RCU_GPB_cmpmix) + CPPUNIT_TEST(RCU_GPB_ic) + + CPPUNIT_TEST(RCU_GPT_cmp) + CPPUNIT_TEST(RCU_GPT_less) + CPPUNIT_TEST(RCU_GPT_cmpmix) + CPPUNIT_TEST(RCU_GPT_ic) + + CPPUNIT_TEST(RCU_SHB_cmp) + CPPUNIT_TEST(RCU_SHB_less) + CPPUNIT_TEST(RCU_SHB_cmpmix) + CPPUNIT_TEST(RCU_SHB_ic) + + CPPUNIT_TEST(RCU_SHT_cmp) + CPPUNIT_TEST(RCU_SHT_less) + CPPUNIT_TEST(RCU_SHT_cmpmix) + CPPUNIT_TEST(RCU_SHT_ic) + + CPPUNIT_TEST(NOGC_cmp) + CPPUNIT_TEST(NOGC_less) + CPPUNIT_TEST(NOGC_cmpmix) + CPPUNIT_TEST(NOGC_ic) + + CPPUNIT_TEST(NOGC_cmp_unord) + CPPUNIT_TEST(NOGC_less_unord) + CPPUNIT_TEST(NOGC_equal_to_unord) + CPPUNIT_TEST(NOGC_cmpmix_unord) + CPPUNIT_TEST(NOGC_equal_to_mix_unord) + CPPUNIT_TEST(NOGC_ic_unord) + + CPPUNIT_TEST_SUITE_END() + }; + +} // namespace ordlist + +#endif // #ifndef CDSTEST_HDR_LAZY_H \ No newline at end of file diff --git a/tests/test-hdr/list/hdr_lazy_dhp.cpp b/tests/test-hdr/list/hdr_lazy_dhp.cpp new file mode 100644 index 00000000..3cd90fb5 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_dhp.cpp @@ -0,0 +1,100 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include + +namespace ordlist { + namespace { + struct DHP_cmp_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } + void LazyListTestHeader::DHP_cmp() + { + // traits-based version + typedef cc::LazyList< cds::gc::DHP, item, DHP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::DHP, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_less_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::DHP_less() + { + // traits-based version + typedef cc::LazyList< cds::gc::DHP, item, DHP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::DHP, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::DHP_cmpmix() + { + // traits-based version + typedef cc::LazyList< cds::gc::DHP, item, DHP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::DHP, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_ic_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::DHP_ic() + { + // traits-based version + typedef cc::LazyList< cds::gc::DHP, item, DHP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::DHP, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_hp.cpp b/tests/test-hdr/list/hdr_lazy_hp.cpp new file mode 100644 index 00000000..0ec60ed1 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_hp.cpp @@ -0,0 +1,102 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include + +namespace ordlist { + namespace { + struct HP_cmp_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + + } + void LazyListTestHeader::HP_cmp() + { + // traits-based version + typedef cc::LazyList< cds::gc::HP, item, HP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::HP, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_less_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::HP_less() + { + // traits-based version + typedef cc::LazyList< cds::gc::HP, item, HP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::HP, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::HP_cmpmix() + { + // traits-based version + typedef cc::LazyList< cds::gc::HP, item, HP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::HP, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_ic_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::HP_ic() + { + // traits-based version + typedef cc::LazyList< cds::gc::HP, item, HP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::HP, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::LazyListTestHeader); diff --git a/tests/test-hdr/list/hdr_lazy_kv.h b/tests/test-hdr/list/hdr_lazy_kv.h new file mode 100644 index 00000000..c719ac89 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv.h @@ -0,0 +1,933 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_LAZY_KV_H +#define CDSTEST_HDR_LAZY_KV_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace cc = cds::container; + namespace co = cds::container::opt; + + class LazyKVListTestHeader: public CppUnitMini::TestCase + { + public: + typedef int key_type; + struct value_type { + int m_val; + + value_type() + : m_val(0) + {} + + value_type( int n ) + : m_val( n ) + {} + }; + + template + struct lt + { + bool operator ()(const T& v1, const T& v2 ) const + { + return v1 < v2; + } + }; + + template + struct cmp { + int operator ()(const T& v1, const T& v2 ) const + { + if ( v1 < v2 ) + return -1; + return v1 > v2 ? 1 : 0; + } + }; + + template + struct eq { + bool operator ()(const T& v1, const T& v2 ) const + { + return v1 == v2; + } + }; + + struct check_value { + int m_nExpected; + + check_value( int nExpected ) + : m_nExpected( nExpected ) + {} + + template + void operator ()( T& pair ) + { + CPPUNIT_ASSERT_CURRENT( pair.second.m_val == m_nExpected ); + } + }; + + struct insert_functor { + template + void operator()( T& pair ) + { + pair.second.m_val = pair.first * 10; + } + }; + + struct ensure_functor { + template + void operator()( bool /*bNew*/, T& pair ) + { + pair.second.m_val = pair.first * 50; + } + }; + + struct erase_functor { + int nKey; + int nVal; + + erase_functor() + : nKey(0) + , nVal(0) + {} + + template + void operator()( T& i ) + { + nKey = i.first; + nVal = i.second.m_val; + } + }; + + typedef float other_key; + struct other_less { + bool operator()( float f, int i ) const + { + return int(f) < i; + } + bool operator()( int i, float f ) const + { + return i < int(f); + } + }; + + protected: + template + void test_with( OrdList& l) + { + typedef typename OrdList::value_type value_type; + + typename OrdList::iterator itTest; + typename OrdList::const_iterator citTest; + + CPPUNIT_ASSERT( l.empty() ); + + // insert / find test + CPPUNIT_ASSERT( !l.find( 100 )); + CPPUNIT_ASSERT( l.insert( 100 )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.find( 100 )); + + check_value chk(0); + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + + CPPUNIT_ASSERT( !l.find_with( 50, lt() )); + CPPUNIT_ASSERT( l.insert( 50, 500 )); + CPPUNIT_ASSERT( l.find_with( 50, lt() )); + CPPUNIT_ASSERT( !l.insert( 50, 5 )); + chk.m_nExpected = 500; + CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); + chk.m_nExpected = 0; + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.find( 150 )); + CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() )); + CPPUNIT_ASSERT( l.find( 150 )); + chk.m_nExpected = 1500; + CPPUNIT_ASSERT( l.find_with( 150, lt(), std::ref( chk ) ) ); + chk.m_nExpected = 0; + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + chk.m_nExpected = 500; + CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); + CPPUNIT_ASSERT( !l.empty() ); + + // erase test + + CPPUNIT_ASSERT( !l.erase( 500 )); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.find( 50 )); + { + erase_functor ef; + l.erase( 50, std::ref( ef ) ); + CPPUNIT_ASSERT( ef.nKey == 50 ); + CPPUNIT_ASSERT( ef.nVal == 500 ); + } + CPPUNIT_ASSERT( !l.find( 50 )); + + // ensure test + std::pair bEnsureResult; + bEnsureResult = l.ensure( 100, ensure_functor() ); + CPPUNIT_ASSERT( bEnsureResult.first ); + CPPUNIT_ASSERT( !bEnsureResult.second ); + chk.m_nExpected = 5000; + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + + { + ensure_functor ef; + bEnsureResult = l.ensure( 50, std::ref( ef ) ); + } + CPPUNIT_ASSERT( bEnsureResult.first ); + CPPUNIT_ASSERT( bEnsureResult.second ); + chk.m_nExpected = 2500; + CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); + + // erase test + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() )); + CPPUNIT_ASSERT( l.insert( 25 )); + CPPUNIT_ASSERT( l.erase( 100 )); + CPPUNIT_ASSERT( l.erase( 150 )); + { + erase_functor ef; + CPPUNIT_ASSERT( l.erase_with( 200, lt(), std::ref(ef)) ); + CPPUNIT_ASSERT( ef.nKey == 200 ); + CPPUNIT_ASSERT( ef.nVal == 2000 ); + } + CPPUNIT_ASSERT( l.erase_with( 25, lt())) + CPPUNIT_ASSERT( l.erase( 50 )); + CPPUNIT_ASSERT( l.empty() ); + + // clear empty list + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) ); + CPPUNIT_ASSERT( l.emplace( 251, 152 )); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); + CPPUNIT_ASSERT( !l.emplace( 251, 10) ); + + check_value cv(0); + CPPUNIT_ASSERT( l.find( 501, std::ref(cv) )); + cv.m_nExpected = 152; + CPPUNIT_ASSERT( l.find( 251, std::ref(cv) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 2 ) ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it.val().m_val == i * 2 ); + it.val().m_val = i * 3; + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + chk.m_nExpected = i * 3; + CPPUNIT_ASSERT( l.find( i, std::ref( chk ) ) ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 7) ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it.val().m_val == i * 7 ); + } + + // Check that we have visited all items + for ( int i = nCount; i > 0; --i ) { + chk.m_nExpected = (i - 1) * 7; + CPPUNIT_ASSERT( l.find_with( i - 1, lt(), std::ref( chk ) ) ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + } + + template + void test() + { + OrdList l; + test_with(l); + + typedef typename OrdList::guarded_ptr guarded_ptr; + + static int const nLimit = 20; + int arr[nLimit]; + for ( int i = 0; i < nLimit; i++ ) + arr[i] = i; + std::random_shuffle( arr, arr + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i], arr[i] * 2 ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + + gp = l.get( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); + gp.release(); + + gp = l.extract( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); + gp.release(); + + gp = l.get( nKey ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( nKey)); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get(arr[0])); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( arr[0])); + CPPUNIT_CHECK( gp.empty()); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i], arr[i] * 2 ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + other_key key = float(nKey + 0.3); + + gp = l.get_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); + gp.release(); + + gp = l.extract_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); + gp.release(); + + gp = l.get_with( key, other_less() ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( key, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get_with(3.4f, other_less())); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + } + + template + void test_rcu() + { + OrdList l; + test_with(l); + + static int const nLimit = 20; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); + + typename OrdList::exempt_ptr ep; + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->first == a[i] ); + CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); + + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->first == a[i] ); + CPPUNIT_CHECK( (*ep).second.m_val == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + ep = l.extract( a[i] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[0] ) ); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + float itm = a[i] + 0.3f; + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->first == a[i] ); + CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); + + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->first == a[i] ); + CPPUNIT_CHECK( ep->second.m_val == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less()) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( 3.14f, other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + } + } + + template + void nogc_test() + { + typedef typename OrdList::value_type value_type; + typedef typename OrdList::iterator iterator; + + { + OrdList l; + iterator it; + + CPPUNIT_ASSERT( l.empty() ); + + // insert / find test + CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + CPPUNIT_ASSERT( l.find_with( 50, lt() ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + + CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); + CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); + it = l.find( 150 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 150 ); + CPPUNIT_ASSERT( it.val().m_val == 1500 ); + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + it.val().m_val = 25; + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 25 ); + CPPUNIT_ASSERT( !l.empty() ); + + // ensure existing item + std::pair ensureResult; + ensureResult = l.ensure( 100 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 5; + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 5 ); + + CPPUNIT_ASSERT( !l.empty() ); + + // ensure new item + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 33; + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); + + // clear test + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); + + it = l.find(501); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 501 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + it = l.find(251); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 251 ); + CPPUNIT_ASSERT( it.val().m_val == 152 ); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); + + iter.val().m_val = i * 3; + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + it = l.find( i ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it.val().m_val == i * 3 ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); + // it.val().m_val = i * 3 ; // error: const-iterator + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + } + } + + template + void nogc_unord_test() + { + typedef typename UnordList::value_type value_type; + typedef typename UnordList::iterator iterator; + + { + UnordList l; + iterator it; + + CPPUNIT_ASSERT( l.empty() ); + + // insert / find test + CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + CPPUNIT_ASSERT( l.find_with( 50, eq() ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + + CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); + CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); + it = l.find( 150 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 150 ); + CPPUNIT_ASSERT( it.val().m_val == 1500 ); + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + it.val().m_val = 25; + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 25 ); + CPPUNIT_ASSERT( !l.empty() ); + + // ensure existing item + std::pair ensureResult; + ensureResult = l.ensure( 100 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 5; + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 5 ); + + CPPUNIT_ASSERT( !l.empty() ); + + // ensure new item + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 33; + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); + + // clear test + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); + + it = l.find(501); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 501 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + it = l.find(251); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 251 ); + CPPUNIT_ASSERT( it.val().m_val == 152 ); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); + + { + typename UnordList::iterator it( l.begin() ); + typename UnordList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename UnordList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); + + iter.val().m_val = i * 3; + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + it = l.find( i ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it.val().m_val == i * 3 ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); + + i = 0; + const UnordList& rl = l; + for ( typename UnordList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); + // it.val().m_val = i * 3 ; // error: const-iterator + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + } + } + + + void HP_cmp(); + void HP_less(); + void HP_cmpmix(); + void HP_ic(); + + void DHP_cmp(); + void DHP_less(); + void DHP_cmpmix(); + void DHP_ic(); + + void RCU_GPI_cmp(); + void RCU_GPI_less(); + void RCU_GPI_cmpmix(); + void RCU_GPI_ic(); + + void RCU_GPB_cmp(); + void RCU_GPB_less(); + void RCU_GPB_cmpmix(); + void RCU_GPB_ic(); + + void RCU_GPT_cmp(); + void RCU_GPT_less(); + void RCU_GPT_cmpmix(); + void RCU_GPT_ic(); + + void RCU_SHB_cmp(); + void RCU_SHB_less(); + void RCU_SHB_cmpmix(); + void RCU_SHB_ic(); + + void RCU_SHT_cmp(); + void RCU_SHT_less(); + void RCU_SHT_cmpmix(); + void RCU_SHT_ic(); + + void NOGC_cmp(); + void NOGC_less(); + void NOGC_cmpmix(); + void NOGC_ic(); + + void NOGC_cmp_unord(); + void NOGC_less_unord(); + void NOGC_equal_to_unord(); + void NOGC_cmpmix_unord(); + void NOGC_ic_unord(); + + CPPUNIT_TEST_SUITE(LazyKVListTestHeader) + CPPUNIT_TEST(HP_cmp) + CPPUNIT_TEST(HP_less) + CPPUNIT_TEST(HP_cmpmix) + CPPUNIT_TEST(HP_ic) + + CPPUNIT_TEST(DHP_cmp) + CPPUNIT_TEST(DHP_less) + CPPUNIT_TEST(DHP_cmpmix) + CPPUNIT_TEST(DHP_ic) + + CPPUNIT_TEST(RCU_GPI_cmp) + CPPUNIT_TEST(RCU_GPI_less) + CPPUNIT_TEST(RCU_GPI_cmpmix) + CPPUNIT_TEST(RCU_GPI_ic) + + CPPUNIT_TEST(RCU_GPB_cmp) + CPPUNIT_TEST(RCU_GPB_less) + CPPUNIT_TEST(RCU_GPB_cmpmix) + CPPUNIT_TEST(RCU_GPB_ic) + + CPPUNIT_TEST(RCU_GPT_cmp) + CPPUNIT_TEST(RCU_GPT_less) + CPPUNIT_TEST(RCU_GPT_cmpmix) + CPPUNIT_TEST(RCU_GPT_ic) + + CPPUNIT_TEST(RCU_SHB_cmp) + CPPUNIT_TEST(RCU_SHB_less) + CPPUNIT_TEST(RCU_SHB_cmpmix) + CPPUNIT_TEST(RCU_SHB_ic) + + CPPUNIT_TEST(RCU_SHT_cmp) + CPPUNIT_TEST(RCU_SHT_less) + CPPUNIT_TEST(RCU_SHT_cmpmix) + CPPUNIT_TEST(RCU_SHT_ic) + + CPPUNIT_TEST(NOGC_cmp) + CPPUNIT_TEST(NOGC_less) + CPPUNIT_TEST(NOGC_cmpmix) + CPPUNIT_TEST(NOGC_ic) + + CPPUNIT_TEST(NOGC_cmp_unord) + CPPUNIT_TEST(NOGC_less_unord) + CPPUNIT_TEST(NOGC_equal_to_unord) + CPPUNIT_TEST(NOGC_cmpmix_unord) + CPPUNIT_TEST(NOGC_ic_unord) + + CPPUNIT_TEST_SUITE_END() + }; + +} // namespace ordlist + +#endif // #ifndef CDSTEST_HDR_LAZY_KV_H \ No newline at end of file diff --git a/tests/test-hdr/list/hdr_lazy_kv_dhp.cpp b/tests/test-hdr/list/hdr_lazy_kv_dhp.cpp new file mode 100644 index 00000000..213e20c2 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_dhp.cpp @@ -0,0 +1,100 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include + +namespace ordlist { + namespace { + struct DHP_cmp_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } + void LazyKVListTestHeader::DHP_cmp() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::DHP_less() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::DHP_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::DHP_ic() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_kv_hp.cpp b/tests/test-hdr/list/hdr_lazy_kv_hp.cpp new file mode 100644 index 00000000..f459606f --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_hp.cpp @@ -0,0 +1,104 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include + +namespace ordlist { + namespace { + struct HP_cmp_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + + } + void LazyKVListTestHeader::HP_cmp() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::HP, + key_type, + value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::HP_less() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::HP_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::HP_ic() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::LazyKVListTestHeader); diff --git a/tests/test-hdr/list/hdr_lazy_kv_nogc.cpp b/tests/test-hdr/list/hdr_lazy_kv_nogc.cpp new file mode 100644 index 00000000..8894adc8 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_nogc.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + + } + void LazyKVListTestHeader::NOGC_cmp() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::nogc, + key_type, + value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::NOGC_less() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::NOGC_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::NOGC_ic() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + nogc_test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_kv_nogc_unord.cpp b/tests/test-hdr/list/hdr_lazy_kv_nogc_unord.cpp new file mode 100644 index 00000000..a914d4f4 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_nogc_unord.cpp @@ -0,0 +1,131 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + static const bool sort = false; + }; + + } + void LazyKVListTestHeader::NOGC_cmp_unord() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyKVList< cds::gc::nogc, + key_type, + value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + static const bool sort = false; + }; + } + void LazyKVListTestHeader::NOGC_less_unord() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_equal_to_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::eq equal_to; + static const bool sort = false; + }; + } + void LazyKVListTestHeader::NOGC_equal_to_unord() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_equal_to_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::equal_to< eq > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + typedef LazyKVListTestHeader::eq equal_to; + static const bool sort = false; + }; + } + void LazyKVListTestHeader::NOGC_cmpmix_unord() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + ,cc::opt::equal_to< eq > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::eq equal_to; + typedef cds::atomicity::item_counter item_counter; + static const bool sort = false; + }; + } + void LazyKVListTestHeader::NOGC_ic_unord() + { + // traits-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::equal_to< eq > + ,cc::opt::item_counter< cds::atomicity::item_counter > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_lazy_kv_rcu_gpb.cpp b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpb.cpp new file mode 100644 index 00000000..590a70dc --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpb.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; + + struct RCU_GPB_cmp_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } + void LazyKVListTestHeader::RCU_GPB_cmp() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPB_less() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPB_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::RCU_GPB_ic() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_kv_rcu_gpi.cpp b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpi.cpp new file mode 100644 index 00000000..7de7be4a --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpi.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; + + struct RCU_GPI_cmp_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } + void LazyKVListTestHeader::RCU_GPI_cmp() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPI_less() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPI_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::RCU_GPI_ic() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_kv_rcu_gpt.cpp b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpt.cpp new file mode 100644 index 00000000..d5192d97 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_rcu_gpt.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; + + struct RCU_GPT_cmp_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } + void LazyKVListTestHeader::RCU_GPT_cmp() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPT_less() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } + void LazyKVListTestHeader::RCU_GPT_cmpmix() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_ic_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyKVListTestHeader::RCU_GPT_ic() + { + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_kv_rcu_shb.cpp b/tests/test-hdr/list/hdr_lazy_kv_rcu_shb.cpp new file mode 100644 index 00000000..0c63b4ae --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_rcu_shb.cpp @@ -0,0 +1,122 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; + + struct RCU_SHB_cmp_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } +#endif + + void LazyKVListTestHeader::RCU_SHB_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_less_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } +#endif + + void LazyKVListTestHeader::RCU_SHB_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } +#endif + + void LazyKVListTestHeader::RCU_SHB_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_ic_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + + void LazyKVListTestHeader::RCU_SHB_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_lazy_kv_rcu_sht.cpp b/tests/test-hdr/list/hdr_lazy_kv_rcu_sht.cpp new file mode 100644 index 00000000..7debbeda --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_kv_rcu_sht.cpp @@ -0,0 +1,119 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy_kv.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; + + struct RCU_SHT_cmp_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + }; + } +#endif + void LazyKVListTestHeader::RCU_SHT_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_less_traits : public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + }; + } +#endif + void LazyKVListTestHeader::RCU_SHT_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::cmp compare; + typedef LazyKVListTestHeader::lt less; + }; + } +#endif + void LazyKVListTestHeader::RCU_SHT_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_ic_traits: public cc::lazy_list::traits + { + typedef LazyKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void LazyKVListTestHeader::RCU_SHT_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyKVList< rcu_type, key_type, value_type, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_nogc.cpp b/tests/test-hdr/list/hdr_lazy_nogc.cpp new file mode 100644 index 00000000..e4e07244 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_nogc.cpp @@ -0,0 +1,99 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } + void LazyListTestHeader::NOGC_cmp() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmp_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::NOGC_less() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_less_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::NOGC_cmpmix() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_ic_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::NOGC_ic() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_ic_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + nogc_test< opt_list >(); + } +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_nogc_unord.cpp b/tests/test-hdr/list/hdr_lazy_nogc_unord.cpp new file mode 100644 index 00000000..e6478879 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_nogc_unord.cpp @@ -0,0 +1,152 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_cmp_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmp_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_less_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_less_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_equal_to_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::equal_to equal_to; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_equal_to_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_equal_to_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::equal_to< equal_to > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_cmpmix_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + + namespace { + struct NOGC_equal_to_mix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + typedef LazyListTestHeader::equal_to equal_to; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_equal_to_mix_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_equal_to_mix_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + ,cc::opt::equal_to< equal_to > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + namespace { + struct NOGC_ic_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::equal_to equal_to; + typedef cds::atomicity::item_counter item_counter; + static const bool sort = false; + }; + } + void LazyListTestHeader::NOGC_ic_unord() + { + // traits-based version + typedef cc::LazyList< cds::gc::nogc, item, NOGC_ic_traits > list; + nogc_unord_test< list >(); + + // option-based version + typedef cc::LazyList< cds::gc::nogc, item, + cc::lazy_list::make_traits< + cc::opt::equal_to< equal_to > + ,cc::opt::item_counter< cds::atomicity::item_counter > + ,cc::opt::sort + >::type + > opt_list; + nogc_unord_test< opt_list >(); + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_lazy_rcu_gpb.cpp b/tests/test-hdr/list/hdr_lazy_rcu_gpb.cpp new file mode 100644 index 00000000..da60916c --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_rcu_gpb.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; + + struct RCU_GPB_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } + void LazyListTestHeader::RCU_GPB_cmp() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPB_less() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPB_cmpmix() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_ic_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::RCU_GPB_ic() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_rcu_gpi.cpp b/tests/test-hdr/list/hdr_lazy_rcu_gpi.cpp new file mode 100644 index 00000000..6b892a1c --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_rcu_gpi.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; + + struct RCU_GPI_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } + void LazyListTestHeader::RCU_GPI_cmp() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPI_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPI_less() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPI_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPI_cmpmix() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPI_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_ic_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::RCU_GPI_ic() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPI_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_rcu_gpt.cpp b/tests/test-hdr/list/hdr_lazy_rcu_gpt.cpp new file mode 100644 index 00000000..c9795664 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_rcu_gpt.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; + + struct RCU_GPT_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } + void LazyListTestHeader::RCU_GPT_cmp() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPT_less() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_cmpmix_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } + void LazyListTestHeader::RCU_GPT_cmpmix() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_ic_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void LazyListTestHeader::RCU_GPT_ic() + { + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_GPT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_rcu_shb.cpp b/tests/test-hdr/list/hdr_lazy_rcu_shb.cpp new file mode 100644 index 00000000..4f9cb0e3 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_rcu_shb.cpp @@ -0,0 +1,119 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; + + struct RCU_SHB_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } +#endif + void LazyListTestHeader::RCU_SHB_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } +#endif + void LazyListTestHeader::RCU_SHB_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } +#endif + void LazyListTestHeader::RCU_SHB_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_ic_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void LazyListTestHeader::RCU_SHB_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_lazy_rcu_sht.cpp b/tests/test-hdr/list/hdr_lazy_rcu_sht.cpp new file mode 100644 index 00000000..3336fca5 --- /dev/null +++ b/tests/test-hdr/list/hdr_lazy_rcu_sht.cpp @@ -0,0 +1,119 @@ +//$$CDS-header$$ + +#include "list/hdr_lazy.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; + + struct RCU_SHT_cmp_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + }; + } +#endif + void LazyListTestHeader::RCU_SHT_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_less_traits : public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + }; + } +#endif + void LazyListTestHeader::RCU_SHT_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_cmpmix_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::cmp compare; + typedef LazyListTestHeader::lt less; + }; + } +#endif + void LazyListTestHeader::RCU_SHT_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_ic_traits: public cc::lazy_list::traits + { + typedef LazyListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void LazyListTestHeader::RCU_SHT_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::LazyList< rcu_type, item, RCU_SHT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::LazyList< rcu_type, item, + cc::lazy_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael.h b/tests/test-hdr/list/hdr_michael.h new file mode 100644 index 00000000..c37eaa8e --- /dev/null +++ b/tests/test-hdr/list/hdr_michael.h @@ -0,0 +1,820 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_MICHAEL_H +#define CDSTEST_HDR_MICHAEL_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace cc = cds::container; + namespace co = cds::container::opt; + + class MichaelListTestHeader: public CppUnitMini::TestCase + { + public: + struct stat { + int nEnsureExistsCall; + int nEnsureNewCall; + + stat() + { + nEnsureExistsCall + = nEnsureNewCall + = 0; + } + }; + + struct item { + int nKey; + int nVal; + + stat s; + + item(int key) + : nKey( key ) + , nVal( key * 2 ) + , s() + {} + + item(int key, int val) + : nKey( key ) + , nVal(val) + , s() + {} + + item( const item& v ) + : nKey( v.nKey ) + , nVal( v.nVal ) + , s() + {} + + int key() const + { + return nKey; + } + }; + + template + struct lt + { + 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; + } + }; + + struct insert_functor { + void operator ()( item& i ) + { + i.nVal = i.nKey * 1033; + } + }; + struct dummy_insert_functor { + void operator ()( item& /*i*/ ) + { + // This functor should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_functor should not be called", __FILE__, __LINE__ ); + } + }; + + struct erase_functor { + unsigned int nEraseCall; + + erase_functor() + : nEraseCall(0) + {} + + void operator()( item const& /*i*/) + { + ++nEraseCall; + } + }; + + static void insert_function( item& i ) + { + i.nVal = i.nKey * 1024; + } + static void dummy_insert_function( item& /*i*/ ) + { + // This function should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_function should not be called", __FILE__, __LINE__ ); + } + + + struct check_value { + unsigned int m_nMultiplier; + + check_value( unsigned int nMultiplier ) + : m_nMultiplier( nMultiplier ) + {} + + check_value( const check_value& s ) + : m_nMultiplier( s.m_nMultiplier ) + {} + + void operator()( item& i, int ) + { + CPPUNIT_ASSERT_CURRENT( int(i.nKey * m_nMultiplier) == i.nVal ); + } + }; + + struct check_exact_value { + int m_nExpected; + + check_exact_value( int nExpected ) + : m_nExpected( nExpected ) + {} + + check_exact_value( check_exact_value const& s) + : m_nExpected( s.m_nExpected ) + {} + + void operator()( item& i, int ) + { + CPPUNIT_ASSERT_CURRENT( i.nVal == m_nExpected ); + } + }; + + struct dummy_check_value { + void operator()( item& /*i*/, int ) + { + // This functor should not be called + TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_check_value should not be called", __FILE__, __LINE__ ); + } + }; + + struct ensure_functor { + void operator()( bool /*bNew*/, item& i, int /*n*/ ) + { + i.nVal = i.nKey * 1024; + } + }; + + static void ensure_func( bool /*bNew*/, item& i, int n ) + { + i.nVal = n * 1033; + } + + struct other_item + { + int nKey; + + other_item() + {} + + other_item(int n) + : nKey(n) + {} + }; + + struct other_less + { + template + bool operator()( T1 const& t1, T2 const& t2 ) const + { + return t1.nKey < t2.nKey; + } + }; + + protected: + template + void test_with( OrdList& l ) + { + typedef typename OrdList::value_type value_type; + + // The list should be empty + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.insert( 50 ) ); + CPPUNIT_ASSERT( l.insert( item( 25 )) ); + CPPUNIT_ASSERT( l.insert( item( 100 )) ); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.insert( 50 ) ); + CPPUNIT_ASSERT( !l.insert( item( 100 )) ); + + // clear test + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + // and now the list is empty + CPPUNIT_ASSERT( l.empty() ); + + // Test insert with functor + + CPPUNIT_ASSERT( l.insert( 100, insert_functor() ) ); + // passed by ref + { + insert_functor f; + CPPUNIT_ASSERT( l.insert( item( 25 ), std::ref( f ) ) ); + CPPUNIT_ASSERT( !l.insert( item( 100 ), std::ref( f ) ) ); + } + // Test insert with function + CPPUNIT_ASSERT( l.insert( 50, insert_function )); + CPPUNIT_ASSERT( !l.insert( 25, dummy_insert_function )); + CPPUNIT_ASSERT( !l.insert( 100, dummy_insert_functor() )); + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + + // Check inserted values + { + int i; + i = 100; + CPPUNIT_ASSERT( l.find( 100 )); + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + { + check_value f(1033); + i = 25; + CPPUNIT_ASSERT( l.find_with( 25, lt() )); + CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( f ) ) ); + } + i = 50; + CPPUNIT_ASSERT( l.find( 50 )); + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + + i = 10; + CPPUNIT_ASSERT( !l.find_with( 10, lt() )); + CPPUNIT_ASSERT( !l.find_with( i, lt(), dummy_check_value() )); + i = 75; + CPPUNIT_ASSERT( !l.find( 75 )); + CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); + i = 150; + CPPUNIT_ASSERT( !l.find( 150 )); + CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); + } + + // The list should not be empty + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + // and now the list is empty + CPPUNIT_ASSERT( l.empty() ); + + // Ensure test + { + std::pair ensureResult; + ensure_functor f; + ensureResult = l.ensure( 100, ensure_functor() ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + ensureResult = l.ensure( 200, std::ref( f ) ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + ensureResult = l.ensure( 50, ensure_func ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( ensureResult.second ); + + int i; + i = 100; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + i = 50; + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + i = 200; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + + // ensure existing key + ensureResult = l.ensure( 200, ensure_func ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( !ensureResult.second ); + i = 200; + CPPUNIT_ASSERT( l.find( i, check_value(1033) )); + + ensureResult = l.ensure( 50, ensure_functor() ); + CPPUNIT_ASSERT( ensureResult.first ); + CPPUNIT_ASSERT( !ensureResult.second ); + i = 50; + CPPUNIT_ASSERT( l.find( i, check_value(1024) )); + } + + // erase test (list: 50, 100, 200) + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.insert(160)); + CPPUNIT_ASSERT( l.insert(250)); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.erase( 150 )); + + CPPUNIT_ASSERT( l.erase( 100 )); + CPPUNIT_ASSERT( !l.erase( 100 )); + + CPPUNIT_ASSERT( l.erase_with( 200, lt() )); + CPPUNIT_ASSERT( !l.erase_with( 200, lt() )); + + { + erase_functor ef; + CPPUNIT_ASSERT( ef.nEraseCall == 0 ); + CPPUNIT_ASSERT( l.erase_with( 160, lt(), std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 1 ); + CPPUNIT_ASSERT( !l.erase_with( 160, lt(), std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 1 ); + + CPPUNIT_ASSERT( l.erase( 250, std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 2 ); + CPPUNIT_ASSERT( !l.erase( 250, std::ref(ef) )); + CPPUNIT_ASSERT( ef.nEraseCall == 2 ); + } + + CPPUNIT_ASSERT( l.erase( 50 )); + CPPUNIT_ASSERT( !l.erase( 50 )); + + CPPUNIT_ASSERT( l.empty() ); + + // clear empty list + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + { + int i; + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) ); + CPPUNIT_ASSERT( l.emplace( 251, 152 )); + CPPUNIT_ASSERT( l.emplace( item( 1001 )) ); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); + CPPUNIT_ASSERT( !l.emplace( 251, 10) ); + + i = 501; + CPPUNIT_ASSERT( l.find( i, check_exact_value(501*2) )); + i = 251; + CPPUNIT_ASSERT( l.find( i, check_exact_value(152) )); + i = 1001; + CPPUNIT_ASSERT( l.find( i, check_exact_value(1001*2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i) ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { + it->nVal = i * 2; + CPPUNIT_ASSERT( it->nKey == i ); + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.find( i, check_value(2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i) ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { + // it->nVal = i * 2 ; // not! + CPPUNIT_ASSERT( it->nKey == i ); + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.find( i, check_value(2) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + } + + template + void test() + { + typedef typename OrdList::guarded_ptr guarded_ptr; + typedef typename OrdList::value_type value_type; + + OrdList l; + test_with(l); + + static int const nLimit = 20; + int arr[nLimit]; + for ( int i = 0; i < nLimit; i++ ) + arr[i] = i; + std::random_shuffle( arr, arr + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i] ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + + gp = l.get( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey * 2 ); + gp.release(); + + gp = l.extract( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey*2 ); + gp.release(); + + gp = l.get( nKey ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( nKey)); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get(arr[0])); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( arr[0])); + CPPUNIT_CHECK( gp.empty()); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i] ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + other_item key( nKey ); + + gp = l.get_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey * 2 ); + gp.release(); + + gp = l.extract_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->nKey == nKey ); + CPPUNIT_CHECK( gp->nVal == nKey*2 ); + gp.release(); + + gp = l.get_with( key, other_less() ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( key, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less())); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less())); + CPPUNIT_CHECK( gp.empty()); + } + } + + template + void test_rcu() + { + OrdList l; + test_with(l); + + static int const nLimit = 20; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( a[i] ) ); + + typename OrdList::exempt_ptr ep; + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + ep = l.extract( a[i] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[0] ) ); + CPPUNIT_CHECK( ep.empty() ); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( a[i] ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + other_item itm( a[i] ); + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->nKey == a[i] ); + CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); + + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->nKey == a[i] ); + CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + } + + } + + template + void nogc_test() + { + typedef OrdList list; + typedef typename list::value_type value_type; + typedef std::pair ensure_result; + + typename list::iterator it; + + list l; + CPPUNIT_ASSERT( l.empty() ); + CPPUNIT_ASSERT( l.insert(50) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + + ensure_result eres = l.ensure( item(100, 33) ); + CPPUNIT_ASSERT( eres.second ); + CPPUNIT_ASSERT( eres.first != l.end() ); + CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); + + CPPUNIT_ASSERT( l.insert(100) == l.end() ); + eres = l.ensure( item(50, 33) ); + CPPUNIT_ASSERT( !eres.second ); + CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); + eres.first->nVal = 63; + + it = l.find( 33 ); + CPPUNIT_ASSERT( it == l.end() ); + + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 50 ); + CPPUNIT_ASSERT( it->nVal == 63 ); + + it = l.find_with( 100, lt() ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 100 ); + CPPUNIT_ASSERT( it->nVal == 33 ); + + it = l.find( 150 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 150 ); + CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); + + CPPUNIT_ASSERT( !l.empty() ); + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end() ); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end() ); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end() ); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end() ); + + it = l.find( 501 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 501 ); + CPPUNIT_ASSERT( it->nVal == 501 * 2 ); + + it = l.find( 251 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 251 ); + CPPUNIT_ASSERT( it->nVal == 152 ); + + it = l.find( 1001 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it->nKey == 1001 ); + CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + void HP_cmp(); + void HP_less(); + void HP_cmpmix(); + void HP_ic(); + + void DHP_cmp(); + void DHP_less(); + void DHP_cmpmix(); + void DHP_ic(); + + void RCU_GPI_cmp(); + void RCU_GPI_less(); + void RCU_GPI_cmpmix(); + void RCU_GPI_ic(); + + void RCU_GPB_cmp(); + void RCU_GPB_less(); + void RCU_GPB_cmpmix(); + void RCU_GPB_ic(); + + void RCU_GPT_cmp(); + void RCU_GPT_less(); + void RCU_GPT_cmpmix(); + void RCU_GPT_ic(); + + void RCU_SHB_cmp(); + void RCU_SHB_less(); + void RCU_SHB_cmpmix(); + void RCU_SHB_ic(); + + void RCU_SHT_cmp(); + void RCU_SHT_less(); + void RCU_SHT_cmpmix(); + void RCU_SHT_ic(); + + void NOGC_cmp(); + void NOGC_less(); + void NOGC_cmpmix(); + void NOGC_ic(); + + CPPUNIT_TEST_SUITE(MichaelListTestHeader) + CPPUNIT_TEST(HP_cmp) + CPPUNIT_TEST(HP_less) + CPPUNIT_TEST(HP_cmpmix) + CPPUNIT_TEST(HP_ic) + + CPPUNIT_TEST(DHP_cmp) + CPPUNIT_TEST(DHP_less) + CPPUNIT_TEST(DHP_cmpmix) + CPPUNIT_TEST(DHP_ic) + + CPPUNIT_TEST(RCU_GPI_cmp) + CPPUNIT_TEST(RCU_GPI_less) + CPPUNIT_TEST(RCU_GPI_cmpmix) + CPPUNIT_TEST(RCU_GPI_ic) + + CPPUNIT_TEST(RCU_GPB_cmp) + CPPUNIT_TEST(RCU_GPB_less) + CPPUNIT_TEST(RCU_GPB_cmpmix) + CPPUNIT_TEST(RCU_GPB_ic) + + CPPUNIT_TEST(RCU_GPT_cmp) + CPPUNIT_TEST(RCU_GPT_less) + CPPUNIT_TEST(RCU_GPT_cmpmix) + CPPUNIT_TEST(RCU_GPT_ic) + + CPPUNIT_TEST(RCU_SHB_cmp) + CPPUNIT_TEST(RCU_SHB_less) + CPPUNIT_TEST(RCU_SHB_cmpmix) + CPPUNIT_TEST(RCU_SHB_ic) + + CPPUNIT_TEST(RCU_SHT_cmp) + CPPUNIT_TEST(RCU_SHT_less) + CPPUNIT_TEST(RCU_SHT_cmpmix) + CPPUNIT_TEST(RCU_SHT_ic) + + CPPUNIT_TEST(NOGC_cmp) + CPPUNIT_TEST(NOGC_less) + CPPUNIT_TEST(NOGC_cmpmix) + CPPUNIT_TEST(NOGC_ic) + CPPUNIT_TEST_SUITE_END() + }; + +} // namespace ordlist + +#endif // #ifndef CDSTEST_HDR_MICHAEL_H diff --git a/tests/test-hdr/list/hdr_michael_dhp.cpp b/tests/test-hdr/list/hdr_michael_dhp.cpp new file mode 100644 index 00000000..17f54406 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_dhp.cpp @@ -0,0 +1,100 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include + +namespace ordlist { + namespace { + struct DHP_cmp_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } + void MichaelListTestHeader::DHP_cmp() + { + // traits-based version + typedef cc::MichaelList< cds::gc::DHP, item, DHP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::DHP, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_less_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::DHP_less() + { + // traits-based version + typedef cc::MichaelList< cds::gc::DHP, item, DHP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::DHP, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::DHP_cmpmix() + { + // traits-based version + typedef cc::MichaelList< cds::gc::DHP, item, DHP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::DHP, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_ic_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::DHP_ic() + { + // traits-based version + typedef cc::MichaelList< cds::gc::DHP, item, DHP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::DHP, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_hp.cpp b/tests/test-hdr/list/hdr_michael_hp.cpp new file mode 100644 index 00000000..e981e3d0 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_hp.cpp @@ -0,0 +1,102 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include + +namespace ordlist { + namespace { + struct HP_cmp_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + + } + void MichaelListTestHeader::HP_cmp() + { + // traits-based version + typedef cc::MichaelList< cds::gc::HP, item, HP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::HP, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_less_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::HP_less() + { + // traits-based version + typedef cc::MichaelList< cds::gc::HP, item, HP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::HP, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::HP_cmpmix() + { + // traits-based version + typedef cc::MichaelList< cds::gc::HP, item, HP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::HP, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_ic_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::HP_ic() + { + // traits-based version + typedef cc::MichaelList< cds::gc::HP, item, HP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::HP, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::MichaelListTestHeader); diff --git a/tests/test-hdr/list/hdr_michael_kv.h b/tests/test-hdr/list/hdr_michael_kv.h new file mode 100644 index 00000000..4f467b31 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv.h @@ -0,0 +1,743 @@ +//$$CDS-header$$ + +#ifndef CDSTEST_HDR_MICHAEL_KV_H +#define CDSTEST_HDR_MICHAEL_KV_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace ordlist { + namespace cc = cds::container; + namespace co = cds::container::opt; + + class MichaelKVListTestHeader: public CppUnitMini::TestCase + { + public: + typedef int key_type; + struct value_type { + int m_val; + + value_type() + : m_val(0) + {} + + value_type( int n ) + : m_val( n ) + {} + }; + + template + struct lt + { + bool operator ()(const T& v1, const T& v2 ) const + { + return v1 < v2; + } + }; + + template + struct cmp { + int operator ()(const T& v1, const T& v2 ) const + { + if ( v1 < v2 ) + return -1; + return v1 > v2 ? 1 : 0; + } + }; + + struct check_value { + int m_nExpected; + + check_value( int nExpected ) + : m_nExpected( nExpected ) + {} + + template + void operator ()( T& pair ) + { + CPPUNIT_ASSERT_CURRENT( pair.second.m_val == m_nExpected ); + } + }; + + struct insert_functor { + template + void operator()( T& pair ) + { + pair.second.m_val = pair.first * 10; + } + }; + + struct ensure_functor { + template + void operator()( bool /*bNew*/, T& pair ) + { + pair.second.m_val = pair.first * 50; + } + }; + + struct erase_functor { + int nKey; + int nVal; + + erase_functor() + : nKey(0) + , nVal(0) + {} + + template + void operator()( T& i ) + { + nKey = i.first; + nVal = i.second.m_val; + } + }; + + typedef float other_key; + struct other_less { + bool operator()( float f, int i ) const + { + return int(f) < i; + } + bool operator()( int i, float f ) const + { + return i < int(f); + } + }; + + protected: + template + void test_with( OrdList& l) + { + typedef typename OrdList::value_type value_type; + + typename OrdList::iterator itTest; + typename OrdList::const_iterator citTest; + + CPPUNIT_ASSERT( l.empty() ); + + // insert / find test + CPPUNIT_ASSERT( !l.find( 100 )); + CPPUNIT_ASSERT( l.insert( 100 )); + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.find( 100 )); + + check_value chk(0); + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + + CPPUNIT_ASSERT( !l.find_with( 50, lt() )); + CPPUNIT_ASSERT( l.insert( 50, 500 )); + CPPUNIT_ASSERT( l.find_with( 50, lt() )); + CPPUNIT_ASSERT( !l.insert( 50, 5 )); + chk.m_nExpected = 500; + CPPUNIT_ASSERT( l.find_with( 50, lt(), std::ref( chk ) ) ); + chk.m_nExpected = 0; + CPPUNIT_ASSERT( l.find_with( 100, lt(), std::ref( chk ) ) ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( !l.find( 150 )); + CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() )); + CPPUNIT_ASSERT( l.find( 150 )); + chk.m_nExpected = 1500; + CPPUNIT_ASSERT( l.find( 150, std::ref( chk ) ) ); + chk.m_nExpected = 0; + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + chk.m_nExpected = 500; + CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); + CPPUNIT_ASSERT( !l.empty() ); + + // erase test + + CPPUNIT_ASSERT( !l.erase( 500 )); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.find( 50 )); + { + erase_functor ef; + l.erase( 50, std::ref( ef ) ); + CPPUNIT_ASSERT( ef.nKey == 50 ); + CPPUNIT_ASSERT( ef.nVal == 500 ); + } + CPPUNIT_ASSERT( !l.find( 50 )); + + // ensure test + std::pair bEnsureResult; + bEnsureResult = l.ensure( 100, ensure_functor() ); + CPPUNIT_ASSERT( bEnsureResult.first ); + CPPUNIT_ASSERT( !bEnsureResult.second ); + chk.m_nExpected = 5000; + CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); + + { + ensure_functor ef; + bEnsureResult = l.ensure( 50, std::ref( ef ) ); + } + CPPUNIT_ASSERT( bEnsureResult.first ); + CPPUNIT_ASSERT( bEnsureResult.second ); + chk.m_nExpected = 2500; + CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); + + // erase test + CPPUNIT_ASSERT( !l.empty() ); + CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() )); + CPPUNIT_ASSERT( l.insert( 25 )); + CPPUNIT_ASSERT( l.erase( 100 )); + CPPUNIT_ASSERT( l.erase( 150 )); + { + erase_functor ef; + CPPUNIT_ASSERT( l.erase_with( 200, lt(), std::ref(ef)) ); + CPPUNIT_ASSERT( ef.nKey == 200 ); + CPPUNIT_ASSERT( ef.nVal == 2000 ); + } + CPPUNIT_ASSERT( l.erase_with( 25, lt())) + CPPUNIT_ASSERT( l.erase( 50 )); + CPPUNIT_ASSERT( l.empty() ); + + // clear empty list + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) ); + CPPUNIT_ASSERT( l.emplace( 251, 152 )); + + // insert failed - such key exists + CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); + CPPUNIT_ASSERT( !l.emplace( 251, 10) ); + + check_value cv(0); + CPPUNIT_ASSERT( l.find( 501, std::ref(cv) )); + cv.m_nExpected = 152; + CPPUNIT_ASSERT( l.find( 251, std::ref(cv) )); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 2 ) ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it->first == i ); + CPPUNIT_ASSERT( (*it).first == i ); + + CPPUNIT_ASSERT( it.val().m_val == i * 2 ); + CPPUNIT_ASSERT( it->second.m_val == i * 2 ); + CPPUNIT_ASSERT( (*it).second.m_val == i * 2 ); + it.val().m_val = i * 3; + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + chk.m_nExpected = i * 3; + CPPUNIT_ASSERT( l.find( i, std::ref( chk ) ) ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 7) ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it->first == i ); + CPPUNIT_ASSERT( (*it).first == i ); + + CPPUNIT_ASSERT( it.val().m_val == i * 7 ); + CPPUNIT_ASSERT( it->second.m_val == i * 7 ); + CPPUNIT_ASSERT( (*it).second.m_val == i * 7 ); + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + chk.m_nExpected = i * 7; + CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( chk ) ) ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + } + + template + void test() + { + OrdList l; + test_with(l); + + typedef typename OrdList::guarded_ptr guarded_ptr; + + static int const nLimit = 20; + int arr[nLimit]; + for ( int i = 0; i < nLimit; i++ ) + arr[i] = i; + std::random_shuffle( arr, arr + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i], arr[i] * 2 ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + + gp = l.get( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); + gp.release(); + CPPUNIT_CHECK( gp.empty() ); + + gp = l.extract( nKey ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); + gp.release(); + + gp = l.get( nKey ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( nKey)); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get(arr[0])); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract( arr[0])); + CPPUNIT_CHECK( gp.empty()); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) + l.insert( arr[i], arr[i] * 2 ); + { + guarded_ptr gp; + for ( int i = 0; i < nLimit; ++i ) { + int nKey = arr[i]; + other_key key = float(nKey + 0.3); + + gp = l.get_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); + gp.release(); + + gp = l.extract_with( key, other_less() ); + CPPUNIT_ASSERT( gp ); + CPPUNIT_ASSERT( !gp.empty()); + CPPUNIT_CHECK( gp->first == nKey ); + CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); + gp.release(); + + gp = l.get_with( key, other_less() ); + CPPUNIT_CHECK( !gp ); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( key, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + CPPUNIT_ASSERT( l.empty()); + CPPUNIT_CHECK( !l.get_with( 3.4f, other_less())); + CPPUNIT_CHECK( gp.empty()); + CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less())); + CPPUNIT_CHECK( gp.empty()); + } + } + + template + void test_rcu() + { + OrdList l; + test_with(l); + + static int const nLimit = 20; + + typedef typename OrdList::rcu_lock rcu_lock; + typedef typename OrdList::value_type value_type; + typedef typename OrdList::gc rcu_type; + + { + int a[nLimit]; + for (int i = 0; i < nLimit; ++i) + a[i]=i; + std::random_shuffle( a, a + nLimit ); + + // extract/get + for ( int i = 0; i < nLimit; ++i ) + CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); + + typename OrdList::exempt_ptr ep; + + for ( int i = 0; i < nLimit; ++i ) { + { + rcu_lock lock; + value_type * pGet = l.get( a[i] ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->first == a[i] ); + CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); + + ep = l.extract( a[i] ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->first == a[i] ); + CPPUNIT_CHECK( (*ep).second.m_val == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); + ep = l.extract( a[i] ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); + CPPUNIT_CHECK( !l.extract( a[0] ) ); + CPPUNIT_CHECK( ep.empty() ); + } + + // extract_with/get_with + for ( int i = 0; i < nLimit; ++i ) { + CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); + } + + for ( int i = 0; i < nLimit; ++i ) { + float itm = a[i] + 0.3f; + { + rcu_lock lock; + value_type * pGet = l.get_with( itm, other_less() ); + CPPUNIT_ASSERT( pGet != nullptr ); + CPPUNIT_CHECK( pGet->first == a[i] ); + CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); + + ep = l.extract_with( itm, other_less() ); + CPPUNIT_ASSERT( ep ); + CPPUNIT_ASSERT( !ep.empty() ); + CPPUNIT_CHECK( ep->first == a[i] ); + CPPUNIT_CHECK( ep->second.m_val == a[i] * 2 ); + } + ep.release(); + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); + ep = l.extract_with( itm, other_less() ); + CPPUNIT_CHECK( !ep ); + CPPUNIT_CHECK( ep.empty() ); + } + } + CPPUNIT_ASSERT( l.empty() ); + + { + rcu_lock lock; + CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == nullptr ); + CPPUNIT_CHECK( !l.extract_with( 3.14f, other_less() )); + CPPUNIT_CHECK( ep.empty() ); + } + } + + } + + template + void nogc_test() + { + typedef typename OrdList::value_type value_type; + typedef typename OrdList::iterator iterator; + + { + OrdList l; + iterator it; + + CPPUNIT_ASSERT( l.empty() ); + + // insert / find test + CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); + CPPUNIT_ASSERT( !l.empty() ); + it = l.find_with( 100, lt() ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + CPPUNIT_ASSERT( l.find_with( 50, lt() ) == l.end() ); + CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + + CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + CPPUNIT_ASSERT( !l.empty() ); + + CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); + CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); + it = l.find( 150 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 150 ); + CPPUNIT_ASSERT( it.val().m_val == 1500 ); + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 500 ); + it.val().m_val = 25; + it = l.find( 50 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 50 ); + CPPUNIT_ASSERT( it.val().m_val == 25 ); + CPPUNIT_ASSERT( !l.empty() ); + + // ensure existing item + std::pair ensureResult; + ensureResult = l.ensure( 100 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 5; + it = l.find( 100 ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == 100 ); + CPPUNIT_ASSERT( it.val().m_val == 5 ); + + CPPUNIT_ASSERT( !l.empty() ); + + // ensure new item + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); + ensureResult.first.val().m_val = 33; + ensureResult = l.ensure( 1000 ); + CPPUNIT_ASSERT( !ensureResult.second ); + CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); + CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); + + // clear test + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // insert test + CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); + + // insert failed - such key exists + CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); + CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); + + it = l.find( 501 ); + CPPUNIT_ASSERT( it != l.end()); + CPPUNIT_ASSERT( it.key() == 501 ); + CPPUNIT_ASSERT( it.val().m_val == 0 ); + + it = l.find( 251 ); + CPPUNIT_ASSERT( it != l.end()); + CPPUNIT_ASSERT( it.key() == 251 ); + CPPUNIT_ASSERT( it.val().m_val == 152 ); + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Iterator test + { + int nCount = 100; + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); + + { + typename OrdList::iterator it( l.begin() ); + typename OrdList::const_iterator cit( l.cbegin() ); + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++it; + CPPUNIT_CHECK( it != cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + ++cit; + CPPUNIT_CHECK( it == cit ); + CPPUNIT_CHECK( it != l.end() ); + CPPUNIT_CHECK( it != l.cend() ); + CPPUNIT_CHECK( cit != l.end() ); + CPPUNIT_CHECK( cit != l.cend() ); + } + + int i = 0; + for ( typename OrdList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); + + iter.val().m_val = i * 3; + } + + // Check that we have visited all items + for ( int i = 0; i < nCount; ++i ) { + it = l.find( i ); + CPPUNIT_ASSERT( it != l.end() ); + CPPUNIT_ASSERT( it.key() == i ); + CPPUNIT_ASSERT( it.val().m_val == i * 3 ); + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + + // Const iterator + for ( int i = 0; i < nCount; ++i ) + CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); + + i = 0; + const OrdList& rl = l; + for ( typename OrdList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { + CPPUNIT_ASSERT( iter.key() == i ); + CPPUNIT_ASSERT( iter->first == i ); + CPPUNIT_ASSERT( (*iter).first == i ); + + CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); + CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); + CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); + + // it.val().m_val = i * 3 ; // error: const-iterator + } + + l.clear(); + CPPUNIT_ASSERT( l.empty() ); + } + + } + } + + void HP_cmp(); + void HP_less(); + void HP_cmpmix(); + void HP_ic(); + + void DHP_cmp(); + void DHP_less(); + void DHP_cmpmix(); + void DHP_ic(); + + void RCU_GPI_cmp(); + void RCU_GPI_less(); + void RCU_GPI_cmpmix(); + void RCU_GPI_ic(); + + void RCU_GPB_cmp(); + void RCU_GPB_less(); + void RCU_GPB_cmpmix(); + void RCU_GPB_ic(); + + void RCU_GPT_cmp(); + void RCU_GPT_less(); + void RCU_GPT_cmpmix(); + void RCU_GPT_ic(); + + void RCU_SHB_cmp(); + void RCU_SHB_less(); + void RCU_SHB_cmpmix(); + void RCU_SHB_ic(); + + void RCU_SHT_cmp(); + void RCU_SHT_less(); + void RCU_SHT_cmpmix(); + void RCU_SHT_ic(); + + void NOGC_cmp(); + void NOGC_less(); + void NOGC_cmpmix(); + void NOGC_ic(); + + CPPUNIT_TEST_SUITE(MichaelKVListTestHeader) + CPPUNIT_TEST(HP_cmp) + CPPUNIT_TEST(HP_less) + CPPUNIT_TEST(HP_cmpmix) + CPPUNIT_TEST(HP_ic) + + CPPUNIT_TEST(DHP_cmp) + CPPUNIT_TEST(DHP_less) + CPPUNIT_TEST(DHP_cmpmix) + CPPUNIT_TEST(DHP_ic) + + CPPUNIT_TEST(RCU_GPI_cmp) + CPPUNIT_TEST(RCU_GPI_less) + CPPUNIT_TEST(RCU_GPI_cmpmix) + CPPUNIT_TEST(RCU_GPI_ic) + + CPPUNIT_TEST(RCU_GPB_cmp) + CPPUNIT_TEST(RCU_GPB_less) + CPPUNIT_TEST(RCU_GPB_cmpmix) + CPPUNIT_TEST(RCU_GPB_ic) + + CPPUNIT_TEST(RCU_GPT_cmp) + CPPUNIT_TEST(RCU_GPT_less) + CPPUNIT_TEST(RCU_GPT_cmpmix) + CPPUNIT_TEST(RCU_GPT_ic) + + CPPUNIT_TEST(RCU_SHB_cmp) + CPPUNIT_TEST(RCU_SHB_less) + CPPUNIT_TEST(RCU_SHB_cmpmix) + CPPUNIT_TEST(RCU_SHB_ic) + + CPPUNIT_TEST(RCU_SHT_cmp) + CPPUNIT_TEST(RCU_SHT_less) + CPPUNIT_TEST(RCU_SHT_cmpmix) + CPPUNIT_TEST(RCU_SHT_ic) + + CPPUNIT_TEST(NOGC_cmp) + CPPUNIT_TEST(NOGC_less) + CPPUNIT_TEST(NOGC_cmpmix) + CPPUNIT_TEST(NOGC_ic) + CPPUNIT_TEST_SUITE_END() + }; + +} // namespace ordlist + +#endif // #ifndef CDSTEST_HDR_MICHAEL_KV_H diff --git a/tests/test-hdr/list/hdr_michael_kv_dhp.cpp b/tests/test-hdr/list/hdr_michael_kv_dhp.cpp new file mode 100644 index 00000000..300735e0 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_dhp.cpp @@ -0,0 +1,100 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include + +namespace ordlist { + namespace { + struct DHP_cmp_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } + void MichaelKVListTestHeader::DHP_cmp() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_less_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::DHP_less() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::DHP_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct DHP_ic_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::DHP_ic() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_kv_hp.cpp b/tests/test-hdr/list/hdr_michael_kv_hp.cpp new file mode 100644 index 00000000..87076177 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_hp.cpp @@ -0,0 +1,104 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include + +namespace ordlist { + namespace { + struct HP_cmp_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + + } + void MichaelKVListTestHeader::HP_cmp() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_cmp_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::HP, + key_type, + value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_less_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::HP_less() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_less_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::HP_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test< opt_list >(); + } + + namespace { + struct HP_ic_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::HP_ic() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_ic_traits > list; + test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test< opt_list >(); + } + +} // namespace ordlist + +CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::MichaelKVListTestHeader); diff --git a/tests/test-hdr/list/hdr_michael_kv_nogc.cpp b/tests/test-hdr/list/hdr_michael_kv_nogc.cpp new file mode 100644 index 00000000..a86dcc64 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_nogc.cpp @@ -0,0 +1,103 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + + } + void MichaelKVListTestHeader::NOGC_cmp() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::nogc, + key_type, + value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::NOGC_less() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::NOGC_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_ic_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::NOGC_ic() + { + // traits-based version + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + nogc_test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_kv_rcu_gpb.cpp b/tests/test-hdr/list/hdr_michael_kv_rcu_gpb.cpp new file mode 100644 index 00000000..e43a1c24 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_rcu_gpb.cpp @@ -0,0 +1,102 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; + struct RCU_GPB_cmp_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } + void MichaelKVListTestHeader::RCU_GPB_cmp() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_less_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPB_less() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPB_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_ic_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::RCU_GPB_ic() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_kv_rcu_gpi.cpp b/tests/test-hdr/list/hdr_michael_kv_rcu_gpi.cpp new file mode 100644 index 00000000..e81bf754 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_rcu_gpi.cpp @@ -0,0 +1,102 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; + struct RCU_GPI_cmp_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } + void MichaelKVListTestHeader::RCU_GPI_cmp() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_less_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPI_less() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPI_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_ic_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::RCU_GPI_ic() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_kv_rcu_gpt.cpp b/tests/test-hdr/list/hdr_michael_kv_rcu_gpt.cpp new file mode 100644 index 00000000..1cd40e3d --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_rcu_gpt.cpp @@ -0,0 +1,102 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; + struct RCU_GPT_cmp_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } + void MichaelKVListTestHeader::RCU_GPT_cmp() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_less_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPT_less() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } + void MichaelKVListTestHeader::RCU_GPT_cmpmix() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_ic_traits : public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelKVListTestHeader::RCU_GPT_ic() + { + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp b/tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp new file mode 100644 index 00000000..f97ca9c3 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp @@ -0,0 +1,117 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; + struct RCU_SHB_cmp_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHB_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_less_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHB_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHB_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_ic_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHB_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp b/tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp new file mode 100644 index 00000000..d8c9c101 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp @@ -0,0 +1,117 @@ +//$$CDS-header$$ + +#include "list/hdr_michael_kv.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; + struct RCU_SHT_cmp_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHT_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_less_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHT_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::cmp compare; + typedef MichaelKVListTestHeader::lt less; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHT_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_ic_traits: public cc::michael_list::traits + { + typedef MichaelKVListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void MichaelKVListTestHeader::RCU_SHT_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelKVList< rcu_type, key_type, value_type, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_michael_nogc.cpp b/tests/test-hdr/list/hdr_michael_nogc.cpp new file mode 100644 index 00000000..65abec8d --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_nogc.cpp @@ -0,0 +1,100 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include + +namespace ordlist { + namespace { + struct NOGC_cmp_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } + void MichaelListTestHeader::NOGC_cmp() + { + // traits-based version + typedef cc::MichaelList< cds::gc::nogc, item, NOGC_cmp_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::nogc, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_less_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::NOGC_less() + { + // traits-based version + typedef cc::MichaelList< cds::gc::nogc, item, NOGC_less_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::nogc, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::NOGC_cmpmix() + { + // traits-based version + typedef cc::MichaelList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::nogc, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + nogc_test< opt_list >(); + } + + namespace { + struct NOGC_ic_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::NOGC_ic() + { + // traits-based version + typedef cc::MichaelList< cds::gc::nogc, item, NOGC_ic_traits > list; + nogc_test< list >(); + + // option-based version + + typedef cc::MichaelList< cds::gc::nogc, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + nogc_test< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_rcu_gpb.cpp b/tests/test-hdr/list/hdr_michael_rcu_gpb.cpp new file mode 100644 index 00000000..f16082d4 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_rcu_gpb.cpp @@ -0,0 +1,104 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; + + struct RCU_GPB_cmp_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } + + void MichaelListTestHeader::RCU_GPB_cmp() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_less_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPB_less() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPB_cmpmix() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPB_ic_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::RCU_GPB_ic() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_rcu_gpi.cpp b/tests/test-hdr/list/hdr_michael_rcu_gpi.cpp new file mode 100644 index 00000000..80609ca7 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_rcu_gpi.cpp @@ -0,0 +1,104 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; + + struct RCU_GPI_cmp_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } + + void MichaelListTestHeader::RCU_GPI_cmp() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPI_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_less_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPI_less() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPI_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPI_cmpmix() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPI_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPI_ic_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::RCU_GPI_ic() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPI_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_rcu_gpt.cpp b/tests/test-hdr/list/hdr_michael_rcu_gpt.cpp new file mode 100644 index 00000000..da423498 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_rcu_gpt.cpp @@ -0,0 +1,104 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include +#include + +namespace ordlist { + namespace { + typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; + + struct RCU_GPT_cmp_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } + + void MichaelListTestHeader::RCU_GPT_cmp() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_less_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPT_less() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } + void MichaelListTestHeader::RCU_GPT_cmpmix() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); + } + + namespace { + struct RCU_GPT_ic_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } + void MichaelListTestHeader::RCU_GPT_ic() + { + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_GPT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); + } + +} // namespace ordlist + diff --git a/tests/test-hdr/list/hdr_michael_rcu_shb.cpp b/tests/test-hdr/list/hdr_michael_rcu_shb.cpp new file mode 100644 index 00000000..32ce2729 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_rcu_shb.cpp @@ -0,0 +1,119 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; + + struct RCU_SHB_cmp_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } +#endif + + void MichaelListTestHeader::RCU_SHB_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_less_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } +#endif + void MichaelListTestHeader::RCU_SHB_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHB_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } +#endif + void MichaelListTestHeader::RCU_SHB_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHB_ic_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void MichaelListTestHeader::RCU_SHB_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHB_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/list/hdr_michael_rcu_sht.cpp b/tests/test-hdr/list/hdr_michael_rcu_sht.cpp new file mode 100644 index 00000000..8696e569 --- /dev/null +++ b/tests/test-hdr/list/hdr_michael_rcu_sht.cpp @@ -0,0 +1,119 @@ +//$$CDS-header$$ + +#include "list/hdr_michael.h" +#include +#include + +namespace ordlist { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; + + struct RCU_SHT_cmp_traits : public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + }; + } +#endif + + void MichaelListTestHeader::RCU_SHT_cmp() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHT_cmp_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_less_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + }; + } +#endif + void MichaelListTestHeader::RCU_SHT_less() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHT_less_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_cmpmix_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::cmp compare; + typedef MichaelListTestHeader::lt less; + }; + } +#endif + void MichaelListTestHeader::RCU_SHT_cmpmix() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHT_cmpmix_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::compare< cmp > + ,cc::opt::less< lt > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + namespace { + struct RCU_SHT_ic_traits: public cc::michael_list::traits + { + typedef MichaelListTestHeader::lt less; + typedef cds::atomicity::item_counter item_counter; + }; + } +#endif + void MichaelListTestHeader::RCU_SHT_ic() + { +#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED + // traits-based version + typedef cc::MichaelList< rcu_type, item, RCU_SHT_ic_traits > list; + test_rcu< list >(); + + // option-based version + + typedef cc::MichaelList< rcu_type, item, + cc::michael_list::make_traits< + cc::opt::less< lt > + ,cc::opt::item_counter< cds::atomicity::item_counter > + >::type + > opt_list; + test_rcu< opt_list >(); +#endif + } + +} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy.h b/tests/test-hdr/ordered_list/hdr_intrusive_lazy.h deleted file mode 100644 index f5e76040..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy.h +++ /dev/null @@ -1,939 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H -#define CDSTEST_HDR_INTRUSIVE_LAZY_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace ci = cds::intrusive; - namespace co = cds::opt; - - class IntrusiveLazyListHeaderTest: public CppUnitMini::TestCase - { - public: - - struct stat { - int nDisposeCount; - int nEnsureExistsCall; - int nEnsureNewCall; - int nFindCall; - int nEraseCall; - - stat() - : nDisposeCount(0) - , nEnsureExistsCall(0) - , nEnsureNewCall(0) - , nFindCall(0) - , nEraseCall(0) - {} - - stat( const stat& s ) - { - *this = s; - } - - stat& operator =(const stat& s) - { - memcpy( this, &s, sizeof(s)); - return *this; - } - }; - - template - struct base_int_item: public ci::lazy_list::node< GC > - { - int nKey; - int nVal; - - mutable stat s; - - base_int_item() - {} - - base_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - base_int_item(const base_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - }; - - template - struct member_int_item - { - int nKey; - int nVal; - - ci::lazy_list::node< GC > hMember; - - mutable stat s; - - member_int_item() - {} - - member_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - member_int_item(const member_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - }; - - 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 { - 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(); - } - }; - - struct other_item { - int nKey; - - other_item( int n ) - : nKey(n) - {} - }; - - struct other_less { - template - bool operator()( T const& i1, Q const& i2) const - { - return i1.nKey < i2.nKey; - } - }; - - struct other_equal { - template - bool operator()( T const& i1, Q const& i2) const - { - return i1.nKey == i2.nKey; - } - }; - - struct faked_disposer - { - template - void operator ()( T * p ) - { - ++p->s.nDisposeCount; - } - }; - - struct ensure_functor - { - template - void operator ()(bool bNew, T& item, T& /*val*/ ) - { - if ( bNew ) - ++item.s.nEnsureNewCall; - else - ++item.s.nEnsureExistsCall; - } - }; - - struct find_functor - { - template - void operator ()( T& item, Q& /*val*/ ) - { - ++item.s.nFindCall; - } - }; - - struct erase_functor - { - template - void operator()( T const& item ) - { - item.s.nEraseCall++; - } - }; - - template - void test_int_common() - { - typedef typename OrdList::value_type value_type; - - value_type v1( 10, 50 ); - value_type v2( 5, 25 ); - value_type v3( 20, 100 ); - { - OrdList l; - CPPUNIT_ASSERT( l.empty() ); - - CPPUNIT_ASSERT( l.insert( v1 )) ; // true - CPPUNIT_ASSERT( l.find( v1.key() )); - - CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find_with( v2.key(), less() )); - CPPUNIT_ASSERT( !l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( !l.empty() ); - - //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised - - { - value_type v( v1 ); - CPPUNIT_ASSERT( !l.insert( v )) ; // false - } - - std::pair ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - - //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" - - CPPUNIT_ASSERT( l.find( v1.key() )) ; // true - - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); - - CPPUNIT_ASSERT( l.find( v2.key() )); - - CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find_with( v2.key(), less(), find_functor() )); - CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v3.key() )); - - { - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - - value_type v( v2 ); - ret = l.ensure( v, ensure_functor() ); - - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( !ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 ); - CPPUNIT_ASSERT( v.s.nEnsureNewCall == 0 ); - } - - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.insert( v3 )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() )); - - CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( l.unlink( v2 ) ); - CPPUNIT_ASSERT( l.find( v1.key() )) ; // true - CPPUNIT_ASSERT( !l.find( v2.key() )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() )) ; // true - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - - { - // v1 key is in the list but v NODE is not in the list - value_type v( v1 ); - CPPUNIT_ASSERT( !l.unlink( v ) ); - } - - CPPUNIT_ASSERT( l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.find( v1.key() )); - CPPUNIT_ASSERT( !l.find( v2.key() )); - CPPUNIT_ASSERT( l.find( v3.key() )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - - CPPUNIT_ASSERT( l.unlink( v3 ) ); - CPPUNIT_ASSERT( !l.find( v1.key() )); - CPPUNIT_ASSERT( !l.find_with( v2.key(), less() )); - CPPUNIT_ASSERT( !l.find( v3.key() )); - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - CPPUNIT_ASSERT( !l.unlink( v3 ) ); - - // Apply retired pointer to clean links - OrdList::gc::force_dispose(); - - stat s( v3.s ); - ret = l.ensure( v3, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v3.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v3.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - s = v2.s; - ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - s = v1.s; - ret = l.ensure( v1, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v1.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v1.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - // Erase test - CPPUNIT_ASSERT( l.erase( v1.key()) ); - //CPPUNIT_ASSERT( v1.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase_with( v2.key(), less(), erase_functor()) ); - CPPUNIT_ASSERT( v2.s.nEraseCall == 1 ); - CPPUNIT_ASSERT( !l.erase_with( v2.key(), less())); - CPPUNIT_ASSERT( v2.s.nEraseCall == 1 ); - //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.erase( v2 )); - CPPUNIT_ASSERT( !l.erase( v1 )); - //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( v3.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase( v3, erase_functor() )); - CPPUNIT_ASSERT( v3.s.nEraseCall == 1 ); - //CPPUNIT_ASSERT( v3.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( l.empty() ); - - // Apply retired pointer to clean links - OrdList::gc::force_dispose(); - - // Unlink test - CPPUNIT_ASSERT( l.insert( v1 )); - CPPUNIT_ASSERT( l.insert( v3 )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v2 )); - CPPUNIT_ASSERT( l.unlink( v1 )); - CPPUNIT_ASSERT( !l.unlink( v1 )); - CPPUNIT_ASSERT( l.unlink( v3 )); - CPPUNIT_ASSERT( !l.unlink( v3 )); - CPPUNIT_ASSERT( l.empty() ); - - // Apply retired pointer - OrdList::gc::force_dispose(); - CPPUNIT_ASSERT( v1.s.nDisposeCount == 3 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 2 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 3 ); - - // Destructor test (call disposer) - CPPUNIT_ASSERT( l.insert( v1 )); - CPPUNIT_ASSERT( l.insert( v3 )); - CPPUNIT_ASSERT( l.insert( v2 )); - - // Iterator test - { - typename OrdList::iterator it = l.begin(); - typename OrdList::const_iterator cit = l.cbegin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( cit != l.end() ); - CPPUNIT_ASSERT( cit != l.cend() ); - CPPUNIT_ASSERT( cit == it ); - - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( ++it == l.end() ); - } - - { - OrdList const & lref = l; - typename OrdList::const_iterator it = lref.begin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != lref.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( ++it == l.end() ); - } - } - - // Apply retired pointer - OrdList::gc::force_dispose(); - - CPPUNIT_ASSERT( v1.s.nDisposeCount == 4 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 3 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 4 ); - } - - template - void test_int() - { - test_int_common(); - - OrdList l; - typename OrdList::guarded_ptr gp; - - static int const nLimit = 20; - typename OrdList::value_type arrItem[nLimit]; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - for (int i = 0; i < nLimit; ++i) { - arrItem[i].nKey = a[i]; - arrItem[i].nVal = a[i] * 2; - } - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - for ( int i=0; i < nLimit; ++i ) { - gp = l.get( arrItem[i].nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); - CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); - - gp = l.extract( arrItem[i].nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); - CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); - - gp = l.get( arrItem[i].nKey ); - CPPUNIT_ASSERT( !gp ); - CPPUNIT_ASSERT( gp.empty()); - CPPUNIT_ASSERT( !l.extract( arrItem[i].nKey )); - CPPUNIT_ASSERT( gp.empty()); - } - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.get( nLimit/2 )); - CPPUNIT_ASSERT( !l.extract( nLimit/2 )); - - // Apply retired pointer - OrdList::gc::force_dispose(); - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - for ( int i=0; i < nLimit; ++i ) { - other_item itm( arrItem[i].nKey ); - gp = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); - CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); - - gp = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey ); - CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal ); - - gp = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( !gp ); - CPPUNIT_ASSERT( gp.empty()); - CPPUNIT_ASSERT( !l.extract_with( itm, other_less() )); - CPPUNIT_ASSERT( gp.empty()); - } - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() )); - CPPUNIT_ASSERT( gp.empty()); - CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() )); - CPPUNIT_ASSERT( gp.empty()); - - // Apply retired pointer - OrdList::gc::force_dispose(); - - for ( int i=0; i < nLimit; i++ ) { - CPPUNIT_ASSERT( arrItem[i].s.nDisposeCount == 2 ); - } - } - } - - template - void test_rcu_int() - { - test_int_common(); - - OrdList l; - static int const nLimit = 20; - typename OrdList::value_type arrItem[nLimit]; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - for (int i = 0; i < nLimit; ++i) { - arrItem[i].nKey = a[i]; - arrItem[i].nVal = a[i] * 2; - } - - typename OrdList::exempt_ptr ep; - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[i] ) ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - ep = l.extract( a[0] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - // Apply retired pointer - OrdList::gc::force_dispose(); - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - other_item itm( a[i] ); - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - // Apply retired pointer - OrdList::gc::force_dispose(); - } - } - - template - void test_nogc_int() - { - typedef typename OrdList::value_type value_type; - typedef typename std::conditional< OrdList::c_bSort, less, equal>::type find_predicate; - - { - value_type v1( 10, 50 ); - value_type v2( 5, 25 ); - value_type v3( 20, 100 ); - { - OrdList l; - CPPUNIT_ASSERT( l.empty() ); - - CPPUNIT_ASSERT( l.insert( v1 )) ; // true - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); - - CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( l.find_with( v2.key(), find_predicate() ) == nullptr ); - CPPUNIT_ASSERT( l.find( v3.key() ) == nullptr ); - CPPUNIT_ASSERT( !l.empty() ); - - //CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is raised - - { - value_type v( v1 ); - CPPUNIT_ASSERT( !l.insert( v )) ; // false - } - - std::pair ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - - //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" - - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true - - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); - - CPPUNIT_ASSERT( l.find_with( v2.key(), find_predicate() ) == &v2 ); - - CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find_with( v2.key(), find_predicate(), find_functor() )); - CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v3.key() )); - - { - value_type v( v2 ); - ret = l.ensure( v, ensure_functor() ); - - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( !ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); - CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); - } - - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.insert( v3 )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); - - CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); - - { - typename OrdList::iterator it = l.begin(); - typename OrdList::const_iterator cit = l.cbegin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( cit != l.end() ); - CPPUNIT_ASSERT( cit != l.cend() ); - CPPUNIT_ASSERT( cit == it ); - - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - - { - OrdList const & lref = l; - typename OrdList::const_iterator it = lref.begin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != lref.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != lref.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - } - - // Disposer called on list destruction - CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); - } - } - - void HP_base_cmp(); - void HP_base_less(); - void HP_base_cmpmix(); - void HP_base_ic(); - void HP_member_cmp(); - void HP_member_less(); - void HP_member_cmpmix(); - void HP_member_ic(); - - void DHP_base_cmp(); - void DHP_base_less(); - void DHP_base_cmpmix(); - void DHP_base_ic(); - void DHP_member_cmp(); - void DHP_member_less(); - void DHP_member_cmpmix(); - void DHP_member_ic(); - - void RCU_GPI_base_cmp(); - void RCU_GPI_base_less(); - void RCU_GPI_base_cmpmix(); - void RCU_GPI_base_ic(); - void RCU_GPI_member_cmp(); - void RCU_GPI_member_less(); - void RCU_GPI_member_cmpmix(); - void RCU_GPI_member_ic(); - - void RCU_GPB_base_cmp(); - void RCU_GPB_base_less(); - void RCU_GPB_base_cmpmix(); - void RCU_GPB_base_ic(); - void RCU_GPB_member_cmp(); - void RCU_GPB_member_less(); - void RCU_GPB_member_cmpmix(); - void RCU_GPB_member_ic(); - - void RCU_GPT_base_cmp(); - void RCU_GPT_base_less(); - void RCU_GPT_base_cmpmix(); - void RCU_GPT_base_ic(); - void RCU_GPT_member_cmp(); - void RCU_GPT_member_less(); - void RCU_GPT_member_cmpmix(); - void RCU_GPT_member_ic(); - - void RCU_SHB_base_cmp(); - void RCU_SHB_base_less(); - void RCU_SHB_base_cmpmix(); - void RCU_SHB_base_ic(); - void RCU_SHB_member_cmp(); - void RCU_SHB_member_less(); - void RCU_SHB_member_cmpmix(); - void RCU_SHB_member_ic(); - - void RCU_SHT_base_cmp(); - void RCU_SHT_base_less(); - void RCU_SHT_base_cmpmix(); - void RCU_SHT_base_ic(); - void RCU_SHT_member_cmp(); - void RCU_SHT_member_less(); - void RCU_SHT_member_cmpmix(); - void RCU_SHT_member_ic(); - - void nogc_base_cmp(); - void nogc_base_less(); - void nogc_base_cmpmix(); - void nogc_base_ic(); - void nogc_member_cmp(); - void nogc_member_less(); - void nogc_member_cmpmix(); - void nogc_member_ic(); - void nogc_base_unord_equal(); - void nogc_base_unord_cmp(); - void nogc_base_unord_less(); - void nogc_member_unord_equal(); - void nogc_member_unord_cmp(); - void nogc_member_unord_less(); - - - CPPUNIT_TEST_SUITE(IntrusiveLazyListHeaderTest) - CPPUNIT_TEST(HP_base_cmp) - CPPUNIT_TEST(HP_base_less) - CPPUNIT_TEST(HP_base_cmpmix) - CPPUNIT_TEST(HP_base_ic) - CPPUNIT_TEST(HP_member_cmp) - CPPUNIT_TEST(HP_member_less) - CPPUNIT_TEST(HP_member_cmpmix) - CPPUNIT_TEST(HP_member_ic) - - CPPUNIT_TEST(DHP_base_cmp) - CPPUNIT_TEST(DHP_base_less) - CPPUNIT_TEST(DHP_base_cmpmix) - CPPUNIT_TEST(DHP_base_ic) - CPPUNIT_TEST(DHP_member_cmp) - CPPUNIT_TEST(DHP_member_less) - CPPUNIT_TEST(DHP_member_cmpmix) - CPPUNIT_TEST(DHP_member_ic) - - CPPUNIT_TEST(RCU_GPI_base_cmp) - CPPUNIT_TEST(RCU_GPI_base_less) - CPPUNIT_TEST(RCU_GPI_base_cmpmix) - CPPUNIT_TEST(RCU_GPI_base_ic) - CPPUNIT_TEST(RCU_GPI_member_cmp) - CPPUNIT_TEST(RCU_GPI_member_less) - CPPUNIT_TEST(RCU_GPI_member_cmpmix) - CPPUNIT_TEST(RCU_GPI_member_ic) - - CPPUNIT_TEST(RCU_GPB_base_cmp) - CPPUNIT_TEST(RCU_GPB_base_less) - CPPUNIT_TEST(RCU_GPB_base_cmpmix) - CPPUNIT_TEST(RCU_GPB_base_ic) - CPPUNIT_TEST(RCU_GPB_member_cmp) - CPPUNIT_TEST(RCU_GPB_member_less) - CPPUNIT_TEST(RCU_GPB_member_cmpmix) - CPPUNIT_TEST(RCU_GPB_member_ic) - - CPPUNIT_TEST(RCU_GPT_base_cmp) - CPPUNIT_TEST(RCU_GPT_base_less) - CPPUNIT_TEST(RCU_GPT_base_cmpmix) - CPPUNIT_TEST(RCU_GPT_base_ic) - CPPUNIT_TEST(RCU_GPT_member_cmp) - CPPUNIT_TEST(RCU_GPT_member_less) - CPPUNIT_TEST(RCU_GPT_member_cmpmix) - CPPUNIT_TEST(RCU_GPT_member_ic) - - CPPUNIT_TEST(RCU_SHB_base_cmp) - CPPUNIT_TEST(RCU_SHB_base_less) - CPPUNIT_TEST(RCU_SHB_base_cmpmix) - CPPUNIT_TEST(RCU_SHB_base_ic) - CPPUNIT_TEST(RCU_SHB_member_cmp) - CPPUNIT_TEST(RCU_SHB_member_less) - CPPUNIT_TEST(RCU_SHB_member_cmpmix) - CPPUNIT_TEST(RCU_SHB_member_ic) - - CPPUNIT_TEST(RCU_SHT_base_cmp) - CPPUNIT_TEST(RCU_SHT_base_less) - CPPUNIT_TEST(RCU_SHT_base_cmpmix) - CPPUNIT_TEST(RCU_SHT_base_ic) - CPPUNIT_TEST(RCU_SHT_member_cmp) - CPPUNIT_TEST(RCU_SHT_member_less) - CPPUNIT_TEST(RCU_SHT_member_cmpmix) - CPPUNIT_TEST(RCU_SHT_member_ic) - - CPPUNIT_TEST(nogc_base_cmp) - CPPUNIT_TEST(nogc_base_less) - CPPUNIT_TEST(nogc_base_cmpmix) - CPPUNIT_TEST(nogc_base_ic) - CPPUNIT_TEST(nogc_base_unord_equal) - CPPUNIT_TEST(nogc_base_unord_cmp) - CPPUNIT_TEST(nogc_base_unord_less) - CPPUNIT_TEST(nogc_member_cmp) - CPPUNIT_TEST(nogc_member_less) - CPPUNIT_TEST(nogc_member_cmpmix) - CPPUNIT_TEST(nogc_member_ic) - CPPUNIT_TEST(nogc_member_unord_equal) - CPPUNIT_TEST(nogc_member_unord_cmp) - CPPUNIT_TEST(nogc_member_unord_less) - - CPPUNIT_TEST_SUITE_END() - }; -} // namespace ordlist - -#endif // #ifndef CDSTEST_HDR_INTRUSIVE_LAZY_H diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_dhp.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_dhp.cpp deleted file mode 100644 index bea26402..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_dhp.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include - -namespace ordlist { - void IntrusiveLazyListHeaderTest::DHP_base_cmp() - { - typedef base_int_item< cds::gc::DHP > item; - struct traits : public ci::lazy_list::traits - { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::LazyList< cds::gc::DHP, item, traits > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_base_less() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_base_cmpmix() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_base_ic() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_member_cmp() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_member_less() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_member_cmpmix() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::DHP_member_ic() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::LazyList< cds::gc::DHP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_hp.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_hp.cpp deleted file mode 100644 index 9482f0ad..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_hp.cpp +++ /dev/null @@ -1,125 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include - -namespace ordlist { - void IntrusiveLazyListHeaderTest::HP_base_cmp() - { - typedef base_int_item< cds::gc::HP > item; - struct traits : public ci::lazy_list::traits - { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::LazyList< cds::gc::HP, item, traits > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_base_less() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_base_cmpmix() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_base_ic() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_member_cmp() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_member_less() - { - typedef member_int_item< cds::gc::HP > item; - struct traits : public ci::lazy_list::traits - { - typedef ci::lazy_list::member_hook< offsetof( item, hMember ), co::gc> hook; - typedef IntrusiveLazyListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::LazyList< cds::gc::HP, item, traits > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_member_cmpmix() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveLazyListHeaderTest::HP_member_ic() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::LazyList< cds::gc::HP - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::IntrusiveLazyListHeaderTest); diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_nogc.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_nogc.cpp deleted file mode 100644 index 4ce2686f..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_nogc.cpp +++ /dev/null @@ -1,233 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include - -namespace ordlist { - void IntrusiveLazyListHeaderTest::nogc_base_cmp() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits : public ci::lazy_list::traits { - typedef ci::lazy_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::LazyList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_less() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits: public - ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::LazyList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_cmpmix() - { - typedef base_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_ic() - { - typedef base_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_unord_equal() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits: public - ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::sort< false > - ,co::equal_to< equal > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::LazyList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_unord_cmp() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits: public - ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::sort< false > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::LazyList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_base_unord_less() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits: public - ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::sort< false > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::LazyList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_cmp() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_less() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_cmpmix() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_ic() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_unord_equal() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::sort< false > - ,co::equal_to< equal > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_unord_cmp() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::sort< false > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - - void IntrusiveLazyListHeaderTest::nogc_member_unord_less() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::LazyList< cds::gc::nogc - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::sort< false > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpb.cpp deleted file mode 100644 index 9091db8a..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpb.cpp +++ /dev/null @@ -1,132 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > RCU; - } - - void IntrusiveLazyListHeaderTest::RCU_GPB_base_cmp() - { - typedef base_int_item< RCU > item; - typedef ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type list_traits; - typedef ci::LazyList< RCU, item, list_traits > list; - - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_base_less() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_member_cmp() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_member_less() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_member_cmpmix() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPB_member_ic() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpi.cpp deleted file mode 100644 index 6e656bc7..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpi.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > RCU; - } - - void IntrusiveLazyListHeaderTest::RCU_GPI_base_cmp() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_base_less() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_member_cmp() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_member_less() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_member_cmpmix() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPI_member_ic() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpt.cpp deleted file mode 100644 index 71d3eae1..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_gpt.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > RCU; - } - - void IntrusiveLazyListHeaderTest::RCU_GPT_base_cmp() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_base_less() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_member_cmp() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_member_less() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_member_cmpmix() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveLazyListHeaderTest::RCU_GPT_member_ic() - { - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_shb.cpp deleted file mode 100644 index 9a002a81..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_shb.cpp +++ /dev/null @@ -1,158 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > RCU; - } -#endif - - void IntrusiveLazyListHeaderTest::RCU_SHB_base_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type list_traits; - typedef ci::LazyList< RCU, item, list_traits > list; - - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_base_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_base_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_base_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_member_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_member_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_member_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - - void IntrusiveLazyListHeaderTest::RCU_SHB_member_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_sht.cpp deleted file mode 100644 index b5a53aed..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_lazy_rcu_sht.cpp +++ /dev/null @@ -1,151 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_lazy.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > RCU; - } -#endif - - void IntrusiveLazyListHeaderTest::RCU_SHT_base_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_base_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_base_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_base_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_member_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_member_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_member_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveLazyListHeaderTest::RCU_SHT_member_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::LazyList< RCU - ,item - ,ci::lazy_list::make_traits< - ci::opt::hook< ci::lazy_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael.h b/tests/test-hdr/ordered_list/hdr_intrusive_michael.h deleted file mode 100644 index 05248f66..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael.h +++ /dev/null @@ -1,911 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_INTRUSIVE_MICHAEL_H -#define CDSTEST_HDR_INTRUSIVE_MICHAEL_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace ci = cds::intrusive; - namespace co = cds::opt; - - class IntrusiveMichaelListHeaderTest: public CppUnitMini::TestCase - { - public: - - struct stat { - int nDisposeCount; - int nEnsureExistsCall; - int nEnsureNewCall; - int nFindCall; - int nEraseCall; - - stat() - : nDisposeCount(0) - , nEnsureExistsCall(0) - , nEnsureNewCall(0) - , nFindCall(0) - , nEraseCall(0) - {} - - stat( const stat& s ) - { - *this = s; - } - - stat& operator =(const stat& s) - { - memcpy( this, &s, sizeof(s)); - return *this; - } - }; - - template - struct base_int_item: public ci::michael_list::node< GC > - { - int nKey; - int nVal; - - mutable stat s; - - base_int_item() - {} - - base_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - base_int_item(const base_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - }; - - template - struct member_int_item - { - int nKey; - int nVal; - - ci::michael_list::node< GC > hMember; - - mutable stat s; - - member_int_item() - {} - - member_int_item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - member_int_item(const member_int_item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - const int& key() const - { - return nKey; - } - }; - - 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(); - } - }; - - struct other_item { - int nKey; - - other_item( int n ) - : nKey(n) - {} - }; - - struct other_less { - template - bool operator()( T const& i1, Q const& i2) const - { - return i1.nKey < i2.nKey; - } - }; - - 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; - } - }; - - struct faked_disposer - { - template - void operator ()( T * p ) - { - ++p->s.nDisposeCount; - } - }; - - struct ensure_functor - { - template - void operator ()(bool bNew, T& item, T& /*val*/ ) - { - if ( bNew ) - ++item.s.nEnsureNewCall; - else - ++item.s.nEnsureExistsCall; - } - }; - - struct find_functor - { - template - void operator ()( T& item, Q& /*val*/ ) - { - ++item.s.nFindCall; - } - }; - - struct erase_functor - { - template - void operator()( T const& item ) - { - item.s.nEraseCall++; - } - }; - - template - void test_int_common() - { - typedef typename OrdList::value_type value_type; - - value_type v1( 10, 50 ); - value_type v2( 5, 25 ); - value_type v3( 20, 100 ); - { - OrdList l; - CPPUNIT_ASSERT( l.empty() ); - - CPPUNIT_ASSERT( l.insert( v1 )) ; // true - CPPUNIT_ASSERT( l.find( v1.key() )); - - CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v2.key() )); - CPPUNIT_ASSERT( !l.find_with( v3.key(), less() )); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr - - { - value_type v( v1 ); - CPPUNIT_ASSERT( !l.insert( v )) ; // false - } - - std::pair ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - - //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" - - CPPUNIT_ASSERT( l.find_with( v1.key(), less() )) ; // true - - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - CPPUNIT_ASSERT( l.find_with( v1.key(), less(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); - - CPPUNIT_ASSERT( l.find( v2.key() )); - - CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v2.key(), find_functor() )); - CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v3.key() )); - - { - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - - value_type v( v2 ); - ret = l.ensure( v, ensure_functor() ); - - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( !ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 ); - CPPUNIT_ASSERT( v.s.nEnsureNewCall == 0 ); - } - - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.insert( v3 )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() )); - - CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( l.unlink( v2 ) ); - CPPUNIT_ASSERT( l.find( v1.key() )) ; // true - CPPUNIT_ASSERT( !l.find( v2.key() )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() )) ; // true - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - - { - // v1 key is in the list but v NODE is not in the list - value_type v( v1 ); - CPPUNIT_ASSERT( !l.unlink( v ) ); - } - - CPPUNIT_ASSERT( l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.find( v1.key() )); - CPPUNIT_ASSERT( !l.find( v2.key() )); - CPPUNIT_ASSERT( l.find( v3.key() )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - - CPPUNIT_ASSERT( l.unlink( v3 ) ); - CPPUNIT_ASSERT( !l.find_with( v1.key(), less() )); - CPPUNIT_ASSERT( !l.find_with( v2.key(), less(), find_functor() )); - CPPUNIT_ASSERT( !l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v1 ) ); - CPPUNIT_ASSERT( !l.unlink( v2 ) ); - CPPUNIT_ASSERT( !l.unlink( v3 ) ); - - // Apply retired pointer to clean links - OrdList::gc::force_dispose(); - - stat s( v3.s ); - ret = l.ensure( v3, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v3.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v3.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - s = v2.s; - ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - s = v1.s; - ret = l.ensure( v1, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v1.s.nEnsureNewCall == s.nEnsureNewCall + 1); - CPPUNIT_ASSERT( v1.s.nEnsureExistsCall == s.nEnsureExistsCall ); - CPPUNIT_ASSERT( !l.empty() ); - - // Erase test - CPPUNIT_ASSERT( v1.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase( v1.key(), erase_functor()) ); - CPPUNIT_ASSERT( v1.s.nEraseCall == 1 ); - //CPPUNIT_ASSERT( v1.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.erase_with( v2.key(), less() ) ); - CPPUNIT_ASSERT( !l.erase( v2.key())); - //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( !l.erase( v2, erase_functor() )); - CPPUNIT_ASSERT( v2.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( !l.erase( v1 )); - //CPPUNIT_ASSERT( v2.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( v3.s.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase_with( v3, less(), erase_functor() )); - CPPUNIT_ASSERT( v3.s.nEraseCall == 1 ); - //CPPUNIT_ASSERT( v3.s.nDisposeCount == 0 ); - CPPUNIT_ASSERT( l.empty() ); - - // Apply retired pointer to clean links - OrdList::gc::force_dispose(); - - // Unlink test - CPPUNIT_ASSERT( l.insert( v1 )); - CPPUNIT_ASSERT( l.insert( v3 )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( !l.unlink( v2 )); - CPPUNIT_ASSERT( l.unlink( v1 )); - CPPUNIT_ASSERT( !l.unlink( v1 )); - CPPUNIT_ASSERT( l.unlink( v3 )); - CPPUNIT_ASSERT( !l.unlink( v3 )); - CPPUNIT_ASSERT( l.empty() ); - - // Apply retired pointer - OrdList::gc::force_dispose(); - CPPUNIT_ASSERT( v1.s.nDisposeCount == 3 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 2 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 3 ); - - // Destructor test (call disposer) - CPPUNIT_ASSERT( l.insert( v1 )); - CPPUNIT_ASSERT( l.insert( v3 )); - CPPUNIT_ASSERT( l.insert( v2 )); - - // Iterator test - // begin/end - { - typename OrdList::iterator it = l.begin(); - typename OrdList::const_iterator cit = l.cbegin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( cit != l.end() ); - CPPUNIT_ASSERT( cit != l.cend() ); - CPPUNIT_ASSERT( cit == it ); - - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( ++it == l.end() ); - } - - // cbegin/cend - { - typename OrdList::const_iterator it = l.cbegin(); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != l.cend() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.cend() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( ++it == l.cend() ); - } - - // const begin/end - { - OrdList const & lref = l; - typename OrdList::const_iterator it = lref.begin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != lref.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( ++it == l.end() ); - } - } - - // Apply retired pointer - OrdList::gc::force_dispose(); - - CPPUNIT_ASSERT( v1.s.nDisposeCount == 4 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 3 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 4 ); - } - - template - void test_int() - { - test_int_common(); - - OrdList l; - typename OrdList::guarded_ptr gp; - - static int const nLimit = 20; - typename OrdList::value_type arrItem[nLimit]; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - for (int i = 0; i < nLimit; ++i) { - arrItem[i].nKey = a[i]; - arrItem[i].nVal = a[i] * 2; - } - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - for ( int i=0; i < nLimit; ++i ) { - gp = l.get( arrItem[i].nKey ); - CPPUNIT_ASSERT_EX( gp, "i=" << i ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); - CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); - gp.release(); - - gp = l.extract( arrItem[i].nKey ); - CPPUNIT_ASSERT_EX( gp, "i=" << i ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); - CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); - gp.release(); - - gp = l.get( arrItem[i].nKey ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( arrItem[i].nKey )); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.get( nLimit/2 )); - CPPUNIT_ASSERT( gp.empty()); - CPPUNIT_ASSERT( !l.extract( nLimit/2 )); - CPPUNIT_ASSERT( gp.empty()); - - // Apply retired pointer - OrdList::gc::force_dispose(); - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - for ( int i=0; i < nLimit; ++i ) { - other_item itm( arrItem[i].nKey ); - gp = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT_EX( gp, "i=" << i ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); - CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); - gp.release(); - - gp = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT_EX( gp, "i=" << i ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey ); - CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal ); - gp.release(); - - gp = l.get_with( itm, other_less() ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( itm, other_less() )); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() )); - CPPUNIT_ASSERT( gp.empty()); - CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() )); - CPPUNIT_ASSERT( gp.empty()); - - // Apply retired pointer - OrdList::gc::force_dispose(); - - for ( int i=0; i < nLimit; i++ ) { - CPPUNIT_ASSERT( arrItem[i].s.nDisposeCount == 2 ); - } - } - } - - template - void test_rcu_int() - { - test_int_common(); - - OrdList l; - static int const nLimit = 20; - typename OrdList::value_type arrItem[nLimit]; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - for (int i = 0; i < nLimit; ++i) { - arrItem[i].nKey = a[i]; - arrItem[i].nVal = a[i] * 2; - } - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - - typename OrdList::exempt_ptr ep; - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - } - - { - rcu_lock lock; - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); - } - ep.release(); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[i] )); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - ep = l.extract( a[0] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - // Apply retired pointer - OrdList::gc::force_dispose(); - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( arrItem[i] ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - other_item itm( a[i] ); - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - } - - { - rcu_lock lock; - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); - } - ep.release(); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - // Apply retired pointer - OrdList::gc::force_dispose(); - } - } - - template - void test_nogc_int() - { - typedef typename OrdList::value_type value_type; - { - value_type v1( 10, 50 ); - value_type v2( 5, 25 ); - value_type v3( 20, 100 ); - { - OrdList l; - CPPUNIT_ASSERT( l.empty() ); - - CPPUNIT_ASSERT( l.insert( v1 )) ; // true - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ); - - CPPUNIT_ASSERT( v1.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( l.find_with( v2.key(), less() ) == nullptr ); - CPPUNIT_ASSERT( !l.find_with( v3.key(), less(), find_functor() )); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.insert( v1 )) ; // assertion "is_empty" is not raised since pNext is nullptr - - { - value_type v( v1 ); - CPPUNIT_ASSERT( !l.insert( v )) ; // false - } - - std::pair ret = l.ensure( v2, ensure_functor() ); - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureNewCall == 1 ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 0 ); - - //CPPUNIT_ASSERT( !l.insert( v2 )) ; // assertion "is_empty" - - CPPUNIT_ASSERT( l.find( v1.key() ) == &v1 ) ; // true - - CPPUNIT_ASSERT( v1.s.nFindCall == 1 ); - CPPUNIT_ASSERT( l.find( v1.key(), find_functor() )); - CPPUNIT_ASSERT( v1.s.nFindCall == 2 ); - - CPPUNIT_ASSERT( l.find( v2.key() ) == &v2 ); - - CPPUNIT_ASSERT( v2.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v2.key(), find_functor() )); - CPPUNIT_ASSERT( v2.s.nFindCall == 1 ); - - CPPUNIT_ASSERT( !l.find( v3.key() )); - - { - value_type v( v2 ); - ret = l.ensure( v, ensure_functor() ); - - CPPUNIT_ASSERT( ret.first ); - CPPUNIT_ASSERT( !ret.second ); - CPPUNIT_ASSERT( v2.s.nEnsureExistsCall == 1 ); - CPPUNIT_ASSERT( v.s.nEnsureExistsCall == 0 && v.s.nEnsureNewCall == 0 ); - } - - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.insert( v3 )) ; // true - CPPUNIT_ASSERT( l.find( v3.key() ) == &v3 ); - - CPPUNIT_ASSERT( v3.s.nFindCall == 0 ); - CPPUNIT_ASSERT( l.find( v3.key(), find_functor() )); - CPPUNIT_ASSERT( v3.s.nFindCall == 1 ); - - { - typename OrdList::iterator it = l.begin(); - typename OrdList::const_iterator cit = l.cbegin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it != l.cend() ); - CPPUNIT_ASSERT( cit != l.end() ); - CPPUNIT_ASSERT( cit != l.cend() ); - CPPUNIT_ASSERT( cit == it ); - - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - - { - OrdList const & lref = l; - typename OrdList::const_iterator it = lref.begin(); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == v2.nKey ); - CPPUNIT_ASSERT( it->nVal == v2.nVal ); - CPPUNIT_ASSERT( ++it != lref.end() ); - CPPUNIT_ASSERT( it->nKey == v1.nKey ); - CPPUNIT_ASSERT( it->nVal == v1.nVal ); - CPPUNIT_ASSERT( it++ != l.end() ); - CPPUNIT_ASSERT( it->nKey == v3.nKey ); - CPPUNIT_ASSERT( it->nVal == v3.nVal ); - CPPUNIT_ASSERT( it++ != lref.end() ); - CPPUNIT_ASSERT( it == l.end() ); - } - } - - // Disposer called on list destruction - CPPUNIT_ASSERT( v1.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v2.s.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v3.s.nDisposeCount == 1 ); - } - } - - void HP_base_cmp(); - void HP_base_less(); - void HP_base_cmpmix(); - void HP_base_ic(); - void HP_member_cmp(); - void HP_member_less(); - void HP_member_cmpmix(); - void HP_member_ic(); - - void DHP_base_cmp(); - void DHP_base_less(); - void DHP_base_cmpmix(); - void DHP_base_ic(); - void DHP_member_cmp(); - void DHP_member_less(); - void DHP_member_cmpmix(); - void DHP_member_ic(); - - void RCU_GPI_base_cmp(); - void RCU_GPI_base_less(); - void RCU_GPI_base_cmpmix(); - void RCU_GPI_base_ic(); - void RCU_GPI_member_cmp(); - void RCU_GPI_member_less(); - void RCU_GPI_member_cmpmix(); - void RCU_GPI_member_ic(); - - void RCU_GPB_base_cmp(); - void RCU_GPB_base_less(); - void RCU_GPB_base_cmpmix(); - void RCU_GPB_base_ic(); - void RCU_GPB_member_cmp(); - void RCU_GPB_member_less(); - void RCU_GPB_member_cmpmix(); - void RCU_GPB_member_ic(); - - void RCU_GPT_base_cmp(); - void RCU_GPT_base_less(); - void RCU_GPT_base_cmpmix(); - void RCU_GPT_base_ic(); - void RCU_GPT_member_cmp(); - void RCU_GPT_member_less(); - void RCU_GPT_member_cmpmix(); - void RCU_GPT_member_ic(); - - void RCU_SHB_base_cmp(); - void RCU_SHB_base_less(); - void RCU_SHB_base_cmpmix(); - void RCU_SHB_base_ic(); - void RCU_SHB_member_cmp(); - void RCU_SHB_member_less(); - void RCU_SHB_member_cmpmix(); - void RCU_SHB_member_ic(); - - void RCU_SHT_base_cmp(); - void RCU_SHT_base_less(); - void RCU_SHT_base_cmpmix(); - void RCU_SHT_base_ic(); - void RCU_SHT_member_cmp(); - void RCU_SHT_member_less(); - void RCU_SHT_member_cmpmix(); - void RCU_SHT_member_ic(); - - void nogc_base_cmp(); - void nogc_base_less(); - void nogc_base_cmpmix(); - void nogc_base_ic(); - void nogc_member_cmp(); - void nogc_member_less(); - void nogc_member_cmpmix(); - void nogc_member_ic(); - - - CPPUNIT_TEST_SUITE(IntrusiveMichaelListHeaderTest) - CPPUNIT_TEST(HP_base_cmp) - CPPUNIT_TEST(HP_base_less) - CPPUNIT_TEST(HP_base_cmpmix) - CPPUNIT_TEST(HP_base_ic) - CPPUNIT_TEST(HP_member_cmp) - CPPUNIT_TEST(HP_member_less) - CPPUNIT_TEST(HP_member_cmpmix) - CPPUNIT_TEST(HP_member_ic) - - CPPUNIT_TEST(DHP_base_cmp) - CPPUNIT_TEST(DHP_base_less) - CPPUNIT_TEST(DHP_base_cmpmix) - CPPUNIT_TEST(DHP_base_ic) - CPPUNIT_TEST(DHP_member_cmp) - CPPUNIT_TEST(DHP_member_less) - CPPUNIT_TEST(DHP_member_cmpmix) - CPPUNIT_TEST(DHP_member_ic) - - CPPUNIT_TEST(RCU_GPI_base_cmp) - CPPUNIT_TEST(RCU_GPI_base_less) - CPPUNIT_TEST(RCU_GPI_base_cmpmix) - CPPUNIT_TEST(RCU_GPI_base_ic) - CPPUNIT_TEST(RCU_GPI_member_cmp) - CPPUNIT_TEST(RCU_GPI_member_less) - CPPUNIT_TEST(RCU_GPI_member_cmpmix) - CPPUNIT_TEST(RCU_GPI_member_ic) - - CPPUNIT_TEST(RCU_GPB_base_cmp) - CPPUNIT_TEST(RCU_GPB_base_less) - CPPUNIT_TEST(RCU_GPB_base_cmpmix) - CPPUNIT_TEST(RCU_GPB_base_ic) - CPPUNIT_TEST(RCU_GPB_member_cmp) - CPPUNIT_TEST(RCU_GPB_member_less) - CPPUNIT_TEST(RCU_GPB_member_cmpmix) - CPPUNIT_TEST(RCU_GPB_member_ic) - - CPPUNIT_TEST(RCU_GPT_base_cmp) - CPPUNIT_TEST(RCU_GPT_base_less) - CPPUNIT_TEST(RCU_GPT_base_cmpmix) - CPPUNIT_TEST(RCU_GPT_base_ic) - CPPUNIT_TEST(RCU_GPT_member_cmp) - CPPUNIT_TEST(RCU_GPT_member_less) - CPPUNIT_TEST(RCU_GPT_member_cmpmix) - CPPUNIT_TEST(RCU_GPT_member_ic) - - CPPUNIT_TEST(nogc_base_cmp) - CPPUNIT_TEST(nogc_base_less) - CPPUNIT_TEST(nogc_base_cmpmix) - CPPUNIT_TEST(nogc_base_ic) - CPPUNIT_TEST(nogc_member_cmp) - CPPUNIT_TEST(nogc_member_less) - CPPUNIT_TEST(nogc_member_cmpmix) - CPPUNIT_TEST(nogc_member_ic) - - CPPUNIT_TEST_SUITE_END() - }; -} // namespace ordlist - -#endif // CDSTEST_HDR_INTRUSIVE_MICHAEL_H diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_dhp.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_dhp.cpp deleted file mode 100644 index 0efc72df..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_dhp.cpp +++ /dev/null @@ -1,127 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include - -namespace ordlist { - void IntrusiveMichaelListHeaderTest::DHP_base_cmp() - { - typedef base_int_item< cds::gc::DHP > item; - struct traits : public ci::michael_list::traits { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< cds::gc::DHP, item, traits > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_base_less() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_base_cmpmix() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_base_ic() - { - typedef base_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_member_cmp() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_member_less() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_member_cmpmix() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::DHP_member_ic() - { - typedef member_int_item< cds::gc::DHP > item; - typedef ci::MichaelList< cds::gc::DHP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_hp.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_hp.cpp deleted file mode 100644 index 2e2c9f35..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_hp.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include - -namespace ordlist { - void IntrusiveMichaelListHeaderTest::HP_base_cmp() - { - typedef base_int_item< cds::gc::HP > item; - struct traits : public ci::michael_list::traits { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< cds::gc::HP, item, traits > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_base_less() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_base_cmpmix() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_base_ic() - { - typedef base_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_member_cmp() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_member_less() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_member_cmpmix() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_int(); - } - void IntrusiveMichaelListHeaderTest::HP_member_ic() - { - typedef member_int_item< cds::gc::HP > item; - typedef ci::MichaelList< cds::gc::HP - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_int(); - } -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::IntrusiveMichaelListHeaderTest); diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpb.cpp deleted file mode 100644 index 996030f5..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpb.cpp +++ /dev/null @@ -1,132 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > RCU; - } - - void IntrusiveMichaelListHeaderTest::RCU_GPB_base_cmp() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_base_less() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_member_cmp() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_member_less() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_member_cmpmix() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPB_member_ic() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - -} diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpi.cpp deleted file mode 100644 index e985cdc3..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpi.cpp +++ /dev/null @@ -1,131 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > RCU; - } - - void IntrusiveMichaelListHeaderTest::RCU_GPI_base_cmp() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_base_less() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_member_cmp() - { - typedef member_int_item< RCU > item; - struct traits: public - ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_member_less() - { - typedef member_int_item< RCU > item; - struct traits: public - ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_member_cmpmix() - { - typedef member_int_item< RCU > item; - struct traits: public - ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - {}; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPI_member_ic() - { - typedef member_int_item< RCU > item; - struct traits: public - ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - {}; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpt.cpp deleted file mode 100644 index 4f8d7f36..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_gpt.cpp +++ /dev/null @@ -1,132 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > RCU; - } - - void IntrusiveMichaelListHeaderTest::RCU_GPT_base_cmp() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_base_less() - { - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_base_cmpmix() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_base_ic() - { - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_member_cmp() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_member_less() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_member_cmpmix() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); - } - void IntrusiveMichaelListHeaderTest::RCU_GPT_member_ic() - { - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); - } - -} diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_shb.cpp deleted file mode 100644 index 92950de7..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_shb.cpp +++ /dev/null @@ -1,150 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > RCU; - } -#endif - - void IntrusiveMichaelListHeaderTest::RCU_SHB_base_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_base_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_base_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_base_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_member_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_member_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_member_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHB_member_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - -} diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_sht.cpp deleted file mode 100644 index 174988cc..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_list_rcu_sht.cpp +++ /dev/null @@ -1,150 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > RCU; - } -#endif - - void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_base_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< RCU, item, traits > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_base_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_base_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef base_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_member_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_member_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_rcu_int(); -#endif - } - void IntrusiveMichaelListHeaderTest::RCU_SHT_member_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef member_int_item< RCU > item; - typedef ci::MichaelList< RCU - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_rcu_int(); -#endif - } - -} diff --git a/tests/test-hdr/ordered_list/hdr_intrusive_michael_nogc.cpp b/tests/test-hdr/ordered_list/hdr_intrusive_michael_nogc.cpp deleted file mode 100644 index 81f97104..00000000 --- a/tests/test-hdr/ordered_list/hdr_intrusive_michael_nogc.cpp +++ /dev/null @@ -1,127 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_intrusive_michael.h" -#include - -namespace ordlist { - void IntrusiveMichaelListHeaderTest::nogc_base_cmp() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef cmp compare; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_base_less() - { - typedef base_int_item< cds::gc::nogc > item; - struct traits : public ci::michael_list::traits - { - typedef ci::michael_list::base_hook< co::gc > hook; - typedef IntrusiveMichaelListHeaderTest::less less; - typedef faked_disposer disposer; - }; - typedef ci::MichaelList< cds::gc::nogc, item, traits > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_base_cmpmix() - { - typedef base_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_base_ic() - { - typedef base_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::base_hook< co::gc > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_member_cmp() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_member_less() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_member_cmpmix() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::less< less > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - >::type - > list; - test_nogc_int(); - } - void IntrusiveMichaelListHeaderTest::nogc_member_ic() - { - typedef member_int_item< cds::gc::nogc > item; - typedef ci::MichaelList< cds::gc::nogc - ,item - ,ci::michael_list::make_traits< - ci::opt::hook< ci::michael_list::member_hook< - offsetof( item, hMember ), - co::gc - > > - ,co::compare< cmp > - ,ci::opt::disposer< faked_disposer > - ,co::item_counter< cds::atomicity::item_counter > - >::type - > list; - test_nogc_int(); - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_lazy.h b/tests/test-hdr/ordered_list/hdr_lazy.h deleted file mode 100644 index 7945d06e..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy.h +++ /dev/null @@ -1,818 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_LAZY_H -#define CDSTEST_HDR_LAZY_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class LazyListTestHeader: public CppUnitMini::TestCase - { - public: - struct stat { - int nEnsureExistsCall; - int nEnsureNewCall; - - stat() - { - nEnsureExistsCall - = nEnsureNewCall - = 0; - } - }; - - struct item { - int nKey; - int nVal; - - stat s; - - item(int key) - : nKey( key ) - , nVal( key * 2 ) - , s() - {} - - item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - item( item const& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - int key() const - { - return nKey; - } - }; - - template - struct lt - { - 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; - } - }; - - struct insert_functor { - void operator ()( item& i ) - { - i.nVal = i.nKey * 1033; - } - }; - struct dummy_insert_functor { - void operator ()( item& /*i*/ ) - { - // This functor should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_functor should not be called", __FILE__, __LINE__ ); - } - }; - - static void insert_function( item& i ) - { - i.nVal = i.nKey * 1024; - } - static void dummy_insert_function( item& /*i*/ ) - { - // This function should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_function should not be called", __FILE__, __LINE__ ); - } - - struct erase_functor { - unsigned int nEraseCall; - - erase_functor() - : nEraseCall(0) - {} - - void operator()( item const& /*i*/) - { - ++nEraseCall; - } - }; - - struct check_value { - unsigned int m_nMultiplier; - - check_value( unsigned int nMultiplier ) - : m_nMultiplier( nMultiplier ) - {} - - check_value( const check_value& s ) - : m_nMultiplier( s.m_nMultiplier ) - {} - - void operator()( item& i, int ) - { - CPPUNIT_ASSERT_CURRENT( int(i.nKey * m_nMultiplier) == i.nVal ); - } - }; - - struct check_exact_value { - int m_nExpected; - - check_exact_value( int nExpected ) - : m_nExpected( nExpected ) - {} - - check_exact_value( check_exact_value const& s) - : m_nExpected( s.m_nExpected ) - {} - - void operator()( item& i, int ) - { - CPPUNIT_ASSERT_CURRENT( i.nVal == m_nExpected ); - } - }; - - struct dummy_check_value { - void operator()( item& /*i*/, int ) - { - // This functor should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_check_value should not be called", __FILE__, __LINE__ ); - } - }; - - struct ensure_functor { - void operator()( bool /*bNew*/, item& i, int /*n*/ ) - { - i.nVal = i.nKey * 1024; - } - }; - - static void ensure_func( bool /*bNew*/, item& i, int n ) - { - i.nVal = n * 1033; - } - - struct other_item - { - int nKey; - - other_item() - {} - - other_item(int n) - : nKey(n) - {} - }; - - struct other_less - { - template - bool operator()( T1 const& t1, T2 const& t2 ) const - { - return t1.nKey < t2.nKey; - } - }; - - protected: - template - void test_with( OrdList& l ) - { - typedef typename OrdList::value_type value_type; - - // The list should be empty - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.insert( 50 ) ); - CPPUNIT_ASSERT( l.insert( item( 25 )) ); - CPPUNIT_ASSERT( l.insert( item( 100 )) ); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.insert( 50 ) ); - CPPUNIT_ASSERT( !l.insert( item( 100 )) ); - - // clear test - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - // and now the list is empty - CPPUNIT_ASSERT( l.empty() ); - - // Test insert with functor - - CPPUNIT_ASSERT( l.insert( 100, insert_functor() ) ); - // passed by ref - { - insert_functor f; - CPPUNIT_ASSERT( l.insert( item( 25 ), std::ref( f ) ) ); - CPPUNIT_ASSERT( !l.insert( item( 100 ), std::ref( f ) ) ); - } - // Test insert with function - CPPUNIT_ASSERT( l.insert( 50, insert_function )); - CPPUNIT_ASSERT( !l.insert( 25, dummy_insert_function )); - CPPUNIT_ASSERT( !l.insert( 100, dummy_insert_functor() )); - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - - // Check inserted values - { - int i; - i = 100; - - CPPUNIT_ASSERT( l.find( 100 )); - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - { - check_value f(1033); - i = 25; - CPPUNIT_ASSERT( l.find_with( 25, lt() )); - CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( f ) ) ); - } - i = 50; - CPPUNIT_ASSERT( l.find( 50 )); - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - - i = 10; - CPPUNIT_ASSERT( !l.find_with( 10, lt() )); - CPPUNIT_ASSERT( !l.find_with( i, lt(), dummy_check_value() )); - i = 75; - CPPUNIT_ASSERT( !l.find( 75 )); - CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); - i = 150; - CPPUNIT_ASSERT( !l.find( 150 )); - CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); - } - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - // and now the list is empty - CPPUNIT_ASSERT( l.empty() ); - - // Ensure test - { - std::pair ensureResult; - ensure_functor f; - ensureResult = l.ensure( 100, ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - ensureResult = l.ensure( 200, std::ref( f ) ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - ensureResult = l.ensure( 50, ensure_func ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - int i; - i = 100; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - i = 50; - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - i = 200; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - - // ensure existing key - ensureResult = l.ensure( 200, ensure_func ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( !ensureResult.second ); - i = 200; - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - - ensureResult = l.ensure( 50, ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( !ensureResult.second ); - i = 50; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - } - - // erase test (list: 50, 100, 200) - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.insert(160)); - CPPUNIT_ASSERT( l.insert(250)); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.erase( 150 )); - - CPPUNIT_ASSERT( l.erase( 100 )); - CPPUNIT_ASSERT( !l.erase( 100 )); - - CPPUNIT_ASSERT( l.erase_with( 200, lt() )); - CPPUNIT_ASSERT( !l.erase_with( 200, lt() )); - - { - erase_functor ef; - CPPUNIT_ASSERT( ef.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase_with( 160, lt(), std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 1 ); - CPPUNIT_ASSERT( !l.erase_with( 160, lt(), std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 1 ); - - CPPUNIT_ASSERT( l.erase( 250, std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 2 ); - CPPUNIT_ASSERT( !l.erase( 250, std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 2 ); - } - - CPPUNIT_ASSERT( l.erase( 50 )); - CPPUNIT_ASSERT( !l.erase( 50 )); - - CPPUNIT_ASSERT( l.empty() ); - - // clear empty list - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - { - int i; - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) ); - CPPUNIT_ASSERT( l.emplace( 251, 152 )); - CPPUNIT_ASSERT( l.emplace( item( 1001 )) ); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); - CPPUNIT_ASSERT( !l.emplace( 251, 10) ); - - i = 501; - CPPUNIT_ASSERT( l.find( i, check_exact_value(501*2) )); - i = 251; - CPPUNIT_ASSERT( l.find( i, check_exact_value(152) )); - i = 1001; - CPPUNIT_ASSERT( l.find( i, check_exact_value(1001*2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert( i ) ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { - it->nVal = i * 2; - CPPUNIT_ASSERT( it->nKey == i ); - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.find( i, check_value(2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i) ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { - // it->nVal = i * 2 ; // not! - CPPUNIT_ASSERT( it->nKey == i ); - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.find_with( i, lt(), check_value(2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - } - - template - void test() - { - typedef typename OrdList::guarded_ptr guarded_ptr; - typedef typename OrdList::value_type value_type; - - OrdList l; - test_with( l ); - - static int const nLimit = 20; - int arr[nLimit]; - for ( int i = 0; i < nLimit; i++ ) - arr[i] = i; - std::random_shuffle( arr, arr + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i] ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - - gp = l.get( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey * 2 ); - gp.release(); - - gp = l.extract( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey*2 ); - gp.release(); - - gp = l.get( nKey ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( nKey)); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get(arr[0])); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( arr[0])); - CPPUNIT_CHECK( gp.empty()); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i] ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - other_item key( nKey ); - - gp = l.get_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey * 2 ); - gp.release(); - - gp = l.extract_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey*2 ); - gp.release(); - - gp = l.get_with( key, other_less() ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( key, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less())); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less())); - CPPUNIT_CHECK( gp.empty()); - } - - } - - template - void test_rcu() - { - OrdList l; - test_with( l ); - - static int const nLimit = 20; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( a[i] ) ); - - typename OrdList::exempt_ptr ep; - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[i] )); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - ep = l.extract( a[0] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( a[i] ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - other_item itm( a[i] ); - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - } - } - - template - void nogc_test() - { - typedef OrdList list; - typedef typename list::value_type value_type; - typedef std::pair ensure_result; - - typename list::iterator it; - - list l; - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( l.insert(50) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - - ensure_result eres = l.ensure( item(100, 33) ); - CPPUNIT_ASSERT( eres.second ); - CPPUNIT_ASSERT( eres.first != l.end() ); - CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); - - CPPUNIT_ASSERT( l.insert(100) == l.end() ); - eres = l.ensure( item(50, 33) ); - CPPUNIT_ASSERT( !eres.second ); - CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); - eres.first->nVal = 63; - - it = l.find( 33 ); - CPPUNIT_ASSERT( it == l.end() ); - - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 50 ); - CPPUNIT_ASSERT( it->nVal == 63 ); - - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 100 ); - CPPUNIT_ASSERT( it->nVal == 33 ); - - it = l.find_with( 150, lt() ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 150 ); - CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); - - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end()); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); - - it = l.find( 501 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 501 ); - CPPUNIT_ASSERT( it->nVal == 501 * 2 ); - - it = l.find_with( 251, lt() ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 251 ); - CPPUNIT_ASSERT( it->nVal == 152 ); - - it = l.find( 1001 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 1001 ); - CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - void HP_cmp(); - void HP_less(); - void HP_cmpmix(); - void HP_ic(); - - void DHP_cmp(); - void DHP_less(); - void DHP_cmpmix(); - void DHP_ic(); - - void RCU_GPI_cmp(); - void RCU_GPI_less(); - void RCU_GPI_cmpmix(); - void RCU_GPI_ic(); - - void RCU_GPB_cmp(); - void RCU_GPB_less(); - void RCU_GPB_cmpmix(); - void RCU_GPB_ic(); - - void RCU_GPT_cmp(); - void RCU_GPT_less(); - void RCU_GPT_cmpmix(); - void RCU_GPT_ic(); - - void RCU_SHB_cmp(); - void RCU_SHB_less(); - void RCU_SHB_cmpmix(); - void RCU_SHB_ic(); - - void RCU_SHT_cmp(); - void RCU_SHT_less(); - void RCU_SHT_cmpmix(); - void RCU_SHT_ic(); - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_cmpmix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(LazyListTestHeader) - CPPUNIT_TEST(HP_cmp) - CPPUNIT_TEST(HP_less) - CPPUNIT_TEST(HP_cmpmix) - CPPUNIT_TEST(HP_ic) - - CPPUNIT_TEST(DHP_cmp) - CPPUNIT_TEST(DHP_less) - CPPUNIT_TEST(DHP_cmpmix) - CPPUNIT_TEST(DHP_ic) - - CPPUNIT_TEST(RCU_GPI_cmp) - CPPUNIT_TEST(RCU_GPI_less) - CPPUNIT_TEST(RCU_GPI_cmpmix) - CPPUNIT_TEST(RCU_GPI_ic) - - CPPUNIT_TEST(RCU_GPB_cmp) - CPPUNIT_TEST(RCU_GPB_less) - CPPUNIT_TEST(RCU_GPB_cmpmix) - CPPUNIT_TEST(RCU_GPB_ic) - - CPPUNIT_TEST(RCU_GPT_cmp) - CPPUNIT_TEST(RCU_GPT_less) - CPPUNIT_TEST(RCU_GPT_cmpmix) - CPPUNIT_TEST(RCU_GPT_ic) - - CPPUNIT_TEST(RCU_SHB_cmp) - CPPUNIT_TEST(RCU_SHB_less) - CPPUNIT_TEST(RCU_SHB_cmpmix) - CPPUNIT_TEST(RCU_SHB_ic) - - CPPUNIT_TEST(RCU_SHT_cmp) - CPPUNIT_TEST(RCU_SHT_less) - CPPUNIT_TEST(RCU_SHT_cmpmix) - CPPUNIT_TEST(RCU_SHT_ic) - - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace ordlist - -#endif // #ifndef CDSTEST_HDR_LAZY_H \ No newline at end of file diff --git a/tests/test-hdr/ordered_list/hdr_lazy_dhp.cpp b/tests/test-hdr/ordered_list/hdr_lazy_dhp.cpp deleted file mode 100644 index 2ea4838e..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_dhp.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include - -namespace ordlist { - namespace { - struct DHP_cmp_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } - void LazyListTestHeader::DHP_cmp() - { - // traits-based version - typedef cc::LazyList< cds::gc::DHP, item, DHP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::DHP, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_less_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::DHP_less() - { - // traits-based version - typedef cc::LazyList< cds::gc::DHP, item, DHP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::DHP, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::DHP_cmpmix() - { - // traits-based version - typedef cc::LazyList< cds::gc::DHP, item, DHP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::DHP, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_ic_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::DHP_ic() - { - // traits-based version - typedef cc::LazyList< cds::gc::DHP, item, DHP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::DHP, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_hp.cpp b/tests/test-hdr/ordered_list/hdr_lazy_hp.cpp deleted file mode 100644 index 441ee6f1..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_hp.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include - -namespace ordlist { - namespace { - struct HP_cmp_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - - } - void LazyListTestHeader::HP_cmp() - { - // traits-based version - typedef cc::LazyList< cds::gc::HP, item, HP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::HP, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_less_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::HP_less() - { - // traits-based version - typedef cc::LazyList< cds::gc::HP, item, HP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::HP, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::HP_cmpmix() - { - // traits-based version - typedef cc::LazyList< cds::gc::HP, item, HP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::HP, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_ic_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::HP_ic() - { - // traits-based version - typedef cc::LazyList< cds::gc::HP, item, HP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::HP, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::LazyListTestHeader); diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv.h b/tests/test-hdr/ordered_list/hdr_lazy_kv.h deleted file mode 100644 index 653c2f7a..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv.h +++ /dev/null @@ -1,729 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_LAZY_KV_H -#define CDSTEST_HDR_LAZY_KV_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class LazyKVListTestHeader: public CppUnitMini::TestCase - { - public: - typedef int key_type; - struct value_type { - int m_val; - - value_type() - : m_val(0) - {} - - value_type( int n ) - : m_val( n ) - {} - }; - - template - struct lt - { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1 < v2; - } - }; - - template - struct cmp { - int operator ()(const T& v1, const T& v2 ) const - { - if ( v1 < v2 ) - return -1; - return v1 > v2 ? 1 : 0; - } - }; - - struct check_value { - int m_nExpected; - - check_value( int nExpected ) - : m_nExpected( nExpected ) - {} - - template - void operator ()( T& pair ) - { - CPPUNIT_ASSERT_CURRENT( pair.second.m_val == m_nExpected ); - } - }; - - struct insert_functor { - template - void operator()( T& pair ) - { - pair.second.m_val = pair.first * 10; - } - }; - - struct ensure_functor { - template - void operator()( bool /*bNew*/, T& pair ) - { - pair.second.m_val = pair.first * 50; - } - }; - - struct erase_functor { - int nKey; - int nVal; - - erase_functor() - : nKey(0) - , nVal(0) - {} - - template - void operator()( T& i ) - { - nKey = i.first; - nVal = i.second.m_val; - } - }; - - typedef float other_key; - struct other_less { - bool operator()( float f, int i ) const - { - return int(f) < i; - } - bool operator()( int i, float f ) const - { - return i < int(f); - } - }; - - protected: - template - void test_with( OrdList& l) - { - typedef typename OrdList::value_type value_type; - - typename OrdList::iterator itTest; - typename OrdList::const_iterator citTest; - - CPPUNIT_ASSERT( l.empty() ); - - // insert / find test - CPPUNIT_ASSERT( !l.find( 100 )); - CPPUNIT_ASSERT( l.insert( 100 )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.find( 100 )); - - check_value chk(0); - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - - CPPUNIT_ASSERT( !l.find_with( 50, lt() )); - CPPUNIT_ASSERT( l.insert( 50, 500 )); - CPPUNIT_ASSERT( l.find_with( 50, lt() )); - CPPUNIT_ASSERT( !l.insert( 50, 5 )); - chk.m_nExpected = 500; - CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); - chk.m_nExpected = 0; - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.find( 150 )); - CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() )); - CPPUNIT_ASSERT( l.find( 150 )); - chk.m_nExpected = 1500; - CPPUNIT_ASSERT( l.find_with( 150, lt(), std::ref( chk ) ) ); - chk.m_nExpected = 0; - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - chk.m_nExpected = 500; - CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); - CPPUNIT_ASSERT( !l.empty() ); - - // erase test - - CPPUNIT_ASSERT( !l.erase( 500 )); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.find( 50 )); - { - erase_functor ef; - l.erase( 50, std::ref( ef ) ); - CPPUNIT_ASSERT( ef.nKey == 50 ); - CPPUNIT_ASSERT( ef.nVal == 500 ); - } - CPPUNIT_ASSERT( !l.find( 50 )); - - // ensure test - std::pair bEnsureResult; - bEnsureResult = l.ensure( 100, ensure_functor() ); - CPPUNIT_ASSERT( bEnsureResult.first ); - CPPUNIT_ASSERT( !bEnsureResult.second ); - chk.m_nExpected = 5000; - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - - { - ensure_functor ef; - bEnsureResult = l.ensure( 50, std::ref( ef ) ); - } - CPPUNIT_ASSERT( bEnsureResult.first ); - CPPUNIT_ASSERT( bEnsureResult.second ); - chk.m_nExpected = 2500; - CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); - - // erase test - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() )); - CPPUNIT_ASSERT( l.insert( 25 )); - CPPUNIT_ASSERT( l.erase( 100 )); - CPPUNIT_ASSERT( l.erase( 150 )); - { - erase_functor ef; - CPPUNIT_ASSERT( l.erase_with( 200, lt(), std::ref(ef)) ); - CPPUNIT_ASSERT( ef.nKey == 200 ); - CPPUNIT_ASSERT( ef.nVal == 2000 ); - } - CPPUNIT_ASSERT( l.erase_with( 25, lt())) - CPPUNIT_ASSERT( l.erase( 50 )); - CPPUNIT_ASSERT( l.empty() ); - - // clear empty list - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) ); - CPPUNIT_ASSERT( l.emplace( 251, 152 )); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); - CPPUNIT_ASSERT( !l.emplace( 251, 10) ); - - check_value cv(0); - CPPUNIT_ASSERT( l.find( 501, std::ref(cv) )); - cv.m_nExpected = 152; - CPPUNIT_ASSERT( l.find( 251, std::ref(cv) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 2 ) ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it.val().m_val == i * 2 ); - it.val().m_val = i * 3; - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - chk.m_nExpected = i * 3; - CPPUNIT_ASSERT( l.find( i, std::ref( chk ) ) ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 7) ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it.val().m_val == i * 7 ); - } - - // Check that we have visited all items - for ( int i = nCount; i > 0; --i ) { - chk.m_nExpected = (i - 1) * 7; - CPPUNIT_ASSERT( l.find_with( i - 1, lt(), std::ref( chk ) ) ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - } - - template - void test() - { - OrdList l; - test_with(l); - - typedef typename OrdList::guarded_ptr guarded_ptr; - - static int const nLimit = 20; - int arr[nLimit]; - for ( int i = 0; i < nLimit; i++ ) - arr[i] = i; - std::random_shuffle( arr, arr + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i], arr[i] * 2 ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - - gp = l.get( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); - gp.release(); - - gp = l.extract( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); - gp.release(); - - gp = l.get( nKey ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( nKey)); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get(arr[0])); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( arr[0])); - CPPUNIT_CHECK( gp.empty()); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i], arr[i] * 2 ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - other_key key = float(nKey + 0.3); - - gp = l.get_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); - gp.release(); - - gp = l.extract_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); - gp.release(); - - gp = l.get_with( key, other_less() ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( key, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get_with(3.4f, other_less())); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - } - - template - void test_rcu() - { - OrdList l; - test_with(l); - - static int const nLimit = 20; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); - - typename OrdList::exempt_ptr ep; - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->first == a[i] ); - CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); - - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->first == a[i] ); - CPPUNIT_CHECK( (*ep).second.m_val == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - ep = l.extract( a[i] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[0] ) ); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - float itm = a[i] + 0.3f; - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->first == a[i] ); - CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); - - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->first == a[i] ); - CPPUNIT_CHECK( ep->second.m_val == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less()) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( 3.14f, other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - } - } - - template - void nogc_test() - { - typedef typename OrdList::value_type value_type; - typedef typename OrdList::iterator iterator; - - { - OrdList l; - iterator it; - - CPPUNIT_ASSERT( l.empty() ); - - // insert / find test - CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - CPPUNIT_ASSERT( l.find_with( 50, lt() ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - - CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); - CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); - it = l.find( 150 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 150 ); - CPPUNIT_ASSERT( it.val().m_val == 1500 ); - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - it.val().m_val = 25; - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 25 ); - CPPUNIT_ASSERT( !l.empty() ); - - // ensure existing item - std::pair ensureResult; - ensureResult = l.ensure( 100 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 5; - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 5 ); - - CPPUNIT_ASSERT( !l.empty() ); - - // ensure new item - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 33; - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); - - // clear test - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); - - it = l.find(501); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 501 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - it = l.find(251); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 251 ); - CPPUNIT_ASSERT( it.val().m_val == 152 ); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); - - iter.val().m_val = i * 3; - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - it = l.find( i ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it.val().m_val == i * 3 ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); - // it.val().m_val = i * 3 ; // error: const-iterator - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - } - } - - void HP_cmp(); - void HP_less(); - void HP_cmpmix(); - void HP_ic(); - - void DHP_cmp(); - void DHP_less(); - void DHP_cmpmix(); - void DHP_ic(); - - void RCU_GPI_cmp(); - void RCU_GPI_less(); - void RCU_GPI_cmpmix(); - void RCU_GPI_ic(); - - void RCU_GPB_cmp(); - void RCU_GPB_less(); - void RCU_GPB_cmpmix(); - void RCU_GPB_ic(); - - void RCU_GPT_cmp(); - void RCU_GPT_less(); - void RCU_GPT_cmpmix(); - void RCU_GPT_ic(); - - void RCU_SHB_cmp(); - void RCU_SHB_less(); - void RCU_SHB_cmpmix(); - void RCU_SHB_ic(); - - void RCU_SHT_cmp(); - void RCU_SHT_less(); - void RCU_SHT_cmpmix(); - void RCU_SHT_ic(); - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_cmpmix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(LazyKVListTestHeader) - CPPUNIT_TEST(HP_cmp) - CPPUNIT_TEST(HP_less) - CPPUNIT_TEST(HP_cmpmix) - CPPUNIT_TEST(HP_ic) - - CPPUNIT_TEST(DHP_cmp) - CPPUNIT_TEST(DHP_less) - CPPUNIT_TEST(DHP_cmpmix) - CPPUNIT_TEST(DHP_ic) - - CPPUNIT_TEST(RCU_GPI_cmp) - CPPUNIT_TEST(RCU_GPI_less) - CPPUNIT_TEST(RCU_GPI_cmpmix) - CPPUNIT_TEST(RCU_GPI_ic) - - CPPUNIT_TEST(RCU_GPB_cmp) - CPPUNIT_TEST(RCU_GPB_less) - CPPUNIT_TEST(RCU_GPB_cmpmix) - CPPUNIT_TEST(RCU_GPB_ic) - - CPPUNIT_TEST(RCU_GPT_cmp) - CPPUNIT_TEST(RCU_GPT_less) - CPPUNIT_TEST(RCU_GPT_cmpmix) - CPPUNIT_TEST(RCU_GPT_ic) - - CPPUNIT_TEST(RCU_SHB_cmp) - CPPUNIT_TEST(RCU_SHB_less) - CPPUNIT_TEST(RCU_SHB_cmpmix) - CPPUNIT_TEST(RCU_SHB_ic) - - CPPUNIT_TEST(RCU_SHT_cmp) - CPPUNIT_TEST(RCU_SHT_less) - CPPUNIT_TEST(RCU_SHT_cmpmix) - CPPUNIT_TEST(RCU_SHT_ic) - - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace ordlist - -#endif // #ifndef CDSTEST_HDR_LAZY_KV_H \ No newline at end of file diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_dhp.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_dhp.cpp deleted file mode 100644 index c3929e55..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_dhp.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include - -namespace ordlist { - namespace { - struct DHP_cmp_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } - void LazyKVListTestHeader::DHP_cmp() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::DHP_less() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::DHP_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::DHP_ic() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, DHP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::DHP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_hp.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_hp.cpp deleted file mode 100644 index 03fd8190..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_hp.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include - -namespace ordlist { - namespace { - struct HP_cmp_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - - } - void LazyKVListTestHeader::HP_cmp() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::HP, - key_type, - value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::HP_less() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::HP_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::HP_ic() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, HP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::HP, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::LazyKVListTestHeader); diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_nogc.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_nogc.cpp deleted file mode 100644 index 65e803b5..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_nogc.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include - -namespace ordlist { - namespace { - struct NOGC_cmp_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - - } - void LazyKVListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::nogc, - key_type, - value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyKVList< cds::gc::nogc, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpb.cpp deleted file mode 100644 index c8892120..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpb.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - - struct RCU_GPB_cmp_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } - void LazyKVListTestHeader::RCU_GPB_cmp() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPB_less() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPB_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::RCU_GPB_ic() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpi.cpp deleted file mode 100644 index 8da769bd..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpi.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - - struct RCU_GPI_cmp_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } - void LazyKVListTestHeader::RCU_GPI_cmp() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPI_less() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPI_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::RCU_GPI_ic() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPI_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpt.cpp deleted file mode 100644 index d9414797..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_gpt.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - - struct RCU_GPT_cmp_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } - void LazyKVListTestHeader::RCU_GPT_cmp() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPT_less() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } - void LazyKVListTestHeader::RCU_GPT_cmpmix() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_ic_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyKVListTestHeader::RCU_GPT_ic() - { - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_GPT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_shb.cpp deleted file mode 100644 index 221d6faa..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_shb.cpp +++ /dev/null @@ -1,122 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - - struct RCU_SHB_cmp_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } -#endif - - void LazyKVListTestHeader::RCU_SHB_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_less_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } -#endif - - void LazyKVListTestHeader::RCU_SHB_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } -#endif - - void LazyKVListTestHeader::RCU_SHB_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_ic_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - - void LazyKVListTestHeader::RCU_SHB_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_sht.cpp deleted file mode 100644 index a0a0f45f..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_kv_rcu_sht.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy_kv.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - - struct RCU_SHT_cmp_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - }; - } -#endif - void LazyKVListTestHeader::RCU_SHT_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_less_traits : public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - }; - } -#endif - void LazyKVListTestHeader::RCU_SHT_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::cmp compare; - typedef LazyKVListTestHeader::lt less; - }; - } -#endif - void LazyKVListTestHeader::RCU_SHT_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_ic_traits: public cc::lazy_list::traits - { - typedef LazyKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void LazyKVListTestHeader::RCU_SHT_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyKVList< rcu_type, key_type, value_type, RCU_SHT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyKVList< rcu_type, key_type, value_type, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_nogc.cpp b/tests/test-hdr/ordered_list/hdr_lazy_nogc.cpp deleted file mode 100644 index 6f7313ce..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_nogc.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include - -namespace ordlist { - namespace { - struct NOGC_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } - void LazyListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_ic_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::LazyList< cds::gc::nogc, item, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::LazyList< cds::gc::nogc, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpb.cpp deleted file mode 100644 index f640f9b4..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpb.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - - struct RCU_GPB_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } - void LazyListTestHeader::RCU_GPB_cmp() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPB_less() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPB_cmpmix() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_ic_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::RCU_GPB_ic() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpi.cpp deleted file mode 100644 index cf6cf19a..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpi.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - - struct RCU_GPI_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } - void LazyListTestHeader::RCU_GPI_cmp() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPI_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPI_less() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPI_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPI_cmpmix() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPI_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_ic_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::RCU_GPI_ic() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPI_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpt.cpp deleted file mode 100644 index a92ec111..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_rcu_gpt.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - - struct RCU_GPT_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } - void LazyListTestHeader::RCU_GPT_cmp() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPT_less() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_cmpmix_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } - void LazyListTestHeader::RCU_GPT_cmpmix() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_ic_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void LazyListTestHeader::RCU_GPT_ic() - { - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_GPT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_lazy_rcu_shb.cpp deleted file mode 100644 index 712c4860..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_rcu_shb.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - - struct RCU_SHB_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } -#endif - void LazyListTestHeader::RCU_SHB_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } -#endif - void LazyListTestHeader::RCU_SHB_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } -#endif - void LazyListTestHeader::RCU_SHB_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_ic_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void LazyListTestHeader::RCU_SHB_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_lazy_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_lazy_rcu_sht.cpp deleted file mode 100644 index 013d1b99..00000000 --- a/tests/test-hdr/ordered_list/hdr_lazy_rcu_sht.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_lazy.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - - struct RCU_SHT_cmp_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - }; - } -#endif - void LazyListTestHeader::RCU_SHT_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_less_traits : public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - }; - } -#endif - void LazyListTestHeader::RCU_SHT_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_cmpmix_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::cmp compare; - typedef LazyListTestHeader::lt less; - }; - } -#endif - void LazyListTestHeader::RCU_SHT_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_ic_traits: public cc::lazy_list::traits - { - typedef LazyListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void LazyListTestHeader::RCU_SHT_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::LazyList< rcu_type, item, RCU_SHT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::LazyList< rcu_type, item, - cc::lazy_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael.h b/tests/test-hdr/ordered_list/hdr_michael.h deleted file mode 100644 index c37eaa8e..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael.h +++ /dev/null @@ -1,820 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_MICHAEL_H -#define CDSTEST_HDR_MICHAEL_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class MichaelListTestHeader: public CppUnitMini::TestCase - { - public: - struct stat { - int nEnsureExistsCall; - int nEnsureNewCall; - - stat() - { - nEnsureExistsCall - = nEnsureNewCall - = 0; - } - }; - - struct item { - int nKey; - int nVal; - - stat s; - - item(int key) - : nKey( key ) - , nVal( key * 2 ) - , s() - {} - - item(int key, int val) - : nKey( key ) - , nVal(val) - , s() - {} - - item( const item& v ) - : nKey( v.nKey ) - , nVal( v.nVal ) - , s() - {} - - int key() const - { - return nKey; - } - }; - - template - struct lt - { - 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; - } - }; - - struct insert_functor { - void operator ()( item& i ) - { - i.nVal = i.nKey * 1033; - } - }; - struct dummy_insert_functor { - void operator ()( item& /*i*/ ) - { - // This functor should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_functor should not be called", __FILE__, __LINE__ ); - } - }; - - struct erase_functor { - unsigned int nEraseCall; - - erase_functor() - : nEraseCall(0) - {} - - void operator()( item const& /*i*/) - { - ++nEraseCall; - } - }; - - static void insert_function( item& i ) - { - i.nVal = i.nKey * 1024; - } - static void dummy_insert_function( item& /*i*/ ) - { - // This function should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_insert_function should not be called", __FILE__, __LINE__ ); - } - - - struct check_value { - unsigned int m_nMultiplier; - - check_value( unsigned int nMultiplier ) - : m_nMultiplier( nMultiplier ) - {} - - check_value( const check_value& s ) - : m_nMultiplier( s.m_nMultiplier ) - {} - - void operator()( item& i, int ) - { - CPPUNIT_ASSERT_CURRENT( int(i.nKey * m_nMultiplier) == i.nVal ); - } - }; - - struct check_exact_value { - int m_nExpected; - - check_exact_value( int nExpected ) - : m_nExpected( nExpected ) - {} - - check_exact_value( check_exact_value const& s) - : m_nExpected( s.m_nExpected ) - {} - - void operator()( item& i, int ) - { - CPPUNIT_ASSERT_CURRENT( i.nVal == m_nExpected ); - } - }; - - struct dummy_check_value { - void operator()( item& /*i*/, int ) - { - // This functor should not be called - TestCase::current_test()->error( "CPPUNIT_ASSERT", "dummy_check_value should not be called", __FILE__, __LINE__ ); - } - }; - - struct ensure_functor { - void operator()( bool /*bNew*/, item& i, int /*n*/ ) - { - i.nVal = i.nKey * 1024; - } - }; - - static void ensure_func( bool /*bNew*/, item& i, int n ) - { - i.nVal = n * 1033; - } - - struct other_item - { - int nKey; - - other_item() - {} - - other_item(int n) - : nKey(n) - {} - }; - - struct other_less - { - template - bool operator()( T1 const& t1, T2 const& t2 ) const - { - return t1.nKey < t2.nKey; - } - }; - - protected: - template - void test_with( OrdList& l ) - { - typedef typename OrdList::value_type value_type; - - // The list should be empty - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.insert( 50 ) ); - CPPUNIT_ASSERT( l.insert( item( 25 )) ); - CPPUNIT_ASSERT( l.insert( item( 100 )) ); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.insert( 50 ) ); - CPPUNIT_ASSERT( !l.insert( item( 100 )) ); - - // clear test - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - // and now the list is empty - CPPUNIT_ASSERT( l.empty() ); - - // Test insert with functor - - CPPUNIT_ASSERT( l.insert( 100, insert_functor() ) ); - // passed by ref - { - insert_functor f; - CPPUNIT_ASSERT( l.insert( item( 25 ), std::ref( f ) ) ); - CPPUNIT_ASSERT( !l.insert( item( 100 ), std::ref( f ) ) ); - } - // Test insert with function - CPPUNIT_ASSERT( l.insert( 50, insert_function )); - CPPUNIT_ASSERT( !l.insert( 25, dummy_insert_function )); - CPPUNIT_ASSERT( !l.insert( 100, dummy_insert_functor() )); - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - - // Check inserted values - { - int i; - i = 100; - CPPUNIT_ASSERT( l.find( 100 )); - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - { - check_value f(1033); - i = 25; - CPPUNIT_ASSERT( l.find_with( 25, lt() )); - CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( f ) ) ); - } - i = 50; - CPPUNIT_ASSERT( l.find( 50 )); - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - - i = 10; - CPPUNIT_ASSERT( !l.find_with( 10, lt() )); - CPPUNIT_ASSERT( !l.find_with( i, lt(), dummy_check_value() )); - i = 75; - CPPUNIT_ASSERT( !l.find( 75 )); - CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); - i = 150; - CPPUNIT_ASSERT( !l.find( 150 )); - CPPUNIT_ASSERT( !l.find( i, dummy_check_value() )); - } - - // The list should not be empty - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - // and now the list is empty - CPPUNIT_ASSERT( l.empty() ); - - // Ensure test - { - std::pair ensureResult; - ensure_functor f; - ensureResult = l.ensure( 100, ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - ensureResult = l.ensure( 200, std::ref( f ) ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - ensureResult = l.ensure( 50, ensure_func ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( ensureResult.second ); - - int i; - i = 100; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - i = 50; - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - i = 200; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - - // ensure existing key - ensureResult = l.ensure( 200, ensure_func ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( !ensureResult.second ); - i = 200; - CPPUNIT_ASSERT( l.find( i, check_value(1033) )); - - ensureResult = l.ensure( 50, ensure_functor() ); - CPPUNIT_ASSERT( ensureResult.first ); - CPPUNIT_ASSERT( !ensureResult.second ); - i = 50; - CPPUNIT_ASSERT( l.find( i, check_value(1024) )); - } - - // erase test (list: 50, 100, 200) - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.insert(160)); - CPPUNIT_ASSERT( l.insert(250)); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.erase( 150 )); - - CPPUNIT_ASSERT( l.erase( 100 )); - CPPUNIT_ASSERT( !l.erase( 100 )); - - CPPUNIT_ASSERT( l.erase_with( 200, lt() )); - CPPUNIT_ASSERT( !l.erase_with( 200, lt() )); - - { - erase_functor ef; - CPPUNIT_ASSERT( ef.nEraseCall == 0 ); - CPPUNIT_ASSERT( l.erase_with( 160, lt(), std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 1 ); - CPPUNIT_ASSERT( !l.erase_with( 160, lt(), std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 1 ); - - CPPUNIT_ASSERT( l.erase( 250, std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 2 ); - CPPUNIT_ASSERT( !l.erase( 250, std::ref(ef) )); - CPPUNIT_ASSERT( ef.nEraseCall == 2 ); - } - - CPPUNIT_ASSERT( l.erase( 50 )); - CPPUNIT_ASSERT( !l.erase( 50 )); - - CPPUNIT_ASSERT( l.empty() ); - - // clear empty list - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - { - int i; - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) ); - CPPUNIT_ASSERT( l.emplace( 251, 152 )); - CPPUNIT_ASSERT( l.emplace( item( 1001 )) ); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); - CPPUNIT_ASSERT( !l.emplace( 251, 10) ); - - i = 501; - CPPUNIT_ASSERT( l.find( i, check_exact_value(501*2) )); - i = 251; - CPPUNIT_ASSERT( l.find( i, check_exact_value(152) )); - i = 1001; - CPPUNIT_ASSERT( l.find( i, check_exact_value(1001*2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i) ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { - it->nVal = i * 2; - CPPUNIT_ASSERT( it->nKey == i ); - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.find( i, check_value(2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i) ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { - // it->nVal = i * 2 ; // not! - CPPUNIT_ASSERT( it->nKey == i ); - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.find( i, check_value(2) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - } - - template - void test() - { - typedef typename OrdList::guarded_ptr guarded_ptr; - typedef typename OrdList::value_type value_type; - - OrdList l; - test_with(l); - - static int const nLimit = 20; - int arr[nLimit]; - for ( int i = 0; i < nLimit; i++ ) - arr[i] = i; - std::random_shuffle( arr, arr + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i] ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - - gp = l.get( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey * 2 ); - gp.release(); - - gp = l.extract( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey*2 ); - gp.release(); - - gp = l.get( nKey ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( nKey)); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get(arr[0])); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( arr[0])); - CPPUNIT_CHECK( gp.empty()); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i] ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - other_item key( nKey ); - - gp = l.get_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey * 2 ); - gp.release(); - - gp = l.extract_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->nKey == nKey ); - CPPUNIT_CHECK( gp->nVal == nKey*2 ); - gp.release(); - - gp = l.get_with( key, other_less() ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( key, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less())); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less())); - CPPUNIT_CHECK( gp.empty()); - } - } - - template - void test_rcu() - { - OrdList l; - test_with(l); - - static int const nLimit = 20; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( a[i] ) ); - - typename OrdList::exempt_ptr ep; - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - ep = l.extract( a[i] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[0] ) ); - CPPUNIT_CHECK( ep.empty() ); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( a[i] ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - other_item itm( a[i] ); - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->nKey == a[i] ); - CPPUNIT_CHECK( pGet->nVal == a[i] * 2 ); - - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->nKey == a[i] ); - CPPUNIT_CHECK( ep->nVal == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( other_item( 0 ), other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( other_item(0), other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - } - - } - - template - void nogc_test() - { - typedef OrdList list; - typedef typename list::value_type value_type; - typedef std::pair ensure_result; - - typename list::iterator it; - - list l; - CPPUNIT_ASSERT( l.empty() ); - CPPUNIT_ASSERT( l.insert(50) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - - ensure_result eres = l.ensure( item(100, 33) ); - CPPUNIT_ASSERT( eres.second ); - CPPUNIT_ASSERT( eres.first != l.end() ); - CPPUNIT_ASSERT( l.insert( item(150) ) != l.end() ); - - CPPUNIT_ASSERT( l.insert(100) == l.end() ); - eres = l.ensure( item(50, 33) ); - CPPUNIT_ASSERT( !eres.second ); - CPPUNIT_ASSERT( eres.first->nVal == eres.first->nKey * 2 ); - eres.first->nVal = 63; - - it = l.find( 33 ); - CPPUNIT_ASSERT( it == l.end() ); - - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 50 ); - CPPUNIT_ASSERT( it->nVal == 63 ); - - it = l.find_with( 100, lt() ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 100 ); - CPPUNIT_ASSERT( it->nVal == 33 ); - - it = l.find( 150 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 150 ); - CPPUNIT_ASSERT( it->nVal == it->nKey * 2 ); - - CPPUNIT_ASSERT( !l.empty() ); - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end() ); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( item( 1001 )) != l.end() ); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end() ); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end() ); - - it = l.find( 501 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 501 ); - CPPUNIT_ASSERT( it->nVal == 501 * 2 ); - - it = l.find( 251 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 251 ); - CPPUNIT_ASSERT( it->nVal == 152 ); - - it = l.find( 1001 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it->nKey == 1001 ); - CPPUNIT_ASSERT( it->nVal == 1001 * 2 ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - void HP_cmp(); - void HP_less(); - void HP_cmpmix(); - void HP_ic(); - - void DHP_cmp(); - void DHP_less(); - void DHP_cmpmix(); - void DHP_ic(); - - void RCU_GPI_cmp(); - void RCU_GPI_less(); - void RCU_GPI_cmpmix(); - void RCU_GPI_ic(); - - void RCU_GPB_cmp(); - void RCU_GPB_less(); - void RCU_GPB_cmpmix(); - void RCU_GPB_ic(); - - void RCU_GPT_cmp(); - void RCU_GPT_less(); - void RCU_GPT_cmpmix(); - void RCU_GPT_ic(); - - void RCU_SHB_cmp(); - void RCU_SHB_less(); - void RCU_SHB_cmpmix(); - void RCU_SHB_ic(); - - void RCU_SHT_cmp(); - void RCU_SHT_less(); - void RCU_SHT_cmpmix(); - void RCU_SHT_ic(); - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_cmpmix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(MichaelListTestHeader) - CPPUNIT_TEST(HP_cmp) - CPPUNIT_TEST(HP_less) - CPPUNIT_TEST(HP_cmpmix) - CPPUNIT_TEST(HP_ic) - - CPPUNIT_TEST(DHP_cmp) - CPPUNIT_TEST(DHP_less) - CPPUNIT_TEST(DHP_cmpmix) - CPPUNIT_TEST(DHP_ic) - - CPPUNIT_TEST(RCU_GPI_cmp) - CPPUNIT_TEST(RCU_GPI_less) - CPPUNIT_TEST(RCU_GPI_cmpmix) - CPPUNIT_TEST(RCU_GPI_ic) - - CPPUNIT_TEST(RCU_GPB_cmp) - CPPUNIT_TEST(RCU_GPB_less) - CPPUNIT_TEST(RCU_GPB_cmpmix) - CPPUNIT_TEST(RCU_GPB_ic) - - CPPUNIT_TEST(RCU_GPT_cmp) - CPPUNIT_TEST(RCU_GPT_less) - CPPUNIT_TEST(RCU_GPT_cmpmix) - CPPUNIT_TEST(RCU_GPT_ic) - - CPPUNIT_TEST(RCU_SHB_cmp) - CPPUNIT_TEST(RCU_SHB_less) - CPPUNIT_TEST(RCU_SHB_cmpmix) - CPPUNIT_TEST(RCU_SHB_ic) - - CPPUNIT_TEST(RCU_SHT_cmp) - CPPUNIT_TEST(RCU_SHT_less) - CPPUNIT_TEST(RCU_SHT_cmpmix) - CPPUNIT_TEST(RCU_SHT_ic) - - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace ordlist - -#endif // #ifndef CDSTEST_HDR_MICHAEL_H diff --git a/tests/test-hdr/ordered_list/hdr_michael_dhp.cpp b/tests/test-hdr/ordered_list/hdr_michael_dhp.cpp deleted file mode 100644 index 7c6fd1d5..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_dhp.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include - -namespace ordlist { - namespace { - struct DHP_cmp_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } - void MichaelListTestHeader::DHP_cmp() - { - // traits-based version - typedef cc::MichaelList< cds::gc::DHP, item, DHP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::DHP, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_less_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::DHP_less() - { - // traits-based version - typedef cc::MichaelList< cds::gc::DHP, item, DHP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::DHP, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::DHP_cmpmix() - { - // traits-based version - typedef cc::MichaelList< cds::gc::DHP, item, DHP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::DHP, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_ic_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::DHP_ic() - { - // traits-based version - typedef cc::MichaelList< cds::gc::DHP, item, DHP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::DHP, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_hp.cpp b/tests/test-hdr/ordered_list/hdr_michael_hp.cpp deleted file mode 100644 index 132c0e06..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_hp.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include - -namespace ordlist { - namespace { - struct HP_cmp_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - - } - void MichaelListTestHeader::HP_cmp() - { - // traits-based version - typedef cc::MichaelList< cds::gc::HP, item, HP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::HP, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_less_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::HP_less() - { - // traits-based version - typedef cc::MichaelList< cds::gc::HP, item, HP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::HP, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::HP_cmpmix() - { - // traits-based version - typedef cc::MichaelList< cds::gc::HP, item, HP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::HP, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_ic_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::HP_ic() - { - // traits-based version - typedef cc::MichaelList< cds::gc::HP, item, HP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::HP, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::MichaelListTestHeader); diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv.h b/tests/test-hdr/ordered_list/hdr_michael_kv.h deleted file mode 100644 index 4f467b31..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv.h +++ /dev/null @@ -1,743 +0,0 @@ -//$$CDS-header$$ - -#ifndef CDSTEST_HDR_MICHAEL_KV_H -#define CDSTEST_HDR_MICHAEL_KV_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace ordlist { - namespace cc = cds::container; - namespace co = cds::container::opt; - - class MichaelKVListTestHeader: public CppUnitMini::TestCase - { - public: - typedef int key_type; - struct value_type { - int m_val; - - value_type() - : m_val(0) - {} - - value_type( int n ) - : m_val( n ) - {} - }; - - template - struct lt - { - bool operator ()(const T& v1, const T& v2 ) const - { - return v1 < v2; - } - }; - - template - struct cmp { - int operator ()(const T& v1, const T& v2 ) const - { - if ( v1 < v2 ) - return -1; - return v1 > v2 ? 1 : 0; - } - }; - - struct check_value { - int m_nExpected; - - check_value( int nExpected ) - : m_nExpected( nExpected ) - {} - - template - void operator ()( T& pair ) - { - CPPUNIT_ASSERT_CURRENT( pair.second.m_val == m_nExpected ); - } - }; - - struct insert_functor { - template - void operator()( T& pair ) - { - pair.second.m_val = pair.first * 10; - } - }; - - struct ensure_functor { - template - void operator()( bool /*bNew*/, T& pair ) - { - pair.second.m_val = pair.first * 50; - } - }; - - struct erase_functor { - int nKey; - int nVal; - - erase_functor() - : nKey(0) - , nVal(0) - {} - - template - void operator()( T& i ) - { - nKey = i.first; - nVal = i.second.m_val; - } - }; - - typedef float other_key; - struct other_less { - bool operator()( float f, int i ) const - { - return int(f) < i; - } - bool operator()( int i, float f ) const - { - return i < int(f); - } - }; - - protected: - template - void test_with( OrdList& l) - { - typedef typename OrdList::value_type value_type; - - typename OrdList::iterator itTest; - typename OrdList::const_iterator citTest; - - CPPUNIT_ASSERT( l.empty() ); - - // insert / find test - CPPUNIT_ASSERT( !l.find( 100 )); - CPPUNIT_ASSERT( l.insert( 100 )); - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.find( 100 )); - - check_value chk(0); - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - - CPPUNIT_ASSERT( !l.find_with( 50, lt() )); - CPPUNIT_ASSERT( l.insert( 50, 500 )); - CPPUNIT_ASSERT( l.find_with( 50, lt() )); - CPPUNIT_ASSERT( !l.insert( 50, 5 )); - chk.m_nExpected = 500; - CPPUNIT_ASSERT( l.find_with( 50, lt(), std::ref( chk ) ) ); - chk.m_nExpected = 0; - CPPUNIT_ASSERT( l.find_with( 100, lt(), std::ref( chk ) ) ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( !l.find( 150 )); - CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() )); - CPPUNIT_ASSERT( l.find( 150 )); - chk.m_nExpected = 1500; - CPPUNIT_ASSERT( l.find( 150, std::ref( chk ) ) ); - chk.m_nExpected = 0; - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - chk.m_nExpected = 500; - CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); - CPPUNIT_ASSERT( !l.empty() ); - - // erase test - - CPPUNIT_ASSERT( !l.erase( 500 )); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.find( 50 )); - { - erase_functor ef; - l.erase( 50, std::ref( ef ) ); - CPPUNIT_ASSERT( ef.nKey == 50 ); - CPPUNIT_ASSERT( ef.nVal == 500 ); - } - CPPUNIT_ASSERT( !l.find( 50 )); - - // ensure test - std::pair bEnsureResult; - bEnsureResult = l.ensure( 100, ensure_functor() ); - CPPUNIT_ASSERT( bEnsureResult.first ); - CPPUNIT_ASSERT( !bEnsureResult.second ); - chk.m_nExpected = 5000; - CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) ); - - { - ensure_functor ef; - bEnsureResult = l.ensure( 50, std::ref( ef ) ); - } - CPPUNIT_ASSERT( bEnsureResult.first ); - CPPUNIT_ASSERT( bEnsureResult.second ); - chk.m_nExpected = 2500; - CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) ); - - // erase test - CPPUNIT_ASSERT( !l.empty() ); - CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() )); - CPPUNIT_ASSERT( l.insert( 25 )); - CPPUNIT_ASSERT( l.erase( 100 )); - CPPUNIT_ASSERT( l.erase( 150 )); - { - erase_functor ef; - CPPUNIT_ASSERT( l.erase_with( 200, lt(), std::ref(ef)) ); - CPPUNIT_ASSERT( ef.nKey == 200 ); - CPPUNIT_ASSERT( ef.nVal == 2000 ); - } - CPPUNIT_ASSERT( l.erase_with( 25, lt())) - CPPUNIT_ASSERT( l.erase( 50 )); - CPPUNIT_ASSERT( l.empty() ); - - // clear empty list - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) ); - CPPUNIT_ASSERT( l.emplace( 251, 152 )); - - // insert failed - such key exists - CPPUNIT_ASSERT( !l.emplace( 501, 2 ) ); - CPPUNIT_ASSERT( !l.emplace( 251, 10) ); - - check_value cv(0); - CPPUNIT_ASSERT( l.find( 501, std::ref(cv) )); - cv.m_nExpected = 152; - CPPUNIT_ASSERT( l.find( 251, std::ref(cv) )); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 2 ) ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) { - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it->first == i ); - CPPUNIT_ASSERT( (*it).first == i ); - - CPPUNIT_ASSERT( it.val().m_val == i * 2 ); - CPPUNIT_ASSERT( it->second.m_val == i * 2 ); - CPPUNIT_ASSERT( (*it).second.m_val == i * 2 ); - it.val().m_val = i * 3; - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - chk.m_nExpected = i * 3; - CPPUNIT_ASSERT( l.find( i, std::ref( chk ) ) ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 7) ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator it = rl.begin(), itEnd = rl.end(); it != itEnd; ++it, ++i ) { - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it->first == i ); - CPPUNIT_ASSERT( (*it).first == i ); - - CPPUNIT_ASSERT( it.val().m_val == i * 7 ); - CPPUNIT_ASSERT( it->second.m_val == i * 7 ); - CPPUNIT_ASSERT( (*it).second.m_val == i * 7 ); - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - chk.m_nExpected = i * 7; - CPPUNIT_ASSERT( l.find_with( i, lt(), std::ref( chk ) ) ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - } - - template - void test() - { - OrdList l; - test_with(l); - - typedef typename OrdList::guarded_ptr guarded_ptr; - - static int const nLimit = 20; - int arr[nLimit]; - for ( int i = 0; i < nLimit; i++ ) - arr[i] = i; - std::random_shuffle( arr, arr + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i], arr[i] * 2 ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - - gp = l.get( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); - gp.release(); - CPPUNIT_CHECK( gp.empty() ); - - gp = l.extract( nKey ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); - gp.release(); - - gp = l.get( nKey ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( nKey)); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get(arr[0])); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract( arr[0])); - CPPUNIT_CHECK( gp.empty()); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) - l.insert( arr[i], arr[i] * 2 ); - { - guarded_ptr gp; - for ( int i = 0; i < nLimit; ++i ) { - int nKey = arr[i]; - other_key key = float(nKey + 0.3); - - gp = l.get_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey * 2 ); - gp.release(); - - gp = l.extract_with( key, other_less() ); - CPPUNIT_ASSERT( gp ); - CPPUNIT_ASSERT( !gp.empty()); - CPPUNIT_CHECK( gp->first == nKey ); - CPPUNIT_CHECK( gp->second.m_val == nKey*2 ); - gp.release(); - - gp = l.get_with( key, other_less() ); - CPPUNIT_CHECK( !gp ); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( key, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - CPPUNIT_ASSERT( l.empty()); - CPPUNIT_CHECK( !l.get_with( 3.4f, other_less())); - CPPUNIT_CHECK( gp.empty()); - CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less())); - CPPUNIT_CHECK( gp.empty()); - } - } - - template - void test_rcu() - { - OrdList l; - test_with(l); - - static int const nLimit = 20; - - typedef typename OrdList::rcu_lock rcu_lock; - typedef typename OrdList::value_type value_type; - typedef typename OrdList::gc rcu_type; - - { - int a[nLimit]; - for (int i = 0; i < nLimit; ++i) - a[i]=i; - std::random_shuffle( a, a + nLimit ); - - // extract/get - for ( int i = 0; i < nLimit; ++i ) - CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); - - typename OrdList::exempt_ptr ep; - - for ( int i = 0; i < nLimit; ++i ) { - { - rcu_lock lock; - value_type * pGet = l.get( a[i] ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->first == a[i] ); - CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); - - ep = l.extract( a[i] ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->first == a[i] ); - CPPUNIT_CHECK( (*ep).second.m_val == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[i] ) == nullptr ); - ep = l.extract( a[i] ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get( a[0] ) == nullptr ); - CPPUNIT_CHECK( !l.extract( a[0] ) ); - CPPUNIT_CHECK( ep.empty() ); - } - - // extract_with/get_with - for ( int i = 0; i < nLimit; ++i ) { - CPPUNIT_ASSERT( l.insert( a[i], a[i]*2 ) ); - } - - for ( int i = 0; i < nLimit; ++i ) { - float itm = a[i] + 0.3f; - { - rcu_lock lock; - value_type * pGet = l.get_with( itm, other_less() ); - CPPUNIT_ASSERT( pGet != nullptr ); - CPPUNIT_CHECK( pGet->first == a[i] ); - CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 ); - - ep = l.extract_with( itm, other_less() ); - CPPUNIT_ASSERT( ep ); - CPPUNIT_ASSERT( !ep.empty() ); - CPPUNIT_CHECK( ep->first == a[i] ); - CPPUNIT_CHECK( ep->second.m_val == a[i] * 2 ); - } - ep.release(); - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr ); - ep = l.extract_with( itm, other_less() ); - CPPUNIT_CHECK( !ep ); - CPPUNIT_CHECK( ep.empty() ); - } - } - CPPUNIT_ASSERT( l.empty() ); - - { - rcu_lock lock; - CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == nullptr ); - CPPUNIT_CHECK( !l.extract_with( 3.14f, other_less() )); - CPPUNIT_CHECK( ep.empty() ); - } - } - - } - - template - void nogc_test() - { - typedef typename OrdList::value_type value_type; - typedef typename OrdList::iterator iterator; - - { - OrdList l; - iterator it; - - CPPUNIT_ASSERT( l.empty() ); - - // insert / find test - CPPUNIT_ASSERT( l.find( 100 ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 100 ) != l.end() ); - CPPUNIT_ASSERT( !l.empty() ); - it = l.find_with( 100, lt() ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - CPPUNIT_ASSERT( l.find_with( 50, lt() ) == l.end() ); - CPPUNIT_ASSERT( l.insert( 50, 500 ) != l.end()); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - - CPPUNIT_ASSERT( l.insert( 50, 5 ) == l.end() ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - CPPUNIT_ASSERT( !l.empty() ); - - CPPUNIT_ASSERT( l.find( 150 ) == l.end() ); - CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() ); - it = l.find( 150 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 150 ); - CPPUNIT_ASSERT( it.val().m_val == 1500 ); - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 500 ); - it.val().m_val = 25; - it = l.find( 50 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 50 ); - CPPUNIT_ASSERT( it.val().m_val == 25 ); - CPPUNIT_ASSERT( !l.empty() ); - - // ensure existing item - std::pair ensureResult; - ensureResult = l.ensure( 100 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 100 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 5; - it = l.find( 100 ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == 100 ); - CPPUNIT_ASSERT( it.val().m_val == 5 ); - - CPPUNIT_ASSERT( !l.empty() ); - - // ensure new item - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 0 ); - ensureResult.first.val().m_val = 33; - ensureResult = l.ensure( 1000 ); - CPPUNIT_ASSERT( !ensureResult.second ); - CPPUNIT_ASSERT( ensureResult.first.key() == 1000 ); - CPPUNIT_ASSERT( ensureResult.first.val().m_val == 33 ); - - // clear test - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // insert test - CPPUNIT_ASSERT( l.emplace( 501 ) != l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end()); - - // insert failed - such key exists - CPPUNIT_ASSERT( l.emplace( 501, 2 ) == l.end()); - CPPUNIT_ASSERT( l.emplace( 251, 10) == l.end()); - - it = l.find( 501 ); - CPPUNIT_ASSERT( it != l.end()); - CPPUNIT_ASSERT( it.key() == 501 ); - CPPUNIT_ASSERT( it.val().m_val == 0 ); - - it = l.find( 251 ); - CPPUNIT_ASSERT( it != l.end()); - CPPUNIT_ASSERT( it.key() == 251 ); - CPPUNIT_ASSERT( it.val().m_val == 152 ); - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Iterator test - { - int nCount = 100; - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() ); - - { - typename OrdList::iterator it( l.begin() ); - typename OrdList::const_iterator cit( l.cbegin() ); - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++it; - CPPUNIT_CHECK( it != cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - ++cit; - CPPUNIT_CHECK( it == cit ); - CPPUNIT_CHECK( it != l.end() ); - CPPUNIT_CHECK( it != l.cend() ); - CPPUNIT_CHECK( cit != l.end() ); - CPPUNIT_CHECK( cit != l.cend() ); - } - - int i = 0; - for ( typename OrdList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 2 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 2 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 2 ); - - iter.val().m_val = i * 3; - } - - // Check that we have visited all items - for ( int i = 0; i < nCount; ++i ) { - it = l.find( i ); - CPPUNIT_ASSERT( it != l.end() ); - CPPUNIT_ASSERT( it.key() == i ); - CPPUNIT_ASSERT( it.val().m_val == i * 3 ); - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - - // Const iterator - for ( int i = 0; i < nCount; ++i ) - CPPUNIT_ASSERT( l.insert(i, i * 7) != l.end() ); - - i = 0; - const OrdList& rl = l; - for ( typename OrdList::const_iterator iter = rl.begin(), itEnd = rl.end(); iter != itEnd; ++iter, ++i ) { - CPPUNIT_ASSERT( iter.key() == i ); - CPPUNIT_ASSERT( iter->first == i ); - CPPUNIT_ASSERT( (*iter).first == i ); - - CPPUNIT_ASSERT( iter.val().m_val == i * 7 ); - CPPUNIT_ASSERT( iter->second.m_val == i * 7 ); - CPPUNIT_ASSERT( (*iter).second.m_val == i * 7 ); - - // it.val().m_val = i * 3 ; // error: const-iterator - } - - l.clear(); - CPPUNIT_ASSERT( l.empty() ); - } - - } - } - - void HP_cmp(); - void HP_less(); - void HP_cmpmix(); - void HP_ic(); - - void DHP_cmp(); - void DHP_less(); - void DHP_cmpmix(); - void DHP_ic(); - - void RCU_GPI_cmp(); - void RCU_GPI_less(); - void RCU_GPI_cmpmix(); - void RCU_GPI_ic(); - - void RCU_GPB_cmp(); - void RCU_GPB_less(); - void RCU_GPB_cmpmix(); - void RCU_GPB_ic(); - - void RCU_GPT_cmp(); - void RCU_GPT_less(); - void RCU_GPT_cmpmix(); - void RCU_GPT_ic(); - - void RCU_SHB_cmp(); - void RCU_SHB_less(); - void RCU_SHB_cmpmix(); - void RCU_SHB_ic(); - - void RCU_SHT_cmp(); - void RCU_SHT_less(); - void RCU_SHT_cmpmix(); - void RCU_SHT_ic(); - - void NOGC_cmp(); - void NOGC_less(); - void NOGC_cmpmix(); - void NOGC_ic(); - - CPPUNIT_TEST_SUITE(MichaelKVListTestHeader) - CPPUNIT_TEST(HP_cmp) - CPPUNIT_TEST(HP_less) - CPPUNIT_TEST(HP_cmpmix) - CPPUNIT_TEST(HP_ic) - - CPPUNIT_TEST(DHP_cmp) - CPPUNIT_TEST(DHP_less) - CPPUNIT_TEST(DHP_cmpmix) - CPPUNIT_TEST(DHP_ic) - - CPPUNIT_TEST(RCU_GPI_cmp) - CPPUNIT_TEST(RCU_GPI_less) - CPPUNIT_TEST(RCU_GPI_cmpmix) - CPPUNIT_TEST(RCU_GPI_ic) - - CPPUNIT_TEST(RCU_GPB_cmp) - CPPUNIT_TEST(RCU_GPB_less) - CPPUNIT_TEST(RCU_GPB_cmpmix) - CPPUNIT_TEST(RCU_GPB_ic) - - CPPUNIT_TEST(RCU_GPT_cmp) - CPPUNIT_TEST(RCU_GPT_less) - CPPUNIT_TEST(RCU_GPT_cmpmix) - CPPUNIT_TEST(RCU_GPT_ic) - - CPPUNIT_TEST(RCU_SHB_cmp) - CPPUNIT_TEST(RCU_SHB_less) - CPPUNIT_TEST(RCU_SHB_cmpmix) - CPPUNIT_TEST(RCU_SHB_ic) - - CPPUNIT_TEST(RCU_SHT_cmp) - CPPUNIT_TEST(RCU_SHT_less) - CPPUNIT_TEST(RCU_SHT_cmpmix) - CPPUNIT_TEST(RCU_SHT_ic) - - CPPUNIT_TEST(NOGC_cmp) - CPPUNIT_TEST(NOGC_less) - CPPUNIT_TEST(NOGC_cmpmix) - CPPUNIT_TEST(NOGC_ic) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace ordlist - -#endif // #ifndef CDSTEST_HDR_MICHAEL_KV_H diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_dhp.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_dhp.cpp deleted file mode 100644 index e26c6b7d..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_dhp.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include - -namespace ordlist { - namespace { - struct DHP_cmp_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } - void MichaelKVListTestHeader::DHP_cmp() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_less_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::DHP_less() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::DHP_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct DHP_ic_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::DHP_ic() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, DHP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::DHP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_hp.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_hp.cpp deleted file mode 100644 index 12012ed0..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_hp.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include - -namespace ordlist { - namespace { - struct HP_cmp_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - - } - void MichaelKVListTestHeader::HP_cmp() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_cmp_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::HP, - key_type, - value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_less_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::HP_less() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_less_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::HP_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test< opt_list >(); - } - - namespace { - struct HP_ic_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::HP_ic() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, HP_ic_traits > list; - test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::HP, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test< opt_list >(); - } - -} // namespace ordlist - -CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::MichaelKVListTestHeader); diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_nogc.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_nogc.cpp deleted file mode 100644 index cf654a92..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_nogc.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include - -namespace ordlist { - namespace { - struct NOGC_cmp_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - - } - void MichaelKVListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::nogc, - key_type, - value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_ic_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelKVList< cds::gc::nogc, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpb.cpp deleted file mode 100644 index 658a5efc..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpb.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - struct RCU_GPB_cmp_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } - void MichaelKVListTestHeader::RCU_GPB_cmp() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_less_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPB_less() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPB_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_ic_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::RCU_GPB_ic() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpi.cpp deleted file mode 100644 index fc080635..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpi.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - struct RCU_GPI_cmp_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } - void MichaelKVListTestHeader::RCU_GPI_cmp() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_less_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPI_less() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPI_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_ic_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::RCU_GPI_ic() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPI_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpt.cpp deleted file mode 100644 index 383c0857..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_gpt.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - struct RCU_GPT_cmp_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } - void MichaelKVListTestHeader::RCU_GPT_cmp() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_less_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPT_less() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } - void MichaelKVListTestHeader::RCU_GPT_cmpmix() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_ic_traits : public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelKVListTestHeader::RCU_GPT_ic() - { - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_shb.cpp deleted file mode 100644 index 21f65ae3..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_shb.cpp +++ /dev/null @@ -1,117 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - struct RCU_SHB_cmp_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHB_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_less_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHB_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHB_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_ic_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHB_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_sht.cpp deleted file mode 100644 index 360fe14c..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_kv_rcu_sht.cpp +++ /dev/null @@ -1,117 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael_kv.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - struct RCU_SHT_cmp_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHT_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_less_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHT_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::cmp compare; - typedef MichaelKVListTestHeader::lt less; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHT_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_ic_traits: public cc::michael_list::traits - { - typedef MichaelKVListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void MichaelKVListTestHeader::RCU_SHT_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_SHT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelKVList< rcu_type, key_type, value_type, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_michael_nogc.cpp b/tests/test-hdr/ordered_list/hdr_michael_nogc.cpp deleted file mode 100644 index 1c28490b..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_nogc.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include - -namespace ordlist { - namespace { - struct NOGC_cmp_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } - void MichaelListTestHeader::NOGC_cmp() - { - // traits-based version - typedef cc::MichaelList< cds::gc::nogc, item, NOGC_cmp_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::nogc, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_less_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::NOGC_less() - { - // traits-based version - typedef cc::MichaelList< cds::gc::nogc, item, NOGC_less_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::nogc, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::NOGC_cmpmix() - { - // traits-based version - typedef cc::MichaelList< cds::gc::nogc, item, NOGC_cmpmix_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::nogc, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - nogc_test< opt_list >(); - } - - namespace { - struct NOGC_ic_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::NOGC_ic() - { - // traits-based version - typedef cc::MichaelList< cds::gc::nogc, item, NOGC_ic_traits > list; - nogc_test< list >(); - - // option-based version - - typedef cc::MichaelList< cds::gc::nogc, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - nogc_test< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpb.cpp b/tests/test-hdr/ordered_list/hdr_michael_rcu_gpb.cpp deleted file mode 100644 index 75c1e94c..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpb.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_type; - - struct RCU_GPB_cmp_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } - - void MichaelListTestHeader::RCU_GPB_cmp() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_less_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPB_less() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPB_cmpmix() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPB_ic_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::RCU_GPB_ic() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpi.cpp b/tests/test-hdr/ordered_list/hdr_michael_rcu_gpi.cpp deleted file mode 100644 index 5d912b10..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpi.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_type; - - struct RCU_GPI_cmp_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } - - void MichaelListTestHeader::RCU_GPI_cmp() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPI_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_less_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPI_less() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPI_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPI_cmpmix() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPI_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPI_ic_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::RCU_GPI_ic() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPI_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpt.cpp b/tests/test-hdr/ordered_list/hdr_michael_rcu_gpt.cpp deleted file mode 100644 index beee1042..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_rcu_gpt.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include -#include - -namespace ordlist { - namespace { - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; - - struct RCU_GPT_cmp_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } - - void MichaelListTestHeader::RCU_GPT_cmp() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_less_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPT_less() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } - void MichaelListTestHeader::RCU_GPT_cmpmix() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); - } - - namespace { - struct RCU_GPT_ic_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } - void MichaelListTestHeader::RCU_GPT_ic() - { - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_GPT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); - } - -} // namespace ordlist - diff --git a/tests/test-hdr/ordered_list/hdr_michael_rcu_shb.cpp b/tests/test-hdr/ordered_list/hdr_michael_rcu_shb.cpp deleted file mode 100644 index 19632db7..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_rcu_shb.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_type; - - struct RCU_SHB_cmp_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } -#endif - - void MichaelListTestHeader::RCU_SHB_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_less_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } -#endif - void MichaelListTestHeader::RCU_SHB_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHB_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } -#endif - void MichaelListTestHeader::RCU_SHB_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHB_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHB_ic_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void MichaelListTestHeader::RCU_SHB_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHB_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist diff --git a/tests/test-hdr/ordered_list/hdr_michael_rcu_sht.cpp b/tests/test-hdr/ordered_list/hdr_michael_rcu_sht.cpp deleted file mode 100644 index 7c74813d..00000000 --- a/tests/test-hdr/ordered_list/hdr_michael_rcu_sht.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//$$CDS-header$$ - -#include "ordered_list/hdr_michael.h" -#include -#include - -namespace ordlist { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_type; - - struct RCU_SHT_cmp_traits : public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - }; - } -#endif - - void MichaelListTestHeader::RCU_SHT_cmp() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHT_cmp_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_less_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - }; - } -#endif - void MichaelListTestHeader::RCU_SHT_less() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHT_less_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_cmpmix_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::cmp compare; - typedef MichaelListTestHeader::lt less; - }; - } -#endif - void MichaelListTestHeader::RCU_SHT_cmpmix() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHT_cmpmix_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::compare< cmp > - ,cc::opt::less< lt > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - namespace { - struct RCU_SHT_ic_traits: public cc::michael_list::traits - { - typedef MichaelListTestHeader::lt less; - typedef cds::atomicity::item_counter item_counter; - }; - } -#endif - void MichaelListTestHeader::RCU_SHT_ic() - { -#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - // traits-based version - typedef cc::MichaelList< rcu_type, item, RCU_SHT_ic_traits > list; - test_rcu< list >(); - - // option-based version - - typedef cc::MichaelList< rcu_type, item, - cc::michael_list::make_traits< - cc::opt::less< lt > - ,cc::opt::item_counter< cds::atomicity::item_counter > - >::type - > opt_list; - test_rcu< opt_list >(); -#endif - } - -} // namespace ordlist