Added StdMap to Map_InsDel_int MT-test
authorkhizmax <libcds.dev@gmail.com>
Sat, 5 Sep 2015 13:42:28 +0000 (16:42 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 5 Sep 2015 13:42:28 +0000 (16:42 +0300)
projects/Win/vc12/unit-map-insdel.vcxproj
projects/Win/vc12/unit-map-insdel.vcxproj.filters
projects/source.unit.map.mk
tests/unit/map2/CMakeLists.txt
tests/unit/map2/map_defs.h
tests/unit/map2/map_insdel_int.h
tests/unit/map2/map_insdel_int_std.cpp [new file with mode: 0644]
tests/unit/map2/map_type_std.h
tests/unit/map2/std_hash_map.h
tests/unit/map2/std_map.h

index 483a9d26bfb4ec6ace35c5785e31b4f5b90d7e4c..48ce135ad7cbd0b51d74524105c90b932c28ce0c 100644 (file)
@@ -60,6 +60,7 @@
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_multilevelhashmap.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_skip.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_split.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_std.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_striped.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_string.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_string_bronsonavltree.cpp" />\r
index 303b3d71a42e098d4b4f8130dc665489d2e082ef..f3be91cd8211c9cd1f7a9c58f54ca74c0f601c4a 100644 (file)
@@ -85,6 +85,9 @@
     <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_multilevelhashmap.cpp">\r
       <Filter>map_insdel_int</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\map2\map_insdel_int_std.cpp">\r
+      <Filter>map_insdel_int</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Filter Include="map_insdel_func">\r
index 4ab10a2ddcadfda7766830f36f31f4cb2692d578..accb93470e3c15eefbb29a6af3321b8978812619 100644 (file)
@@ -48,6 +48,7 @@ CDSUNIT_MAP_SOURCES := \
     tests/unit/map2/map_insdel_int_skip.cpp \
     tests/unit/map2/map_insdel_int_split.cpp \
     tests/unit/map2/map_insdel_int_striped.cpp \
+    tests/unit/map2/map_insdel_int_std.cpp \
     tests/unit/map2/map_insdel_item_int.cpp \
     tests/unit/map2/map_insdel_item_int_michael.cpp \
     tests/unit/map2/map_insdel_item_int_split.cpp \
index 4d96a296de03b25009f322cb2b0ebf80f3a731c1..fbcddeecd86cad2bf698d3ae0732b242a64ec461 100644 (file)
@@ -49,6 +49,7 @@ set(CDSUNIT_MAP_SOURCES
     map_insdel_int_skip.cpp
     map_insdel_int_split.cpp
     map_insdel_int_striped.cpp
+    map_insdel_int_std.cpp
     map_insdel_item_int.cpp
     map_insdel_item_int_michael.cpp
     map_insdel_item_int_split.cpp
index 6a07e050125a2bee3753e4caab0b335719d3ea96..47c17bbe2e9fa1c1861a612e7f2ce92d77529be7 100644 (file)
@@ -1,14 +1,16 @@
 //$$CDS-header$$
 
 #define CDSUNIT_DECLARE_StdMap \
-    CDSUNIT_DECLARE_TEST(StdMap_Spin) \
-    CDSUNIT_DECLARE_TEST(StdHashMap_Spin)
-#define CDSUNIT_DEFINE_StdMap(IMPL, C) \
-    TEST_MAP(IMPL, C, StdMap_Spin) \
-    TEST_MAP(IMPL, C, StdHashMap_Spin)
+    TEST_CASE(tag_StdMap, StdMap_Spin) \
+    TEST_CASE(tag_StdMap, StdHashMap_Spin) \
+    TEST_CASE(tag_StdMap, StdMap_Mutex) \
+    TEST_CASE(tag_StdMap, StdHashMap_Mutex)
+
 #define CDSUNIT_TEST_StdMap \
     CPPUNIT_TEST(StdMap_Spin) \
     CPPUNIT_TEST(StdHashMap_Spin) \
+    CPPUNIT_TEST(StdMap_Mutex) \
+    CPPUNIT_TEST(StdHashMap_Mutex) \
 
 
 // **************************************************************************************
index a36c64156cd46b811dc1bfac640f1744a053f3f4..c6130a051f147c44f0eb13de1b0c0f8856a5391d 100644 (file)
@@ -256,7 +256,7 @@ namespace map2 {
         CDSUNIT_DECLARE_StripedMap
         CDSUNIT_DECLARE_RefinableMap
         CDSUNIT_DECLARE_CuckooMap
-        //CDSUNIT_DECLARE_StdMap
+        CDSUNIT_DECLARE_StdMap
 
         CPPUNIT_TEST_SUITE(Map_InsDel_int)
             CDSUNIT_TEST_MichaelMap
@@ -268,9 +268,7 @@ namespace map2 {
             CDSUNIT_TEST_CuckooMap
             CDSUNIT_TEST_StripedMap
             CDSUNIT_TEST_RefinableMap
-            //CDSUNIT_TEST_StdMap
-
-            //CDSUNIT_TEST_MultiLevelHashMap // the test is not suitable
+            CDSUNIT_TEST_StdMap
         CPPUNIT_TEST_SUITE_END();
 
     };
diff --git a/tests/unit/map2/map_insdel_int_std.cpp b/tests/unit/map2/map_insdel_int_std.cpp
new file mode 100644 (file)
index 0000000..95c8045
--- /dev/null
@@ -0,0 +1,12 @@
+//$$CDS-header$$
+
+#include "map2/map_insdel_int.h"
+#include "map2/map_type_std.h"
+
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_InsDel_int::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
+
+namespace map2 {
+    CDSUNIT_DECLARE_StdMap
+} // namespace map2
index 3022896ded970a91aae5853019ae3644dd910194..8cfce03453107dcb0d4ba8b3f65d812922198ab2 100644 (file)
 
 namespace map2 {
 
-    struct std_implementation_tag;
+    struct tag_StdMap;
 
     template <typename Key, typename Value>
-    struct map_type< std_implementation_tag, Key, Value >: public map_type_base< Key, Value >
+    struct map_type< tag_StdMap, Key, Value >: public map_type_base< Key, Value >
     {
         typedef map_type_base< Key, Value > base_class;
         typedef typename base_class::compare    compare;
         typedef typename base_class::less       less;
 
-        typedef StdMap< Key, Value, cds::sync::spin >     StdMap_Spin;
-        typedef StdMap< Key, Value, lock::NoLock>         StdMap_NoLock;
+        typedef StdMap< Key, Value, cds::sync::spin >   StdMap_Spin;
+        typedef StdMap< Key, Value, std::mutex >        StdMap_Mutex;
+        typedef StdMap< Key, Value, lock::NoLock>       StdMap_NoLock;
 
         typedef StdHashMap< Key, Value, cds::sync::spin > StdHashMap_Spin;
+        typedef StdHashMap< Key, Value, std::mutex >      StdHashMap_Mutex;
         typedef StdHashMap< Key, Value, lock::NoLock >    StdHashMap_NoLock;
     };
 }   // namespace map2
index 067e69f83af57747a7a5b8e2af2fa4438015cb34..904b5e5e391bebcabf513d7080b6446d0cff2271 100644 (file)
@@ -32,7 +32,11 @@ namespace map2 {
         typedef typename base_class::mapped_type value_type;
         typedef size_t      item_counter;
 
-        StdHashMap( size_t /*nMapSize*/, size_t /*nLoadFactor*/ )
+        StdHashMap()
+        {}
+
+        template <class Config>
+        StdHashMap( Config const& )
         {}
 
         bool find( const Key& key )
@@ -60,7 +64,7 @@ namespace map2 {
         }
 
         template <typename T, typename Func>
-        std::pair<bool, bool> ensure( const T& key, Func func )
+        std::pair<bool, bool> update( const T& key, Func func, bool /*bAllowInsert*/ = true )
         {
             scoped_lock al( m_lock );
             std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value() ));
@@ -93,6 +97,11 @@ namespace map2 {
         }
 
         std::ostream& dump( std::ostream& stm ) { return stm; }
+
+
+        // for testing
+        static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+        static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
     };
 }   // namespace map2
 
index 6923472c5489d264ea32fa88e5798ab27ee4a5f5..3551071fb5cb6fcd723e3c45458f392167454f67 100644 (file)
@@ -21,7 +21,11 @@ namespace map2 {
         typedef typename base_class::value_type  pair_type;
         typedef size_t      item_counter;
 
-        StdMap( size_t /*nMapSize*/, size_t /*nLoadFactor*/ )
+        StdMap()
+        {}
+
+        template <class Config>
+        StdMap( Config const& )
         {}
 
         bool find( const Key& key )
@@ -49,7 +53,7 @@ namespace map2 {
         }
 
         template <typename T, typename Func>
-        std::pair<bool, bool> ensure( const T& key, Func func )
+        std::pair<bool, bool> update( const T& key, Func func, bool /*bAllowInsert*/ = true )
         {
             scoped_lock al( m_lock );
             std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
@@ -83,6 +87,11 @@ namespace map2 {
         }
 
         std::ostream& dump( std::ostream& stm ) { return stm; }
+
+
+        // for testing
+        static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+        static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
     };
 }   // namespace map