Start to migrate map unit test to gtest
authorkhizmax <libcds.dev@gmail.com>
Sun, 27 Mar 2016 19:51:17 +0000 (22:51 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 27 Mar 2016 19:51:17 +0000 (22:51 +0300)
projects/Win/vc14/cds.sln
projects/Win/vc14/gtest-map.vcxproj [new file with mode: 0644]
projects/Win/vc14/gtest-map.vcxproj.filters [new file with mode: 0644]
test/unit/CMakeLists.txt
test/unit/map/CMakeLists.txt [new file with mode: 0644]
test/unit/map/michael_michael_dhp.cpp [new file with mode: 0644]
test/unit/map/michael_michael_hp.cpp [new file with mode: 0644]
test/unit/map/test_map.h [new file with mode: 0644]
test/unit/map/test_map_hp.h [new file with mode: 0644]
test/unit/set/michael_michael_hp.cpp

index 315add172646ed700602039716728e1f6a4f20ac..78b4e83f66de876f797fc128f943f208b6cebe62 100644 (file)
@@ -204,6 +204,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-intrusive-set", "gtes
        EndProjectSection\r
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-striped-set", "gtest-striped-set.vcxproj", "{648021D3-6E18-4B94-88B8-F6A59609E210}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-map", "gtest-map.vcxproj", "{42B7E892-DDDA-4D00-9AB7-378E0E7E9433}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239}\r
+       EndProjectSection\r
 EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
@@ -527,6 +535,18 @@ Global
                {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|Win32.Build.0 = Release|Win32\r
                {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|x64.ActiveCfg = Release|x64\r
                {648021D3-6E18-4B94-88B8-F6A59609E210}.Release|x64.Build.0 = Release|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Debug|Win32.Build.0 = Debug|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Debug|x64.ActiveCfg = Debug|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Debug|x64.Build.0 = Debug|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.DebugVLD|Win32.Build.0 = DebugVLD|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.DebugVLD|x64.ActiveCfg = DebugVLD|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.DebugVLD|x64.Build.0 = DebugVLD|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Release|Win32.ActiveCfg = Release|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Release|Win32.Build.0 = Release|Win32\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Release|x64.ActiveCfg = Release|x64\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433}.Release|x64.Build.0 = Release|x64\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
@@ -559,6 +579,7 @@ Global
                {A589D3F1-A749-4268-ADEC-D0CE13D1E359} = {810490B7-31E5-49AE-8455-CAF99A9658B6}\r
                {EC1EF263-7E34-4867-9ED9-77AA7963CD4A} = {810490B7-31E5-49AE-8455-CAF99A9658B6}\r
                {648021D3-6E18-4B94-88B8-F6A59609E210} = {810490B7-31E5-49AE-8455-CAF99A9658B6}\r
+               {42B7E892-DDDA-4D00-9AB7-378E0E7E9433} = {810490B7-31E5-49AE-8455-CAF99A9658B6}\r
        EndGlobalSection\r
        GlobalSection(DPCodeReviewSolutionGUID) = preSolution\r
                DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}\r
