From: khizmax Date: Fri, 15 Jan 2016 21:25:48 +0000 (+0300) Subject: Moved priority_queue unit test to gtest framework X-Git-Tag: v2.2.0~426 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=439a1e79e84e69a2b2fdfec81cda6a5f5262caa4 Moved priority_queue unit test to gtest framework --- diff --git a/cds/container/mspriority_queue.h b/cds/container/mspriority_queue.h index 4b916f04..23b2324b 100644 --- a/cds/container/mspriority_queue.h +++ b/cds/container/mspriority_queue.h @@ -164,7 +164,7 @@ namespace cds { namespace container { public: /// Constructs empty priority queue /** - For cds::opt::v::static_buffer the \p nCapacity parameter is ignored. + For \p cds::opt::v::static_buffer the \p nCapacity parameter is ignored. */ MSPriorityQueue( size_t nCapacity ) : base_class( nCapacity ) diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index c85989ad..8dfbad07 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -245,7 +245,7 @@ namespace cds { namespace intrusive { public: /// Constructs empty priority queue /** - For cds::opt::v::static_buffer the \p nCapacity parameter is ignored. + For \p cds::opt::v::static_buffer the \p nCapacity parameter is ignored. */ MSPriorityQueue( size_t nCapacity ) : m_Heap( nCapacity ) diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index 1299dddc..9404ae70 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -135,12 +135,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-set-insdel", "unit-set {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-priority_queue", "hdr-test-priority_queue.vcxproj", "{90192F7D-5850-41DD-AE89-62D26B387162}" - ProjectSection(ProjectDependencies) = postProject - {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} - {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-queue", "hdr-test-queue.vcxproj", "{33664E63-8D24-4FF4-A744-9782EB711509}" ProjectSection(ProjectDependencies) = postProject {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} @@ -192,6 +186,19 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unit", "unit", "{810490B7-31E5-49AE-8455-CAF99A9658B6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-stack", "gtest-stack.vcxproj", "{5407E9D2-67D9-4266-976E-7A90BDE2541D}" + ProjectSection(ProjectDependencies) = postProject + {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-pqueue", "gtest-pqueue.vcxproj", "{EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}" + ProjectSection(ProjectDependencies) = postProject + {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cds_test", "cds_test", "{3A510E45-180B-4ADC-AFCD-D75774B68580}" + ProjectSection(SolutionItems) = preProject + ..\..\..\test\include\cds_test\fixture.h = ..\..\..\test\include\cds_test\fixture.h + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -371,18 +378,6 @@ Global {BA23811C-D4CB-4836-B2F3-6791BD6FFCD1}.Release|Win32.Build.0 = Release|Win32 {BA23811C-D4CB-4836-B2F3-6791BD6FFCD1}.Release|x64.ActiveCfg = Release|x64 {BA23811C-D4CB-4836-B2F3-6791BD6FFCD1}.Release|x64.Build.0 = Release|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.Debug|Win32.ActiveCfg = Debug|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.Debug|Win32.Build.0 = Debug|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.Debug|x64.ActiveCfg = Debug|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.Debug|x64.Build.0 = Debug|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.DebugVLD|x64.Build.0 = DebugVLD|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.Release|Win32.ActiveCfg = Release|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.Release|Win32.Build.0 = Release|Win32 - {90192F7D-5850-41DD-AE89-62D26B387162}.Release|x64.ActiveCfg = Release|x64 - {90192F7D-5850-41DD-AE89-62D26B387162}.Release|x64.Build.0 = Release|x64 {33664E63-8D24-4FF4-A744-9782EB711509}.Debug|Win32.ActiveCfg = Debug|Win32 {33664E63-8D24-4FF4-A744-9782EB711509}.Debug|Win32.Build.0 = Debug|Win32 {33664E63-8D24-4FF4-A744-9782EB711509}.Debug|x64.ActiveCfg = Debug|x64 @@ -491,6 +486,18 @@ Global {5407E9D2-67D9-4266-976E-7A90BDE2541D}.Release|Win32.Build.0 = Release|Win32 {5407E9D2-67D9-4266-976E-7A90BDE2541D}.Release|x64.ActiveCfg = Release|x64 {5407E9D2-67D9-4266-976E-7A90BDE2541D}.Release|x64.Build.0 = Release|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Debug|Win32.ActiveCfg = Debug|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Debug|Win32.Build.0 = Debug|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Debug|x64.ActiveCfg = Debug|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Debug|x64.Build.0 = Debug|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.DebugVLD|x64.Build.0 = DebugVLD|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Release|Win32.ActiveCfg = Release|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Release|Win32.Build.0 = Release|Win32 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Release|x64.ActiveCfg = Release|x64 + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -511,7 +518,6 @@ Global {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4} = {6BB7A27F-FC59-4267-B6FA-D034176D1459} {AF7B2253-2E6D-4992-94D9-4B3699C54929} = {A64449B7-90FB-4E2B-A686-9EFC0E298644} {BA23811C-D4CB-4836-B2F3-6791BD6FFCD1} = {A64449B7-90FB-4E2B-A686-9EFC0E298644} - {90192F7D-5850-41DD-AE89-62D26B387162} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {33664E63-8D24-4FF4-A744-9782EB711509} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {A38E5597-6916-4480-A343-C9846EF544E4} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} @@ -521,6 +527,7 @@ Global {CA6F0834-0628-4CD7-8800-AEABCD636360} = {6BB7A27F-FC59-4267-B6FA-D034176D1459} {DE256E91-EE96-412E-82EE-DD7BD1A1130D} = {A64449B7-90FB-4E2B-A686-9EFC0E298644} {5407E9D2-67D9-4266-976E-7A90BDE2541D} = {810490B7-31E5-49AE-8455-CAF99A9658B6} + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A} = {810490B7-31E5-49AE-8455-CAF99A9658B6} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/projects/Win/vc14/gtest-pqueue.vcxproj b/projects/Win/vc14/gtest-pqueue.vcxproj new file mode 100644 index 00000000..7aa5b944 --- /dev/null +++ b/projects/Win/vc14/gtest-pqueue.vcxproj @@ -0,0 +1,251 @@ + + + + + DebugVLD + Win32 + + + DebugVLD + x64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + {EAD522BF-E7DA-4A20-94FF-4D3EAF0A540A} + Win32Proj + stack + 8.1 + + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + true + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + $(ProjectName)_d + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ + $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtestd.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB32);$(GTEST_ROOT)/lib/x86;$(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..;$(GTEST_ROOT)/include;$(SolutionDir)..\..\..\test\include;$(BOOST_PATH);%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(GTEST_LIB64);$(GTEST_ROOT)/lib/x64;$(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;%(AdditionalLibraryDirectories);$(OutDir) + gtest.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/projects/Win/vc14/gtest-pqueue.vcxproj.filters b/projects/Win/vc14/gtest-pqueue.vcxproj.filters new file mode 100644 index 00000000..228156a9 --- /dev/null +++ b/projects/Win/vc14/gtest-pqueue.vcxproj.filters @@ -0,0 +1,45 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/projects/Win/vc14/gtest-stack.vcxproj b/projects/Win/vc14/gtest-stack.vcxproj index acbcad6d..3741d2e1 100644 --- a/projects/Win/vc14/gtest-stack.vcxproj +++ b/projects/Win/vc14/gtest-stack.vcxproj @@ -134,12 +134,12 @@ false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ + $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ diff --git a/projects/Win/vc14/hdr-test-priority_queue.vcxproj b/projects/Win/vc14/hdr-test-priority_queue.vcxproj deleted file mode 100644 index 8603df36..00000000 --- a/projects/Win/vc14/hdr-test-priority_queue.vcxproj +++ /dev/null @@ -1,349 +0,0 @@ - - - - - DebugVLD - Win32 - - - DebugVLD - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - {90192F7D-5850-41dd-AE89-62D26B387162} - hdrtestpriority_queue - Win32Proj - 8.1 - - - - Application - MultiByte - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - $(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 - MultiplyDefinedSymbolOnly - - - - - 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 - MultiplyDefinedSymbolOnly - - - - - /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 - MultiplyDefinedSymbolOnly - - - - - 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 - MultiplyDefinedSymbolOnly - - - - - /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 - MultiplyDefinedSymbolOnly - - - - - 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 - MultiplyDefinedSymbolOnly - - - - - - \ No newline at end of file diff --git a/projects/Win/vc14/hdr-test-priority_queue.vcxproj.filters b/projects/Win/vc14/hdr-test-priority_queue.vcxproj.filters deleted file mode 100644 index 3a2eb198..00000000 --- a/projects/Win/vc14/hdr-test-priority_queue.vcxproj.filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - {2e5ccb52-5287-4912-8d3f-aeaf257134cd} - - - {d864adcf-d418-48b8-85be-6f4d39ac6941} - - - - - - intrusive - - - intrusive - - - container - - - container - - - container - - - container - - - container - - - - - intrusive - - - container - - - \ No newline at end of file diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index 3bfc132e..65171891 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -103,16 +103,6 @@ CDS_TESTHDR_LIST := \ tests/test-hdr/list/hdr_michael_kv_rcu_shb.cpp \ tests/test-hdr/list/hdr_michael_kv_rcu_sht.cpp -CDS_TESTHDR_PQUEUE := \ - tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_dyn.cpp \ - tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_static.cpp \ - tests/test-hdr/priority_queue/hdr_mspqueue_dyn.cpp \ - tests/test-hdr/priority_queue/hdr_mspqueue_static.cpp \ - tests/test-hdr/priority_queue/hdr_fcpqueue_boost_stable_vector.cpp \ - tests/test-hdr/priority_queue/hdr_fcpqueue_deque.cpp \ - tests/test-hdr/priority_queue/hdr_fcpqueue_vector.cpp \ - tests/test-hdr/priority_queue/hdr_priority_queue_reg.cpp - CDS_TESTHDR_QUEUE := \ tests/test-hdr/queue/hdr_queue_register.cpp \ tests/test-hdr/queue/hdr_intrusive_fcqueue.cpp \ @@ -287,7 +277,6 @@ CDS_TESTHDR_MISC := \ CDS_TESTHDR_SOURCES := \ $(CDS_TESTHDR_QUEUE) \ - $(CDS_TESTHDR_PQUEUE) \ $(CDS_TESTHDR_MAP) \ $(CDS_TESTHDR_DEQUE) \ $(CDS_TESTHDR_LIST) \ diff --git a/test/include/cds_test/fixture.h b/test/include/cds_test/fixture.h new file mode 100644 index 00000000..aa9fcffe --- /dev/null +++ b/test/include/cds_test/fixture.h @@ -0,0 +1,55 @@ +/* + 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 CDSTEST_FIXTURE_H +#define CDSTEST_FIXTURE_H + +#include +#include +#include + +namespace cds_test { + + class fixture : public ::testing::Test + { + protected: + template + static void shuffle( RandomIt first, RandomIt last ) + { + static std::random_device random_dev; + static std::mt19937 random_gen( random_dev() ); + + std::shuffle( first, last, random_gen ); + } + }; + +} // namespace cds_test + +#endif // CDSTEST_FIXTURE_H diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 3f733605..c25c24e0 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack) diff --git a/test/unit/pqueue/CMakeLists.txt b/test/unit/pqueue/CMakeLists.txt new file mode 100644 index 00000000..8da85f9a --- /dev/null +++ b/test/unit/pqueue/CMakeLists.txt @@ -0,0 +1,25 @@ +set(PACKAGE_NAME unit-pqueue) + +set(CDSGTEST_PQUEUE_SOURCES + fcpqueue_boost_stable_vector.cpp + fcpqueue_deque.cpp + fcpqueue_vector.cpp + intrusive_mspqueue.cpp + main.cpp + mspqueue.cpp +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(${PACKAGE_NAME} ${CDSGTEST_PQUEUE_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/pqueue/fcpqueue_boost_stable_vector.cpp b/test/unit/pqueue/fcpqueue_boost_stable_vector.cpp new file mode 100644 index 00000000..91044795 --- /dev/null +++ b/test/unit/pqueue/fcpqueue_boost_stable_vector.cpp @@ -0,0 +1,104 @@ +/* + 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_fcpqueue.h" +#include +#include +#include + +namespace cds_test { + + TEST_F( FCPQueue, stable_vector ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,boost::container::stable_vector + ,less + > + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, stable_vector_stat ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,boost::container::stable_vector + ,less + > + ,cds::container::fcpqueue::make_traits< + cds::opt::stat< cds::container::fcpqueue::stat<> > + >::type + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, boost_deque ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,boost::container::deque + ,less + > + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, boost_deque_stat ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,boost::container::deque + ,less + > + ,cds::container::fcpqueue::make_traits< + cds::opt::stat< cds::container::fcpqueue::stat<> > + >::type + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + +} // namespace cds_test diff --git a/test/unit/pqueue/fcpqueue_deque.cpp b/test/unit/pqueue/fcpqueue_deque.cpp new file mode 100644 index 00000000..0f7e0b93 --- /dev/null +++ b/test/unit/pqueue/fcpqueue_deque.cpp @@ -0,0 +1,87 @@ +/* + 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_fcpqueue.h" +#include +#include + +namespace cds_test { + + TEST_F( FCPQueue, deque ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,std::deque + ,less + > + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, deque_stat ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,std::deque + ,less + > + ,cds::container::fcpqueue::make_traits< + cds::opt::stat< cds::container::fcpqueue::stat<> > + >::type + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, deque_mutex ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< + value_type + ,std::deque + > + ,cds::container::fcpqueue::make_traits< + cds::opt::lock_type< std::mutex > + >::type + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + +} // namespace cds_test diff --git a/test/unit/pqueue/fcpqueue_vector.cpp b/test/unit/pqueue/fcpqueue_vector.cpp new file mode 100644 index 00000000..6de4855a --- /dev/null +++ b/test/unit/pqueue/fcpqueue_vector.cpp @@ -0,0 +1,78 @@ +/* + 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_fcpqueue.h" +#include + +namespace cds_test { + + TEST_F( FCPQueue, vector ) + { + typedef cds::container::FCPriorityQueue< FCPQueue::value_type > pqueue_type; + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, vector_stat ) + { + struct pqueue_traits : public cds::container::fcpqueue::traits + { + typedef cds::container::fcpqueue::stat<> stat; + }; + + typedef cds::container::FCPriorityQueue< + value_type + , std::priority_queue< + value_type + , std::vector + , less + > + , pqueue_traits + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + + TEST_F( FCPQueue, vector_mutex ) + { + typedef cds::container::FCPriorityQueue< + value_type + ,std::priority_queue< value_type > + ,cds::container::fcpqueue::make_traits< + cds::opt::lock_type< std::mutex > + >::type + > pqueue_type; + + pqueue_type pq; + test( pq ); + } + +} // namespace cds_test diff --git a/test/unit/pqueue/intrusive_mspqueue.cpp b/test/unit/pqueue/intrusive_mspqueue.cpp new file mode 100644 index 00000000..1c019943 --- /dev/null +++ b/test/unit/pqueue/intrusive_mspqueue.cpp @@ -0,0 +1,270 @@ +/* + 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_data.h" +#include + +namespace { + + struct disposer { + size_t m_nCallCount; + + disposer() + : m_nCallCount( 0 ) + {} + + template + void operator()( T& ) + { + ++m_nCallCount; + } + }; + + class IntrusiveMSPQueue : public cds_test::PQueueTest + { + typedef cds_test::PQueueTest base_class; + protected: + template + void test( PQueue& pq ) + { + data_array arr( pq.capacity() ); + value_type * pFirst = arr.begin(); + value_type * pLast = arr.end(); + + ASSERT_TRUE( pq.empty() ); + ASSERT_FALSE( pq.full() ); + ASSERT_EQ( pq.size(), 0 ); + ASSERT_EQ( pq.capacity(), base_class::c_nCapacity - 1 ); + + size_t nSize = 0; + + // Push test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + ASSERT_FALSE( pq.empty() ); + ASSERT_EQ( pq.size(), ++nSize ); + } + + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + + // The queue is full + { + value_type k( base_class::c_nMinValue + key_type( base_class::c_nCapacity )); + ASSERT_FALSE( pq.push( k ) ); + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + } + + // Pop test + key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity() ) - 1; + value_type * p = pq.pop(); + ASSERT_TRUE( p != nullptr ); + EXPECT_EQ( p->k, nPrev ); + + ASSERT_EQ( pq.size(), pq.capacity() - 1 ); + ASSERT_FALSE( pq.full() ); + ASSERT_FALSE( pq.empty() ); + + nSize = pq.size(); + while ( pq.size() > 1 ) { + p = pq.pop(); + ASSERT_TRUE( p != nullptr ); + EXPECT_EQ( p->k, nPrev - 1 ); + nPrev = p->k; + --nSize; + ASSERT_EQ( pq.size(), nSize ); + } + + ASSERT_FALSE( pq.full() ); + ASSERT_FALSE( pq.empty() ); + ASSERT_EQ( pq.size(), 1 ); + + p = pq.pop(); + ASSERT_TRUE( p != nullptr ); + EXPECT_EQ( p->k, base_class::c_nMinValue ); + + ASSERT_FALSE( pq.full() ); + ASSERT_TRUE( pq.empty() ); + ASSERT_EQ( pq.size(), 0 ); + + // Clear test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + } + EXPECT_FALSE( pq.empty() ); + EXPECT_TRUE( pq.full() ); + EXPECT_EQ( pq.size(), pq.capacity() ); + pq.clear(); + EXPECT_TRUE( pq.empty() ); + EXPECT_FALSE( pq.full() ); + EXPECT_EQ( pq.size(), 0 ); + + // clear_with test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + } + ASSERT_FALSE( pq.empty() ); + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + + { + disposer disp; + pq.clear_with( std::ref( disp ) ); + ASSERT_TRUE( pq.empty() ); + ASSERT_FALSE( pq.full() ); + ASSERT_EQ( pq.size(), 0 ); + ASSERT_EQ( disp.m_nCallCount, pq.capacity() ); + } + } + }; + + typedef cds::opt::v::dynamic_buffer< char > dyn_buffer_type; + typedef cds::opt::v::static_buffer< char, IntrusiveMSPQueue::c_nCapacity > static_buffer_type; + + TEST_F( IntrusiveMSPQueue, dynamic ) + { + struct traits : public cds::intrusive::mspriority_queue::traits + { + typedef dyn_buffer_type buffer; + }; + typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( IntrusiveMSPQueue, dynamic_cmp ) + { + struct traits : public cds::intrusive::mspriority_queue::traits + { + typedef dyn_buffer_type buffer; + typedef IntrusiveMSPQueue::compare compare; + }; + typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( IntrusiveMSPQueue, dynamic_less ) + { + typedef cds::intrusive::MSPriorityQueue< value_type, + cds::intrusive::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + ,cds::opt::less< std::less > + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( IntrusiveMSPQueue, dynamic_cmp_less ) + { + typedef cds::intrusive::MSPriorityQueue< value_type, + cds::intrusive::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + ,cds::opt::less< std::less > + ,cds::opt::compare< IntrusiveMSPQueue::compare > + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( IntrusiveMSPQueue, dynamic_mutex ) + { + struct traits : public cds::intrusive::mspriority_queue::traits + { + typedef dyn_buffer_type buffer; + typedef IntrusiveMSPQueue::compare compare; + typedef std::mutex lock_type; + }; + typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( IntrusiveMSPQueue, stat ) + { + struct traits : public cds::intrusive::mspriority_queue::traits + { + typedef static_buffer_type buffer; + }; + typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue; + + std::unique_ptr pq( new pqueue(0)); + test( *pq ); + } + + TEST_F( IntrusiveMSPQueue, stat_cmp ) + { + typedef cds::intrusive::MSPriorityQueue< value_type, + cds::intrusive::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + ,cds::opt::compare< compare > + >::type + > pqueue; + + std::unique_ptr pq( new pqueue( 0 ) ); + test( *pq ); + } + + TEST_F( IntrusiveMSPQueue, stat_less ) + { + typedef cds::intrusive::MSPriorityQueue< value_type, + cds::intrusive::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + ,cds::opt::less< less > + >::type + > pqueue; + + std::unique_ptr pq( new pqueue( 0 ) ); + test( *pq ); + } + + TEST_F( IntrusiveMSPQueue, stat_mutex ) + { + struct traits : public cds::intrusive::mspriority_queue::traits + { + typedef static_buffer_type buffer; + typedef IntrusiveMSPQueue::compare compare; + typedef std::mutex lock_type; + }; + typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue; + + std::unique_ptr pq( new pqueue( 0 ) ); + test( *pq ); + } + +} // namespace diff --git a/test/unit/pqueue/main.cpp b/test/unit/pqueue/main.cpp new file mode 100644 index 00000000..e690d555 --- /dev/null +++ b/test/unit/pqueue/main.cpp @@ -0,0 +1,44 @@ +/* + 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 +#include + +int main( int argc, char **argv ) +{ + int result; + cds::Initialize(); + { + ::testing::InitGoogleTest( &argc, argv ); + result = RUN_ALL_TESTS(); + } + cds::Terminate(); + return result; +} diff --git a/test/unit/pqueue/mspqueue.cpp b/test/unit/pqueue/mspqueue.cpp new file mode 100644 index 00000000..1966883d --- /dev/null +++ b/test/unit/pqueue/mspqueue.cpp @@ -0,0 +1,285 @@ +/* + 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_data.h" +#include + +namespace { + + struct disposer { + size_t m_nCallCount; + + disposer() + : m_nCallCount( 0 ) + {} + + template + void operator()( T& ) + { + ++m_nCallCount; + } + }; + + class MSPQueue : public cds_test::PQueueTest + { + typedef cds_test::PQueueTest base_class; + protected: + template + void test( PQueue& pq ) + { + data_array arr( pq.capacity() ); + value_type * pFirst = arr.begin(); + value_type * pLast = pFirst + pq.capacity(); + + ASSERT_TRUE( pq.empty() ); + ASSERT_EQ( pq.size(), 0 ); + ASSERT_EQ( pq.capacity(), base_class::c_nCapacity - 1 ); + + size_t nSize = 0; + + // Push test + for ( value_type * p = pFirst; p < pLast; ++p ) { + switch ( pq.size() & 3 ) { + case 0: + ASSERT_TRUE( pq.push_with( [p]( value_type& dest ) { dest = *p; } ) ); + break; + case 1: + ASSERT_TRUE( pq.emplace( p->k, p->v ) ); + break; + case 2: + ASSERT_TRUE( pq.emplace( std::make_pair( p->k, p->v ) ) ); + break; + default: + ASSERT_TRUE( pq.push( *p ) ); + } + ASSERT_TRUE( !pq.empty() ); + ASSERT_TRUE( pq.size() == ++nSize ); + } + + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + + // The queue is full + key_type k = base_class::c_nMinValue + key_type( base_class::c_nCapacity ); + ASSERT_TRUE( !pq.push( k ) ); + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + + // Pop test + key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity() ) - 1; + value_type kv( 0 ); + key_type key; + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, nPrev ); + + ASSERT_EQ( pq.size(), pq.capacity() - 1 ); + ASSERT_TRUE( !pq.full() ); + ASSERT_TRUE( !pq.empty() ); + + nSize = pq.size(); + while ( pq.size() > 1 ) { + if ( pq.size() & 1 ) { + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, nPrev - 1 ); + nPrev = kv.k; + } + else { + ASSERT_TRUE( pq.pop_with( [&key]( value_type& src ) { key = src.k; } ) ); + EXPECT_EQ( key, nPrev - 1 ); + nPrev = key; + } + + --nSize; + ASSERT_EQ( pq.size(), nSize ); + } + + ASSERT_TRUE( !pq.full() ); + ASSERT_TRUE( !pq.empty() ); + ASSERT_EQ( pq.size(), 1 ); + + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, base_class::c_nMinValue ); + + ASSERT_TRUE( !pq.full() ); + ASSERT_TRUE( pq.empty() ); + ASSERT_EQ( pq.size(), 0 ); + + // Clear test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + } + ASSERT_TRUE( !pq.empty() ); + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + pq.clear(); + ASSERT_TRUE( pq.empty() ); + ASSERT_TRUE( !pq.full() ); + ASSERT_EQ( pq.size(), 0 ); + + // clear_with test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + } + ASSERT_TRUE( !pq.empty() ); + ASSERT_TRUE( pq.full() ); + ASSERT_EQ( pq.size(), pq.capacity() ); + + { + disposer disp; + pq.clear_with( std::ref( disp ) ); + ASSERT_TRUE( pq.empty() ); + ASSERT_TRUE( !pq.full() ); + ASSERT_EQ( pq.size(), 0 ); + ASSERT_EQ( disp.m_nCallCount, pq.capacity() ); + } + } + }; + + typedef cds::opt::v::dynamic_buffer< char > dyn_buffer_type; + typedef cds::opt::v::static_buffer< char, MSPQueue::c_nCapacity > static_buffer_type; + + TEST_F( MSPQueue, dynamic ) + { + typedef cds::container::MSPriorityQueue< MSPQueue::value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( MSPQueue, dynamic_cmp ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + , cds::opt::compare< compare > + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( MSPQueue, dynamic_less ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + ,cds::opt::less< less > + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + TEST_F( MSPQueue, dynamic_cmp_less ) + { + struct pqueue_traits : public cds::container::mspriority_queue::traits + { + typedef dyn_buffer_type buffer; + typedef MSPQueue::less less; + typedef MSPQueue::compare compare; + }; + typedef cds::container::MSPriorityQueue< value_type, pqueue_traits > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( MSPQueue, dynamic_mutex ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< dyn_buffer_type > + ,cds::opt::compare< compare > + ,cds::opt::lock_type + >::type + > pqueue; + + pqueue pq( c_nCapacity ); + test( pq ); + } + + TEST_F( MSPQueue, stat ) + { + typedef cds::container::MSPriorityQueue< MSPQueue::value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + >::type + > pqueue; + + std::unique_ptr< pqueue > pq( new pqueue(0)); + test( *pq ); + } + + TEST_F( MSPQueue, stat_cmp ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + ,cds::opt::compare< compare > + >::type + > pqueue; + + std::unique_ptr< pqueue > pq( new pqueue(0)); + test( *pq ); + } + + TEST_F( MSPQueue, stat_less ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + ,cds::opt::less< less > + >::type + > pqueue; + + std::unique_ptr< pqueue > pq( new pqueue(0)); + test( *pq ); + } + + TEST_F( MSPQueue, stat_mutex ) + { + typedef cds::container::MSPriorityQueue< value_type, + cds::container::mspriority_queue::make_traits< + cds::opt::buffer< static_buffer_type > + ,cds::opt::less< less > + ,cds::opt::lock_type + >::type + > pqueue; + + std::unique_ptr< pqueue > pq( new pqueue(0)); + test( *pq ); + } + +} // namespace diff --git a/test/unit/pqueue/test_data.h b/test/unit/pqueue/test_data.h new file mode 100644 index 00000000..7145d4c9 --- /dev/null +++ b/test/unit/pqueue/test_data.h @@ -0,0 +1,131 @@ +/* + 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_PQUEUE_TEST_DATA_H +#define CDSUNIT_PQUEUE_TEST_DATA_H + +#include +#include + +namespace cds_test { + + class PQueueTest : public ::cds_test::fixture + { + public: + typedef int key_type; + + struct value_type { + key_type k; + int v; + + value_type() + {} + + value_type( value_type const& kv ) + : k( kv.k ) + , v( kv.v ) + {} + + value_type( key_type key ) + : k( key ) + , v( key ) + {} + + value_type( key_type key, int val ) + : k( key ) + , v( val ) + {} + + value_type( std::pair const& p ) + : k( p.first ) + , v( p.second ) + {} + }; + + struct compare { + int operator()( value_type k1, value_type k2 ) const + { + return k1.k - k2.k; + } + }; + + struct less { + bool operator()( value_type k1, value_type k2 ) const + { + return k1.k < k2.k; + } + }; + + enum { + c_nMinValue = -123, + c_nCapacity = 1024 + }; + + protected: + template + class data_array + { + std::unique_ptr pFirst; + T * pLast; + + public: + data_array( size_t nSize ) + : pFirst( new T[nSize] ) + , pLast( pFirst.get() + nSize ) + { + key_type i = c_nMinValue; + for ( T * p = pFirst.get(); p != pLast; ++p, ++i ) + p->k = p->v = i; + + shuffle( pFirst.get(), pLast ); + } + + T * begin() { return pFirst.get(); } + T * end() { return pLast; } + size_t size() const + { + return pLast - pFirst; + } + }; + }; +} // namespace cds_test + +namespace std { + template<> + struct less + { + bool operator()( cds_test::PQueueTest::value_type const& v1, cds_test::PQueueTest::value_type const& v2 ) const + { + return cds_test::PQueueTest::less()(v1, v2); + } + }; +} + +#endif // CDSUNIT_PQUEUE_FCPQUEUE_H diff --git a/test/unit/pqueue/test_fcpqueue.h b/test/unit/pqueue/test_fcpqueue.h new file mode 100644 index 00000000..9943a7aa --- /dev/null +++ b/test/unit/pqueue/test_fcpqueue.h @@ -0,0 +1,110 @@ +/* + 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_PQUEUE_FCPQUEUE_H +#define CDSUNIT_PQUEUE_FCPQUEUE_H + +#include "test_data.h" + +namespace cds_test { + + class FCPQueue : public PQueueTest + { + protected: + template + void test( PQueue& pq ) + { + data_array arr( PQueueTest::c_nCapacity ); + value_type * pFirst = arr.begin(); + value_type * pLast = arr.end(); + + ASSERT_TRUE( pq.empty() ); + ASSERT_TRUE( pq.size() == 0 ); + + size_t nSize = 0; + + // Push test + for ( value_type * p = pFirst; p < pLast; ++p ) { + ASSERT_TRUE( pq.push( *p ) ); + ASSERT_TRUE( !pq.empty() ); + ASSERT_EQ( pq.size(), ++nSize ); + } + + ASSERT_EQ( pq.size(), PQueueTest::c_nCapacity ); + + // Pop test + key_type nPrev = PQueueTest::c_nMinValue + key_type( PQueueTest::c_nCapacity ) - 1; + value_type kv( 0 ); + + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, nPrev ); + + ASSERT_EQ( pq.size(), PQueueTest::c_nCapacity - 1 ); + ASSERT_TRUE( !pq.empty() ); + + nSize = pq.size(); + while ( pq.size() > 1 ) { + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, nPrev - 1 ); + nPrev = kv.k; + + --nSize; + ASSERT_EQ( pq.size(), nSize ); + } + + ASSERT_TRUE( !pq.empty() ); + ASSERT_EQ( pq.size(), 1 ); + + ASSERT_TRUE( pq.pop( kv ) ); + EXPECT_EQ( kv.k, PQueueTest::c_nMinValue ); + + ASSERT_TRUE( pq.empty() ); + ASSERT_EQ( pq.size(), 0 ); + + // pop from empty pqueue + kv.k = PQueueTest::c_nCapacity * 2; + ASSERT_FALSE( pq.pop( kv )); + EXPECT_EQ( kv.k, PQueueTest::c_nCapacity * 2 ); + + // Clear test + for ( value_type * p = pFirst; p < pLast; ++p ) + ASSERT_TRUE( pq.push( *p ) ); + + ASSERT_TRUE( !pq.empty() ); + ASSERT_EQ( pq.size(), PQueueTest::c_nCapacity ); + + pq.clear(); + ASSERT_TRUE( pq.empty() ); + ASSERT_EQ( pq.size(), 0 ); + } + }; +} // namespace cds_test + +#endif // CDSUNIT_PQUEUE_FCPQUEUE_H diff --git a/tests/test-hdr/CMakeLists.txt b/tests/test-hdr/CMakeLists.txt index 40988a05..df1fba99 100644 --- a/tests/test-hdr/CMakeLists.txt +++ b/tests/test-hdr/CMakeLists.txt @@ -105,16 +105,6 @@ set(CDS_TESTHDR_LIST list/hdr_michael_kv_rcu_shb.cpp list/hdr_michael_kv_rcu_sht.cpp) -set(CDS_TESTHDR_PQUEUE - priority_queue/hdr_intrusive_mspqueue_dyn.cpp - priority_queue/hdr_intrusive_mspqueue_static.cpp - priority_queue/hdr_mspqueue_dyn.cpp - priority_queue/hdr_mspqueue_static.cpp - priority_queue/hdr_fcpqueue_boost_stable_vector.cpp - priority_queue/hdr_fcpqueue_deque.cpp - priority_queue/hdr_fcpqueue_vector.cpp - priority_queue/hdr_priority_queue_reg.cpp) - set(CDS_TESTHDR_QUEUE queue/hdr_queue_register.cpp queue/hdr_intrusive_fcqueue.cpp @@ -364,12 +354,6 @@ set(CDS_TESTHDR_OFFSETOF_QUEUE queue/hdr_intrusive_optimisticqueue_hp.cpp queue/hdr_intrusive_optimisticqueue_dhp.cpp) -set(CDS_TESTHDR_OFFSETOF_STACK - stack/hdr_intrusive_treiber_stack_hp.cpp - stack/hdr_intrusive_treiber_stack_dhp.cpp - stack/hdr_intrusive_elimination_stack_hp.cpp - stack/hdr_intrusive_elimination_stack_dhp.cpp) - set(CDS_TESTHDR_OFFSETOF_TREE tree/hdr_intrusive_ellen_bintree_hp_member.cpp tree/hdr_intrusive_ellen_bintree_dhp_member.cpp @@ -381,7 +365,6 @@ set(CDS_TESTHDR_OFFSETOF_TREE set(CDS_TESTHDR_OFFSETOF_SOURCES ${CDS_TESTHDR_OFFSETOF_QUEUE} - ${CDS_TESTHDR_OFFSETOF_STACK} ${CDS_TESTHDR_OFFSETOF_MAP} ${CDS_TESTHDR_OFFSETOF_SET} ${CDS_TESTHDR_OFFSETOF_LIST} @@ -395,7 +378,6 @@ endif(CMAKE_COMPILER_IS_GNUCC) set(CDS_TESTHDR_SOURCES ${CDS_TESTHDR_QUEUE} - ${CDS_TESTHDR_PQUEUE} ${CDS_TESTHDR_MAP} ${CDS_TESTHDR_DEQUE} ${CDS_TESTHDR_LIST} diff --git a/tests/test-hdr/priority_queue/hdr_fcpqueue_boost_stable_vector.cpp b/tests/test-hdr/priority_queue/hdr_fcpqueue_boost_stable_vector.cpp deleted file mode 100644 index 204f4569..00000000 --- a/tests/test-hdr/priority_queue/hdr_fcpqueue_boost_stable_vector.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - 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 "priority_queue/hdr_pqueue.h" -#include -#include -#include - -namespace priority_queue { - - void PQueueHdrTest::FCPQueue_stablevector() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,boost::container::stable_vector - ,PQueueHdrTest::less - > - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_stablevector_stat() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,boost::container::stable_vector - ,PQueueHdrTest::less - > - ,cds::container::fcpqueue::make_traits< - cds::opt::stat< cds::container::fcpqueue::stat<> > - >::type - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_boost_deque() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,boost::container::deque - ,PQueueHdrTest::less - > - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_boost_deque_stat() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,boost::container::deque - ,PQueueHdrTest::less - > - ,cds::container::fcpqueue::make_traits< - cds::opt::stat< cds::container::fcpqueue::stat<> > - >::type - > pqueue_type; - test_fcpqueue(); - } - -} // namespace priorty_queue diff --git a/tests/test-hdr/priority_queue/hdr_fcpqueue_deque.cpp b/tests/test-hdr/priority_queue/hdr_fcpqueue_deque.cpp deleted file mode 100644 index b4e27b39..00000000 --- a/tests/test-hdr/priority_queue/hdr_fcpqueue_deque.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - 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 "priority_queue/hdr_pqueue.h" -#include -#include - -namespace priority_queue { - - void PQueueHdrTest::FCPQueue_deque() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,std::deque - ,PQueueHdrTest::less - > - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_deque_stat() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,std::deque - ,PQueueHdrTest::less - > - ,cds::container::fcpqueue::make_traits< - cds::opt::stat< cds::container::fcpqueue::stat<> > - >::type - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_deque_mutex() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,std::deque - > - ,cds::container::fcpqueue::make_traits< - cds::opt::lock_type< std::mutex > - >::type - > pqueue_type; - test_fcpqueue(); - } - -} // namespace priorty_queue diff --git a/tests/test-hdr/priority_queue/hdr_fcpqueue_vector.cpp b/tests/test-hdr/priority_queue/hdr_fcpqueue_vector.cpp deleted file mode 100644 index 1914861c..00000000 --- a/tests/test-hdr/priority_queue/hdr_fcpqueue_vector.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - 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 "priority_queue/hdr_pqueue.h" -#include - -namespace priority_queue { - - void PQueueHdrTest::FCPQueue_vector() - { - typedef cds::container::FCPriorityQueue< PQueueHdrTest::value_type > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_vector_stat() - { - struct pqueue_traits : public cds::container::fcpqueue::traits - { - typedef cds::container::fcpqueue::stat<> stat; - }; - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< - PQueueHdrTest::value_type - ,std::vector - ,PQueueHdrTest::less - > - ,pqueue_traits - > pqueue_type; - test_fcpqueue(); - } - - void PQueueHdrTest::FCPQueue_vector_mutex() - { - typedef cds::container::FCPriorityQueue< - PQueueHdrTest::value_type - ,std::priority_queue< PQueueHdrTest::value_type > - ,cds::container::fcpqueue::make_traits< - cds::opt::lock_type< std::mutex > - >::type - > pqueue_type; - test_fcpqueue(); - } - -} // namespace priorty_queue diff --git a/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_dyn.cpp b/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_dyn.cpp deleted file mode 100644 index 635311cb..00000000 --- a/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_dyn.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - 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 "priority_queue/hdr_intrusive_pqueue.h" -#include - -namespace priority_queue { - namespace intrusive_pqueue { - template - struct constants > { - static size_t const nCapacity = c_nCapacity - 1; - }; - } - - namespace { - typedef cds::opt::v::dynamic_buffer< char > buffer_type; - } - - void IntrusivePQueueHdrTest::MSPQueue_dyn() - { - struct pqueue_traits : public cds::intrusive::mspriority_queue::traits - { - typedef buffer_type buffer; - }; - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, pqueue_traits > pqueue; - - test_msq_dyn(); - } - - void IntrusivePQueueHdrTest::MSPQueue_dyn_cmp() - { - struct pqueue_traits : public cds::intrusive::mspriority_queue::traits - { - typedef buffer_type buffer; - typedef IntrusivePQueueHdrTest::compare compare; - }; - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, pqueue_traits > pqueue; - - test_msq_dyn(); - } - - void IntrusivePQueueHdrTest::MSPQueue_dyn_less() - { - struct pqueue_traits : public - cds::intrusive::mspriority_queue::make_traits < - cds::opt::buffer< buffer_type > - , cds::opt::less < std::less > - > ::type - {}; - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, pqueue_traits > pqueue; - - test_msq_dyn(); - } - - void IntrusivePQueueHdrTest::MSPQueue_dyn_cmpless() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< std::less > - ,cds::opt::compare< IntrusivePQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_dyn(); - } - - void IntrusivePQueueHdrTest::MSPQueue_dyn_cmp_mtx() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< IntrusivePQueueHdrTest::compare > - ,cds::opt::lock_type - >::type - > pqueue; - - test_msq_dyn(); - } - -} // namespace priority_queue diff --git a/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_static.cpp b/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_static.cpp deleted file mode 100644 index 51ff761b..00000000 --- a/tests/test-hdr/priority_queue/hdr_intrusive_mspqueue_static.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - 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 "priority_queue/hdr_intrusive_pqueue.h" -#include - -namespace priority_queue { - namespace intrusive_pqueue { - template - struct constants > { - static size_t const nCapacity = c_nCapacity - 1; - }; - } - - namespace { - typedef cds::opt::v::static_buffer< char, IntrusivePQueueHdrTest::c_nCapacity > buffer_type; - } - - void IntrusivePQueueHdrTest::MSPQueue_st() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - >::type - > pqueue; - - test_msq_stat(); - } - - void IntrusivePQueueHdrTest::MSPQueue_st_cmp() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< IntrusivePQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_stat(); - } - - void IntrusivePQueueHdrTest::MSPQueue_st_less() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< std::less > - >::type - > pqueue; - - test_msq_stat(); - } - - void IntrusivePQueueHdrTest::MSPQueue_st_cmpless() - { - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, - cds::intrusive::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< std::less > - ,cds::opt::compare< IntrusivePQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_stat(); - } - - void IntrusivePQueueHdrTest::MSPQueue_st_cmp_mtx() - { - struct pqueue_traits : public cds::intrusive::mspriority_queue::traits - { - typedef buffer_type buffer; - typedef IntrusivePQueueHdrTest::compare compare; - typedef std::mutex lock_type; - }; - typedef cds::intrusive::MSPriorityQueue< IntrusivePQueueHdrTest::key_type, pqueue_traits > pqueue; - - test_msq_stat(); - } - -} // namespace priority_queue diff --git a/tests/test-hdr/priority_queue/hdr_intrusive_pqueue.h b/tests/test-hdr/priority_queue/hdr_intrusive_pqueue.h deleted file mode 100644 index e038c8f9..00000000 --- a/tests/test-hdr/priority_queue/hdr_intrusive_pqueue.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - 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 CDSTEST_HDR_INTRUSIVE_PQUEUE_H -#define CDSTEST_HDR_INTRUSIVE_PQUEUE_H - -#include "cppunit/cppunit_proxy.h" -#include "size_check.h" -#include -#include // ref - -namespace priority_queue { - - namespace intrusive_pqueue { - static size_t const c_nCapacity = 1024 * 16; - - struct another_disposer { - size_t m_nCallCount; - - another_disposer() - : m_nCallCount(0) - {} - template - void operator()( T& ) - { - ++m_nCallCount; - } - }; - - template - struct constants { - static size_t const nCapacity = c_nCapacity; - }; - } // namespace intrusive_pqueue - - class IntrusivePQueueHdrTest: public CppUnitMini::TestCase - { - public: - static size_t const c_nCapacity = intrusive_pqueue::c_nCapacity; - - typedef int key_type; - static key_type const c_nMinValue = -123; - - struct compare { - int operator()( key_type k1, key_type k2 ) const - { - return k1 - k2; - } - }; - - template - class data_array - { - T * pFirst; - T * pLast; - - public: - data_array( size_t nSize ) - : pFirst( new T[nSize] ) - , pLast( pFirst + nSize ) - { - T i = c_nMinValue; - for ( T * p = pFirst; p != pLast; ++p, ++i ) - *p = i; - - CppUnitMini::TestCase::shuffle( pFirst, pLast ); - } - - ~data_array() - { - delete [] pFirst; - } - - T * begin() { return pFirst; } - T * end() { return pLast ; } - size_t size() const - { - return pLast - pFirst; - } - }; - - protected: - template - void test_bounded_with( PQueue& pq ) - { - data_array arr( pq.capacity() ); - key_type * pFirst = arr.begin(); - key_type * pLast = pFirst + pq.capacity(); - - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - CPPUNIT_ASSERT( pq.capacity() == intrusive_pqueue::constants::nCapacity ); - - size_t nSize = 0; - - // Push test - for ( key_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == ++nSize ); - } - - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - // The queue is full - key_type k = c_nMinValue + key_type(c_nCapacity); - CPPUNIT_ASSERT( !pq.push( k )); - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - // Pop test - key_type nPrev = c_nMinValue + key_type(pq.capacity()) - 1; - key_type * p = pq.pop(); - CPPUNIT_ASSERT( p != nullptr ); - CPPUNIT_CHECK_EX( *p == nPrev, "Expected=" << nPrev << ", current=" << *p ); - - CPPUNIT_ASSERT( pq.size() == pq.capacity() - 1 ); - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( !pq.empty() ); - - nSize = pq.size(); - while ( pq.size() > 1 ) { - p = pq.pop(); - CPPUNIT_ASSERT( p != nullptr ); - CPPUNIT_CHECK_EX( *p == nPrev - 1, "Expected=" << nPrev - 1 << ", current=" << *p ); - nPrev = *p; - --nSize; - CPPUNIT_ASSERT( pq.size() == nSize ); - } - - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 1 ); - - p = pq.pop(); - CPPUNIT_ASSERT( p != nullptr ); - CPPUNIT_CHECK_EX( *p == c_nMinValue, "Expected=" << c_nMinValue << ", current=" << *p ); - - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - - // Clear test - for ( key_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_CHECK( !pq.empty() ); - CPPUNIT_CHECK( pq.full() ); - CPPUNIT_CHECK( pq.size() == pq.capacity() ); - pq.clear(); - CPPUNIT_CHECK( pq.empty() ); - CPPUNIT_CHECK( !pq.full() ); - CPPUNIT_CHECK( pq.size() == 0 ); - - // clear_with test - for ( key_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - { - intrusive_pqueue::another_disposer disp; - pq.clear_with( std::ref(disp) ); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - CPPUNIT_ASSERT( disp.m_nCallCount == pq.capacity() ); - } - } - - template - void test_msq_stat() - { - std::unique_ptr< PQueue > pq( new PQueue(0)); // argument should be ignored for static buffer - test_bounded_with( *pq ); - } - template - void test_msq_dyn() - { - PQueue pq( c_nCapacity ); - test_bounded_with( pq ); - } - - public: - void MSPQueue_st(); - void MSPQueue_st_cmp(); - void MSPQueue_st_less(); - void MSPQueue_st_cmpless(); - void MSPQueue_st_cmp_mtx(); - void MSPQueue_dyn(); - void MSPQueue_dyn_cmp(); - void MSPQueue_dyn_less(); - void MSPQueue_dyn_cmpless(); - void MSPQueue_dyn_cmp_mtx(); - - CPPUNIT_TEST_SUITE(IntrusivePQueueHdrTest) - CPPUNIT_TEST(MSPQueue_st) - CPPUNIT_TEST(MSPQueue_st_cmp) - CPPUNIT_TEST(MSPQueue_st_less) - CPPUNIT_TEST(MSPQueue_st_cmpless) - CPPUNIT_TEST(MSPQueue_st_cmp_mtx) - CPPUNIT_TEST(MSPQueue_dyn) - CPPUNIT_TEST(MSPQueue_dyn_cmp) - CPPUNIT_TEST(MSPQueue_dyn_less) - CPPUNIT_TEST(MSPQueue_dyn_cmpless) - CPPUNIT_TEST(MSPQueue_dyn_cmp_mtx) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace priority_queue - -#endif // #ifndef CDSTEST_HDR_INTRUSIVE_PQUEUE_H diff --git a/tests/test-hdr/priority_queue/hdr_mspqueue_dyn.cpp b/tests/test-hdr/priority_queue/hdr_mspqueue_dyn.cpp deleted file mode 100644 index 248f4c88..00000000 --- a/tests/test-hdr/priority_queue/hdr_mspqueue_dyn.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - 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 "priority_queue/hdr_pqueue.h" -#include - -namespace priority_queue { - namespace pqueue { - template - struct constants > { - static size_t const nCapacity = c_nCapacity - 1; - }; - } - - namespace { - typedef cds::opt::v::dynamic_buffer< char > buffer_type; - } - - void PQueueHdrTest::MSPQueue_dyn() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - >::type - > pqueue; - - test_msq_dyn(); - } - - void PQueueHdrTest::MSPQueue_dyn_cmp() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< PQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_dyn(); - } - - void PQueueHdrTest::MSPQueue_dyn_less() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< PQueueHdrTest::less > - >::type - > pqueue; - - test_msq_dyn(); - } - - void PQueueHdrTest::MSPQueue_dyn_cmpless() - { - struct pqueue_traits : public cds::container::mspriority_queue::traits - { - typedef buffer_type buffer; - typedef PQueueHdrTest::less less; - typedef PQueueHdrTest::compare compare; - }; - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, pqueue_traits > pqueue; - - test_msq_dyn(); - } - - void PQueueHdrTest::MSPQueue_dyn_cmp_mtx() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< PQueueHdrTest::compare > - ,cds::opt::lock_type - >::type - > pqueue; - - test_msq_dyn(); - } - -} // namespace priority_queue diff --git a/tests/test-hdr/priority_queue/hdr_mspqueue_static.cpp b/tests/test-hdr/priority_queue/hdr_mspqueue_static.cpp deleted file mode 100644 index cd70a81e..00000000 --- a/tests/test-hdr/priority_queue/hdr_mspqueue_static.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - 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 "priority_queue/hdr_pqueue.h" -#include - -namespace priority_queue { - namespace pqueue { - template - struct constants > { - static size_t const nCapacity = c_nCapacity - 1; - }; - } - - namespace { - typedef cds::opt::v::static_buffer< char, PQueueHdrTest::c_nCapacity > buffer_type; - } - - void PQueueHdrTest::MSPQueue_st() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - >::type - > pqueue; - - test_msq_stat(); - } - - void PQueueHdrTest::MSPQueue_st_cmp() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< PQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_stat(); - } - - void PQueueHdrTest::MSPQueue_st_less() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< PQueueHdrTest::less > - >::type - > pqueue; - - test_msq_stat(); - } - - void PQueueHdrTest::MSPQueue_st_cmpless() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::less< PQueueHdrTest::less > - ,cds::opt::compare< PQueueHdrTest::compare > - >::type - > pqueue; - - test_msq_stat(); - } - - void PQueueHdrTest::MSPQueue_st_cmp_mtx() - { - typedef cds::container::MSPriorityQueue< PQueueHdrTest::value_type, - cds::container::mspriority_queue::make_traits< - cds::opt::buffer< buffer_type > - ,cds::opt::compare< PQueueHdrTest::compare > - ,cds::opt::lock_type - >::type - > pqueue; - - test_msq_stat(); - } - -} // namespace priority_queue diff --git a/tests/test-hdr/priority_queue/hdr_pqueue.h b/tests/test-hdr/priority_queue/hdr_pqueue.h deleted file mode 100644 index a9ef86c0..00000000 --- a/tests/test-hdr/priority_queue/hdr_pqueue.h +++ /dev/null @@ -1,396 +0,0 @@ -/* - 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 CDSTEST_HDR_PQUEUE_H -#define CDSTEST_HDR_PQUEUE_H - -#include "cppunit/cppunit_proxy.h" -#include "size_check.h" -#include -#include // ref - -namespace priority_queue { - - namespace pqueue { - static size_t const c_nCapacity = 1024 * 16; - - struct disposer { - size_t m_nCallCount; - - disposer() - : m_nCallCount(0) - {} - - template - void operator()( T& ) - { - ++m_nCallCount; - } - }; - - template - struct constants { - static size_t const nCapacity = c_nCapacity; - }; - } // namespace pqueue - - class PQueueHdrTest: public CppUnitMini::TestCase - { - public: - static size_t const c_nCapacity = pqueue::c_nCapacity; - - typedef int key_type; - static key_type const c_nMinValue = -123; - - struct value_type { - key_type k; - int v; - - value_type() - {} - - value_type( value_type const& kv ) - : k(kv.k) - , v(kv.v) - {} - - value_type( key_type key ) - : k(key) - , v(key) - {} - - value_type( key_type key, int val ) - : k(key) - , v(val) - {} - - value_type( std::pair const& p ) - : k(p.first) - , v(p.second) - {} - }; - - struct compare { - int operator()( value_type k1, value_type k2 ) const - { - return k1.k - k2.k; - } - }; - - struct less { - bool operator()( value_type k1, value_type k2 ) const - { - return k1.k < k2.k; - } - }; - - template - class data_array - { - T * pFirst; - T * pLast; - - public: - data_array( size_t nSize ) - : pFirst( new T[nSize] ) - , pLast( pFirst + nSize ) - { - key_type i = c_nMinValue; - for ( T * p = pFirst; p != pLast; ++p, ++i ) - p->k = p->v = i; - - shuffle( pFirst, pLast ); - } - - ~data_array() - { - delete [] pFirst; - } - - T * begin() { return pFirst; } - T * end() { return pLast ; } - size_t size() const - { - return pLast - pFirst; - } - }; - - protected: - template - void test_bounded_with( PQueue& pq ) - { - data_array arr( pq.capacity() ); - value_type * pFirst = arr.begin(); - value_type * pLast = pFirst + pq.capacity(); - - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - CPPUNIT_ASSERT_EX( pq.capacity() == pqueue::constants::nCapacity, - "pq.capacity() = " << pq.capacity() << ", pqueue::constants::nCapacity = " << pqueue::constants::nCapacity - ); - - size_t nSize = 0; - - // Push test - for ( value_type * p = pFirst; p < pLast; ++p ) { - switch ( pq.size() & 3 ) { - case 0: - CPPUNIT_ASSERT( pq.push_with( [p]( value_type& dest ) { dest = *p; } )); - break; - case 1: - CPPUNIT_ASSERT( pq.emplace( p->k, p->v )); - break; - case 2: - CPPUNIT_ASSERT( pq.emplace( std::make_pair( p->k, p->v ) )); - break; - default: - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == ++nSize ); - } - - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - // The queue is full - key_type k = c_nMinValue + key_type(c_nCapacity); - CPPUNIT_ASSERT( !pq.push( k )); - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - // Pop test - key_type nPrev = c_nMinValue + key_type(pq.capacity()) - 1; - value_type kv(0); - key_type key; - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == nPrev, "Expected=" << nPrev << ", current=" << kv.k ); - - CPPUNIT_ASSERT( pq.size() == pq.capacity() - 1 ); - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( !pq.empty() ); - - nSize = pq.size(); - while ( pq.size() > 1 ) { - if ( pq.size() & 1 ) { - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == nPrev - 1, "Expected=" << nPrev - 1 << ", current=" << kv.k ); - nPrev = kv.k; - } - else { - CPPUNIT_ASSERT( pq.pop_with( [&key]( value_type& src ) { key = src.k; } ) ); - CPPUNIT_CHECK_EX( key == nPrev - 1, "Expected=" << nPrev - 1 << ", current=" << key ); - nPrev = key; - } - - --nSize; - CPPUNIT_ASSERT( pq.size() == nSize ); - } - - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 1 ); - - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == c_nMinValue, "Expected=" << c_nMinValue << ", current=" << kv.k ); - - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - - // Clear test - for ( value_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - pq.clear(); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - - // clear_with test - for ( value_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.full() ); - CPPUNIT_ASSERT( pq.size() == pq.capacity() ); - - { - pqueue::disposer disp; - pq.clear_with( std::ref(disp) ); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( !pq.full() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - CPPUNIT_ASSERT( disp.m_nCallCount == pq.capacity() ); - } - } - - template - void test_msq_stat() - { - std::unique_ptr< PQueue > pq( new PQueue( 0 )); // argument should be ignored for static buffer - test_bounded_with( *pq ); - } - template - void test_msq_dyn() - { - PQueue pq( c_nCapacity ); - test_bounded_with( pq ); - } - - template - void test_fcpqueue() - { - PQueue pq; - - data_array arr( c_nCapacity ); - value_type * pFirst = arr.begin(); - value_type * pLast = pFirst + c_nCapacity; - - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - - size_t nSize = 0; - - // Push test - for ( value_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == ++nSize ); - } - - CPPUNIT_ASSERT( pq.size() == c_nCapacity ); - - // Pop test - key_type nPrev = c_nMinValue + key_type(c_nCapacity) - 1; - value_type kv(0); - //key_type key; - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == nPrev, "Expected=" << nPrev << ", current=" << kv.k ); - - CPPUNIT_ASSERT( pq.size() == c_nCapacity - 1 ); - CPPUNIT_ASSERT( !pq.empty() ); - - nSize = pq.size(); - while ( pq.size() > 1 ) { - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == nPrev - 1, "Expected=" << nPrev - 1 << ", current=" << kv.k ); - nPrev = kv.k; - - --nSize; - CPPUNIT_ASSERT( pq.size() == nSize ); - } - - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 1 ); - - CPPUNIT_ASSERT( pq.pop(kv) ); - CPPUNIT_CHECK_EX( kv.k == c_nMinValue, "Expected=" << c_nMinValue << ", current=" << kv.k ); - - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - - // Clear test - for ( value_type * p = pFirst; p < pLast; ++p ) { - CPPUNIT_ASSERT( pq.push( *p )); - } - CPPUNIT_ASSERT( !pq.empty() ); - CPPUNIT_ASSERT( pq.size() == c_nCapacity ); - - pq.clear(); - CPPUNIT_ASSERT( pq.empty() ); - CPPUNIT_ASSERT( pq.size() == 0 ); - } - - public: - void MSPQueue_st(); - void MSPQueue_st_cmp(); - void MSPQueue_st_less(); - void MSPQueue_st_cmpless(); - void MSPQueue_st_cmp_mtx(); - void MSPQueue_dyn(); - void MSPQueue_dyn_cmp(); - void MSPQueue_dyn_less(); - void MSPQueue_dyn_cmpless(); - void MSPQueue_dyn_cmp_mtx(); - - void FCPQueue_vector(); - void FCPQueue_vector_stat(); - void FCPQueue_vector_mutex(); - void FCPQueue_deque(); - void FCPQueue_deque_stat(); - void FCPQueue_deque_mutex(); - void FCPQueue_boost_deque(); - void FCPQueue_boost_deque_stat(); - void FCPQueue_stablevector(); - void FCPQueue_stablevector_stat(); - - CPPUNIT_TEST_SUITE(PQueueHdrTest) - CPPUNIT_TEST(MSPQueue_st) - CPPUNIT_TEST(MSPQueue_st_cmp) - CPPUNIT_TEST(MSPQueue_st_less) - CPPUNIT_TEST(MSPQueue_st_cmpless) - CPPUNIT_TEST(MSPQueue_st_cmp_mtx) - CPPUNIT_TEST(MSPQueue_dyn) - CPPUNIT_TEST(MSPQueue_dyn_cmp) - CPPUNIT_TEST(MSPQueue_dyn_less) - CPPUNIT_TEST(MSPQueue_dyn_cmpless) - CPPUNIT_TEST(MSPQueue_dyn_cmp_mtx) - - CPPUNIT_TEST(FCPQueue_vector) - CPPUNIT_TEST(FCPQueue_vector_stat) - CPPUNIT_TEST(FCPQueue_vector_mutex) - CPPUNIT_TEST(FCPQueue_deque) - CPPUNIT_TEST(FCPQueue_deque_stat) - CPPUNIT_TEST(FCPQueue_deque_mutex) - CPPUNIT_TEST(FCPQueue_boost_deque) - CPPUNIT_TEST(FCPQueue_boost_deque_stat) - CPPUNIT_TEST(FCPQueue_stablevector) - CPPUNIT_TEST(FCPQueue_stablevector_stat) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace priority_queue - -namespace std { - template<> - struct less - { - bool operator()( priority_queue::PQueueHdrTest::value_type const& v1, priority_queue::PQueueHdrTest::value_type const& v2) const - { - return priority_queue::PQueueHdrTest::less()( v1, v2 ); - } - }; -} - -#endif // #ifndef CDSTEST_HDR_PQUEUE_H diff --git a/tests/test-hdr/priority_queue/hdr_priority_queue_reg.cpp b/tests/test-hdr/priority_queue/hdr_priority_queue_reg.cpp deleted file mode 100644 index 8db5ae4e..00000000 --- a/tests/test-hdr/priority_queue/hdr_priority_queue_reg.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - 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 "priority_queue/hdr_intrusive_pqueue.h" -#include "priority_queue/hdr_pqueue.h" - - -CPPUNIT_TEST_SUITE_REGISTRATION_(priority_queue::IntrusivePQueueHdrTest, s_IntrusivePQueueHdrTest); -CPPUNIT_TEST_SUITE_REGISTRATION_(priority_queue::PQueueHdrTest, s_PQueueHdrTest);