diff --git a/projects/Win/vc14/gtest-map.vcxproj b/projects/Win/vc14/gtest-map.vcxproj
new file mode 100644 (file)
index 0000000..5f73f33
--- /dev/null
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="DebugVLD|Win32">\r
+      <Configuration>DebugVLD</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="DebugVLD|x64">\r
+      <Configuration>DebugVLD</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\..\test\unit\main.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_michael_dhp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_michael_hp.cpp" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\..\test\unit\map\test_map.h" />\r
+    <ClInclude Include="..\..\..\test\unit\map\test_map_hp.h" />\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{42B7E892-DDDA-4D00-9AB7-378E0E7E9433}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>map</RootNamespace>\r
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>Application</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>v140</PlatformToolset>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="Shared">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+    <TargetName>$(ProjectName)_d</TargetName>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+    <TargetName>$(ProjectName)_d</TargetName>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+    <TargetName>$(ProjectName)_d</TargetName>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+    <TargetName>$(ProjectName)_d</TargetName>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+    <OutDir>$(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\</OutDir>\r
+    <IntDir>$(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Console</SubSystem>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <AdditionalLibraryDirectories>$(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir)</AdditionalLibraryDirectories>\r
+      <AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/projects/Win/vc14/gtest-map.vcxproj.filters b/projects/Win/vc14/gtest-map.vcxproj.filters
new file mode 100644 (file)
index 0000000..69cfb7d
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+    <Filter Include="Source Files\MichaelMap">\r
+      <UniqueIdentifier>{12baf500-5c1c-44a7-9bac-e0554eb93b1a}</UniqueIdentifier>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\..\test\unit\main.cpp">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_michael_hp.cpp">\r
+      <Filter>Source Files\MichaelMap</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_michael_dhp.cpp">\r
+      <Filter>Source Files\MichaelMap</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\..\test\unit\map\test_map.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\map\test_map_hp.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
index 1d4e933fe6862422f2de06e8f2f3216b75c301b8..20a12b2c6c73bd267825385e819b96d4104a2da4 100644 (file)
@@ -1,5 +1,6 @@
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deque)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/list)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/map)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/queue)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/intrusive-set)
@@ -11,6 +12,7 @@ add_custom_target(unit-all
     DEPENDS 
         unit-deque
         unit-list
+        unit-map
         unit-pqueue
         unit-queue
         unit-intrusive-set
diff --git a/test/unit/map/CMakeLists.txt b/test/unit/map/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f62bf96
--- /dev/null
@@ -0,0 +1,22 @@
+set(PACKAGE_NAME unit-map)
+
+set(CDSGTEST_MAP_SOURCES
+    ../main.cpp
+    michael_michael_hp.cpp
+    michael_michael_dhp.cpp
+)
+
+include_directories(
+    ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+add_executable(${PACKAGE_NAME} ${CDSGTEST_MAP_SOURCES})
+target_link_libraries(${PACKAGE_NAME} 
+    ${CDS_SHARED_LIBRARY}
+    ${GTEST_LIBRARY}
+    ${Boost_THREAD_LIBRARY}
+    ${Boost_SYSTEM_LIBRARY}
+    ${CMAKE_THREAD_LIBS_INIT}
+)
+
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
diff --git a/test/unit/map/michael_michael_dhp.cpp b/test/unit/map/michael_michael_dhp.cpp
new file mode 100644 (file)
index 0000000..9416235
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+*/
+
+#include "test_map_hp.h"
+
+#include <cds/container/michael_kvlist_dhp.h>
+#include <cds/container/michael_map.h>
+
+namespace {
+
+    namespace cc = cds::container;
+    typedef cds::gc::DHP gc_type;
+
+    class MichaelMap_DHP: public cds_test::container_map_hp
+    {
+    protected:
+        typedef cds_test::container_map_hp base_class;
+
+        void SetUp()
+        {
+            typedef cc::MichaelKVList< gc_type, key_type, value_type > list_type;
+            typedef cc::MichaelHashMap< gc_type, list_type >   map_type;
+
+            cds::gc::dhp::GarbageCollector::Construct( 16, map_type::c_nHazardPtrCount );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::dhp::GarbageCollector::Destruct();
+        }
+    };
+
+    TEST_F( MichaelMap_DHP, compare )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_DHP, less )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< less >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 1 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_DHP, cmpmix )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< less >
+                ,cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_DHP, backoff )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::exponential<cds::backoff::pause, cds::backoff::yield> back_off;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 4 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_DHP, seq_cst )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+} // namespace
+
diff --git a/test/unit/map/michael_michael_hp.cpp b/test/unit/map/michael_michael_hp.cpp
new file mode 100644 (file)
index 0000000..b69aa59
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+*/
+
+#include "test_map_hp.h"
+
+#include <cds/container/michael_kvlist_hp.h>
+#include <cds/container/michael_map.h>
+
+namespace {
+
+    namespace cc = cds::container;
+    typedef cds::gc::HP gc_type;
+
+    class MichaelMap_HP: public cds_test::container_map_hp
+    {
+    protected:
+        typedef cds_test::container_map_hp base_class;
+
+        void SetUp()
+        {
+            typedef cc::MichaelKVList< gc_type, key_type, value_type > list_type;
+            typedef cc::MichaelHashMap< gc_type, list_type >   map_type;
+
+            // +1 - for guarded_ptr and iterator
+            cds::gc::hp::GarbageCollector::Construct( map_type::c_nHazardPtrCount + 1, 1, 16 );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct( true );
+        }
+    };
+
+    TEST_F( MichaelMap_HP, compare )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_HP, less )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< less >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 1 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_HP, cmpmix )
+    {
+        typedef cc::MichaelKVList< gc_type, key_type, value_type,
+            typename cc::michael_list::make_traits<
+                cds::opt::less< less >
+                ,cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_HP, backoff )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::exponential<cds::backoff::pause, cds::backoff::yield> back_off;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 4 );
+        test( m );
+    }
+
+    TEST_F( MichaelMap_HP, seq_cst )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+} // namespace
+
diff --git a/test/unit/map/test_map.h b/test/unit/map/test_map.h
new file mode 100644 (file)
index 0000000..3253705
--- /dev/null
@@ -0,0 +1,574 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+*/
+
+#ifndef CDSUNIT_MAP_TEST_MAP_H
+#define CDSUNIT_MAP_TEST_MAP_H
+
+#include <cds_test/check_size.h>
+#include <cds_test/fixture.h>
+
+#include <cds/opt/hash.h>
+
+// forward declaration
+namespace cds { namespace container {} }
+
+namespace cds_test {
+
+    class container_map: public fixture
+    {
+    public:
+        static size_t const kSize = 1000;
+
+        struct key_type {
+            int nKey;
+
+            explicit key_type( int n )
+                : nKey( n )
+            {}
+
+            explicit key_type( std::string const& str )
+                : nKey( std::stoi( str ))
+            {}
+        };
+
+        struct value_type {
+            int nVal;
+            std::string strVal;
+
+            value_type()
+                : nVal( 0 )
+            {}
+
+            explicit value_type( int n )
+                : nVal( n )
+                , strVal( std::to_string( n ))
+            {}
+
+            explicit value_type( std::string const& str )
+                : nVal( std::stoi( str ))
+                , strVal( str )
+            {}
+
+            explicit value_type( std::string&& str )
+                : nVal( std::stoi( str ))
+                , strVal( std::move( str ))
+            {}
+
+            value_type( int n, std::string const& str )
+                : nVal( n )
+                , strVal( str )
+            {}
+
+            value_type( int n, std::string&& str )
+                : nVal( n )
+                , strVal( std::move( str ))
+            {}
+
+            value_type( value_type&& v )
+                : nVal( v.nVal )
+                , strVal( std::move( v.strVal ))
+            {}
+
+            value_type( value_type const& v )
+                : nVal( v.nVal )
+                , strVal( v.strVal )
+            {}
+
+            value_type& operator=( value_type const& v )
+            {
+                if ( this != &v ) {
+                    nVal = v.nVal;
+                    strVal = v.strVal;
+                }
+                return *this;
+            }
+
+            value_type& operator=( value_type&& v )
+            {
+                if ( this != &v ) {
+                    nVal = v.nVal;
+                    strVal = std::move( v.strVal );
+                }
+                return *this;
+            }
+        };
+
+        typedef std::pair<key_type const, value_type> pair_type;
+
+        struct less
+        {
+            bool operator ()( key_type const& v1, key_type const& v2 ) const
+            {
+                return v1.nKey < v2.nKey;
+            }
+
+            bool operator ()( key_type const& v1, int v2 ) const
+            {
+                return v1.nKey < v2;
+            }
+
+            bool operator ()( int v1, key_type const& v2 ) const
+            {
+                return v1 < v2.nKey;
+            }
+
+            bool operator ()( key_type const& v1, std::string const& v2 ) const
+            {
+                return v1.nKey < std::stoi(v2 );
+            }
+
+            bool operator ()( std::string const& v1, key_type const& v2 ) const
+            {
+                return std::stoi( v1 ) < v2.nKey;
+            }
+        };
+
+        struct cmp {
+            int operator ()( key_type const& v1, key_type const& v2 ) const
+            {
+                if ( v1.nKey < v2.nKey )
+                    return -1;
+                return v1.nKey > v2.nKey ? 1 : 0;
+            }
+
+            int operator ()( key_type const& v1, int v2 ) const
+            {
+                if ( v1.nKey < v2 )
+                    return -1;
+                return v1.nKey > v2 ? 1 : 0;
+            }
+
+            int operator ()( int v1, key_type const& v2 ) const
+            {
+                if ( v1 < v2.nKey )
+                    return -1;
+                return v1 > v2.nKey ? 1 : 0;
+            }
+
+            int operator ()( key_type const& v1, std::string const& v2 ) const
+            {
+                int n2 = std::stoi( v2 );
+                if ( v1.nKey < n2 )
+                    return -1;
+                return v1.nKey > n2 ? 1 : 0;
+            }
+
+            int operator ()( std::string const& v1, key_type const& v2 ) const
+            {
+                int n1 = std::stoi( v1 );
+                if ( n1 < v2.nKey )
+                    return -1;
+                return n1 > v2.nKey ? 1 : 0;
+            }
+        };
+
+        struct hash1 {
+            size_t operator()( int i ) const
+            {
+                return cds::opt::v::hash<int>()( i );
+            }
+
+            size_t operator()( std::string const& str ) const
+            {
+                return cds::opt::v::hash<int>()( std::stoi( str ));
+            }
+
+            template <typename T>
+            size_t operator()( T const& i ) const
+            {
+                return cds::opt::v::hash<int>()(i.nKey);
+            }
+        };
+
+        struct other_item {
+            int nKey;
+
+            other_item( int key )
+                : nKey( key )
+            {}
+        };
+
+        struct other_less
+        {
+            bool operator ()( key_type const& v1, other_item const& v2 ) const
+            {
+                return v1.nKey < v2.nKey;
+            }
+            bool operator ()( other_item const& v1, key_type const& v2 ) const
+            {
+                return v1.nKey < v2.nKey;
+            }
+        };
+
+    protected:
+        template <class Map>
+        void test( Map& m )
+        {
+            // Precondition: map is empty
+            // Postcondition: map is empty
+
+            ASSERT_TRUE( m.empty());
+            ASSERT_CONTAINER_SIZE( m, 0 );
+
+            typedef Map::value_type map_pair;
+
+            std::vector<key_type> arrKeys;
+            for ( int i = 0; i < static_cast<int>(kSize); ++i )
+                arrKeys.push_back( key_type( i ));
+            shuffle( arrKeys.begin(), arrKeys.end());
+
+            std::vector< value_type > arrVals;
+            for ( size_t i = 0; i < kSize; ++i ) {
+                value_type val;
+                val.nVal = static_cast<int>( i );
+                val.strVal = std::to_string( i );
+                arrVals.push_back( val );
+            }
+
+            // insert/find
+            for ( auto const& i : arrKeys ) {
+                value_type const& val( arrVals.at( i.nKey ));
+
+                ASSERT_FALSE( m.contains( i.nKey ));
+                ASSERT_FALSE( m.contains( i ));
+                ASSERT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                ASSERT_FALSE( m.find( i, []( map_pair const& ) {
+                    ASSERT_TRUE( false );
+                } ));
+                ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                ASSERT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+
+                std::pair< bool, bool > updResult;
+
+                switch ( i.nKey % 16 ) {
+                case 0:
+                    ASSERT_TRUE( m.insert( i ));
+                    ASSERT_FALSE( m.insert( i ));
+                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 1:
+                    ASSERT_TRUE( m.insert( i.nKey ));
+                    ASSERT_FALSE( m.insert( i.nKey ));
+                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 2:
+                    ASSERT_TRUE( m.insert( std::to_string( i.nKey )));
+                    ASSERT_FALSE( m.insert( std::to_string( i.nKey )));
+                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 3:
+                    ASSERT_TRUE( m.insert( i, val ));
+                    ASSERT_FALSE( m.insert( i, val ));
+                    break;
+                case 4:
+                    ASSERT_TRUE( m.insert( i.nKey, val.strVal ));
+                    ASSERT_FALSE( m.insert( i.nKey, val.strVal ));
+                    break;
+                case 5:
+                    ASSERT_TRUE( m.insert( val.strVal, i.nKey ));
+                    ASSERT_FALSE( m.insert( val.strVal, i.nKey ));
+                    break;
+                case 6:
+                    ASSERT_TRUE( m.insert_with( i, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    ASSERT_FALSE( m.insert_with( i, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 7:
+                    ASSERT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    ASSERT_FALSE( m.insert_with( i.nKey, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 8:
+                    ASSERT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    ASSERT_FALSE( m.insert_with( val.strVal, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 9:
+                    updResult = m.update( i.nKey, []( bool, map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    ASSERT_FALSE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+
+                    updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
+                        EXPECT_TRUE( bNew );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_TRUE( updResult.second );
+
+                    updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
+                        EXPECT_FALSE( bNew );
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        v.second.strVal = std::to_string( v.second.nVal );
+                    } );
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+                    break;
+                case 10:
+                    updResult = m.update( i, []( bool, map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    ASSERT_FALSE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+
+                    updResult = m.update( i, []( bool bNew, map_pair& v ) {
+                        EXPECT_TRUE( bNew );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_TRUE( updResult.second );
+
+                    updResult = m.update( i, []( bool bNew, map_pair& v ) {
+                        EXPECT_FALSE( bNew );
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        v.second.strVal = std::to_string( v.second.nVal );
+                    } );
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+                    break;
+                case 11:
+                    updResult = m.update( val.strVal, []( bool, map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    ASSERT_FALSE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+
+                    updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
+                        EXPECT_TRUE( bNew );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_TRUE( updResult.second );
+
+                    updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
+                        EXPECT_FALSE( bNew );
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        v.second.strVal = std::to_string( v.second.nVal );
+                    } );
+                    ASSERT_TRUE( updResult.first );
+                    ASSERT_FALSE( updResult.second );
+                    break;
+                case 12:
+                    ASSERT_TRUE( m.emplace( i.nKey ));
+                    ASSERT_FALSE( m.emplace( i.nKey ));
+                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 13:
+                    ASSERT_TRUE( m.emplace( i, i.nKey ));
+                    ASSERT_FALSE( m.emplace( i, i.nKey ));
+                    break;
+                case 14:
+                    {
+                        std::string str = val.strVal;
+                        ASSERT_TRUE( m.emplace( i, std::move( str )));
+                        ASSERT_TRUE( str.empty());
+                        str = val.strVal;
+                        ASSERT_FALSE( m.emplace( i, std::move( str )));
+                        ASSERT_TRUE( str.empty());
+                    }
+                    break;
+                case 15:
+                    {
+                        std::string str = val.strVal;
+                        ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str )));
+                        ASSERT_TRUE( str.empty());
+                        str = val.strVal;
+                        ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )));
+                        ASSERT_TRUE( str.empty());
+                    }
+                    break;
+                }
+
+                ASSERT_TRUE( m.contains( i.nKey ));
+                ASSERT_TRUE( m.contains( i ));
+                ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+            }
+            ASSERT_FALSE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, kSize );
+            ASSERT_FALSE( m.begin() == m.end() );
+            ASSERT_FALSE( m.cbegin() == m.cend() );
+
+            shuffle( arrKeys.begin(), arrKeys.end() );
+
+            // erase/find
+            for ( auto const& i : arrKeys ) {
+                value_type const& val( arrVals.at( i.nKey ) );
+
+                ASSERT_TRUE( m.contains( i.nKey ));
+                ASSERT_TRUE( m.contains( val.strVal ) );
+                ASSERT_TRUE( m.contains( i ));
+                ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+
+
+                switch ( i.nKey % 8 ) {
+                case 0:
+                    ASSERT_TRUE( m.erase( i ));
+                    ASSERT_FALSE( m.erase( i ));
+                    break;
+                case 1:
+                    ASSERT_TRUE( m.erase( i.nKey ));
+                    ASSERT_FALSE( m.erase( i.nKey ));
+                    break;
+                case 2:
+                    ASSERT_TRUE( m.erase( val.strVal ));
+                    ASSERT_FALSE( m.erase( val.strVal ));
+                    break;
+                case 3:
+                    ASSERT_TRUE( m.erase_with( other_item( i.nKey ), other_less()));
+                    ASSERT_FALSE( m.erase_with( other_item( i.nKey ), other_less()));
+                    break;
+                case 4:
+                    ASSERT_TRUE( m.erase( i, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    ASSERT_FALSE( m.erase( i, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 5:
+                    ASSERT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    ASSERT_FALSE( m.erase( i.nKey, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 6:
+                    ASSERT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    ASSERT_FALSE( m.erase( val.strVal, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 7:
+                    ASSERT_TRUE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    ASSERT_FALSE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                }
+
+                ASSERT_FALSE( m.contains( i.nKey ));
+                ASSERT_FALSE( m.contains( i ));
+                ASSERT_FALSE( m.contains( val.strVal ));
+                ASSERT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                ASSERT_FALSE( m.find( i, []( map_pair const& ) {
+                    ASSERT_TRUE( false );
+                } ));
+                ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                ASSERT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+            }
+            ASSERT_TRUE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, 0 );
+
+            ASSERT_TRUE( m.begin() == m.end());
+            ASSERT_TRUE( m.cbegin() == m.cend());
+
+            // clear
+            for ( auto const& i : arrKeys )
+                ASSERT_TRUE( m.insert( i ));
+
+            ASSERT_FALSE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, kSize );
+
+            m.clear();
+
+            ASSERT_TRUE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, 0 );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // #ifndef CDSUNIT_MAP_TEST_MAP_H
diff --git a/test/unit/map/test_map_hp.h b/test/unit/map/test_map_hp.h
new file mode 100644 (file)
index 0000000..7b4bd05
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+*/
+
+#ifndef CDSUNIT_MAP_TEST_MAP_HP_H
+#define CDSUNIT_MAP_TEST_MAP_HP_H
+
+#include "test_map.h"
+
+namespace cds_test {
+
+    class container_map_hp: public container_map
+    {
+        typedef container_map base_class;
+
+    protected:
+        template <class Map>
+        void test( Map& m )
+        {
+            // Precondition: map is empty
+            // Postcondition: map is empty
+
+            base_class::test( m );
+
+            ASSERT_TRUE( m.empty());
+            ASSERT_CONTAINER_SIZE( m, 0 );
+
+            typedef Map::value_type map_pair;
+
+            std::vector<key_type> arrKeys;
+            for ( int i = 0; i < static_cast<int>(kSize); ++i )
+                arrKeys.push_back( key_type( i ));
+            shuffle( arrKeys.begin(), arrKeys.end());
+
+            std::vector< value_type > arrVals;
+            for ( size_t i = 0; i < kSize; ++i ) {
+                value_type val;
+                val.nVal = static_cast<int>( i );
+                val.strVal = std::to_string( i );
+                arrVals.push_back( val );
+            }
+
+            for ( auto const& i : arrKeys )
+                ASSERT_TRUE( m.insert( i ) );
+            ASSERT_FALSE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, kSize );
+
+            // iterators
+            size_t nCount = 0;
+            for ( auto it = m.begin(); it != m.end(); ++it ) {
+                EXPECT_EQ( it->second.nVal, 0 );
+                it->second.nVal = it->first.nKey;
+                ++nCount;
+            }
+            EXPECT_EQ( nCount, kSize );
+
+            nCount = 0;
+            for ( auto it = m.cbegin(); it != m.cend(); ++it ) {
+                EXPECT_EQ( it->second.nVal, it->first.nKey );
+                ++nCount;
+            }
+            EXPECT_EQ( nCount, kSize );
+
+            // get/extract
+            typedef typename Map::guarded_ptr guarded_ptr;
+            guarded_ptr gp;
+
+            for ( auto const& i : arrKeys ) {
+                value_type const& val = arrVals.at( i.nKey );
+
+                gp = m.get( i.nKey );
+                ASSERT_FALSE( !gp );
+                ASSERT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+                gp = m.get( i );
+                ASSERT_FALSE( !gp );
+                ASSERT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+                gp = m.get_with( other_item( i.nKey ), other_less());
+                ASSERT_FALSE( !gp );
+                ASSERT_EQ( gp->first.nKey, i.nKey );
+
+                switch ( i.nKey % 4 ) {
+                case 0:
+                    gp = m.extract( i.nKey );
+                    break;
+                case 1:
+                    gp = m.extract( i );
+                    break;
+                case 2:
+                    gp = m.extract( val.strVal );
+                    break;
+                case 3:
+                    gp = m.extract_with( other_item( i.nKey ), other_less());
+                    break;
+                }
+                ASSERT_FALSE( !gp );
+                ASSERT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+
+                gp = m.get( i.nKey );
+                ASSERT_TRUE( !gp );
+                gp = m.get( i );
+                ASSERT_TRUE( !gp );
+                gp = m.get_with( other_item( i.nKey ), other_less() );
+                ASSERT_TRUE( !gp );
+            }
+            ASSERT_TRUE( m.empty() );
+            ASSERT_CONTAINER_SIZE( m, 0 );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // #ifndef CDSUNIT_MAP_TEST_MAP_H
index 3483b8f9a86d0d7d21b6e0de42d400173a960568..29107d44209e6bf2d0b8a5ce6401ba0d44ad4cfc 100644 (file)
@@ -127,7 +127,7 @@ namespace {
             typedef hash_int hash;
             typedef simple_item_counter item_counter;
         };
-        typedef cc::MichaelHashSet< gc_type, list_type, set_traits >set_type;
+        typedef cc::MichaelHashSet< gc_type, list_type, set_traits > set_type;
 
         set_type s( kSize, 3 );
         test( s );
@@ -147,7 +147,7 @@ namespace {
             typedef hash_int hash;
             typedef cds::atomicity::item_counter item_counter;
         };
-        typedef cc::MichaelHashSet< gc_type, list_type, set_traits >set_type;
+        typedef cc::MichaelHashSet< gc_type, list_type, set_traits > set_type;
 
         set_type s( kSize, 4 );
         test( s );
@@ -168,7 +168,7 @@ namespace {
             typedef hash_int hash;
             typedef cds::atomicity::item_counter item_counter;
         };
-        typedef cc::MichaelHashSet< gc_type, list_type, set_traits >set_type;
+        typedef cc::MichaelHashSet< gc_type, list_type, set_traits > set_type;
 
         set_type s( kSize, 4 );
         test( s );