Added tree consistency checking to the map unit test
authorkhizmax <khizmax@gmail.com>
Wed, 4 Mar 2015 15:24:27 +0000 (18:24 +0300)
committerkhizmax <khizmax@gmail.com>
Wed, 4 Mar 2015 15:24:27 +0000 (18:24 +0300)
tests/unit/map2/map_delodd.cpp
tests/unit/map2/map_find_int.cpp
tests/unit/map2/map_find_string.cpp
tests/unit/map2/map_insdel_func.cpp
tests/unit/map2/map_insdel_int.cpp
tests/unit/map2/map_insdel_item_int.cpp
tests/unit/map2/map_insdel_item_string.cpp
tests/unit/map2/map_insdel_string.cpp
tests/unit/map2/map_insdelfind.cpp
tests/unit/map2/map_insfind_int.cpp
tests/unit/map2/map_types.h

index 02332e1e8f355c1ee8238db3576f0839117e1415..a57c5d58874ccdc97e0ae8e7057dd9f6856e2e89 100644 (file)
@@ -126,16 +126,6 @@ namespace boost {
 
 namespace map2 {
 
-    template <typename Map>
-    static inline void check_before_clear( Map& /*s*/ )
-    {}
-
-    template <typename GC, typename Key, typename T, typename Traits>
-    static inline void check_before_clear( cds::container::EllenBinTreeMap<GC, Key, T, Traits>& s )
-    {
-        CPPUNIT_CHECK_CURRENT( s.check_consistency() );
-    }
-
     class Map_DelOdd: public CppUnitMini::TestCase
     {
         std::vector<size_t>     m_arrData;
@@ -628,7 +618,7 @@ namespace map2 {
                 CPPUNIT_CHECK_EX( nErrorCount == 0, "Totals: " << nErrorCount << " keys is not found");
             }
 
-            check_before_clear( testMap );
+            check_before_cleanup( testMap );
 
             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
             timer.reset();
index 789fc18022d20db7e33bfe2bd469e434deaca2ea..d796e48ba303f3189246f2a0c0127e941e486647 100644 (file)
@@ -198,6 +198,8 @@ namespace map2 {
                 CPPUNIT_ASSERT( pThread->m_KeyNotExists.nSuccess == (m_Arr.size() - m_nRealMapSize) * c_nPassCount );
             }
 
+            check_before_cleanup( testMap );
+
             testMap.clear();
             additional_check( testMap );
             print_stat( testMap );
index d796bef664106f73d8522840d585f9398a352e91..fbdc0e48a7ed036dbed19a1959da4726f375f091 100644 (file)
@@ -199,6 +199,8 @@ namespace map2 {
                 CPPUNIT_ASSERT( pThread->m_KeyNotExists.nFailed == 0 );
             }
 
+            check_before_cleanup( testMap );
+
             testMap.clear();
             additional_check( testMap );
             print_stat( testMap );
index 2ebadc4d9aaefd1e84c7dc3624416c5c58bd24cb..65b970b79a047af76ad05d748dffc8bcd69f0f56 100644 (file)
@@ -484,6 +484,8 @@ namespace map2 {
             // nTestFunctorRef is call count of insert functor
             CPPUNIT_CHECK_EX( nTestFunctorRef == nInsertSuccess, "nInsertSuccess=" << nInsertSuccess << " functor nTestFunctorRef=" << nTestFunctorRef );
 
+            check_before_cleanup( testMap );
+
             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
             timer.reset();
             for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) {
index 57a2031d8c95d7e0502d896448e63cab610d373a..a6ecc14989d77d6e1848a620f113fd8f4ed3b459 100644 (file)
@@ -197,6 +197,7 @@ namespace map2 {
                 << " Map size=" << testMap.size()
                 );
 
+            check_before_cleanup( testMap );
 
             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
             timer.reset();
index deb0432f327e17fefd589f5376312800edc15238..cb4376e7ab82e4549b403fd5a9640ed6aa487387 100644 (file)
@@ -225,6 +225,8 @@ namespace map2 {
             }
             CPPUNIT_MSG( "    Duration=" << timer.duration() );
 
+            check_before_cleanup( testMap );
+
             testMap.clear();
             additional_check( testMap );
             print_stat( testMap );
index 44ea87a265918552259f9bb567a3896762f1db67..fd062d1c3bb3a9e3b184dd493075cdf65a9cd1f6 100644 (file)
@@ -202,6 +202,8 @@ namespace map2 {
             }
             CPPUNIT_MSG( "    Duration=" << timer.duration() );
 
+            check_before_cleanup( testMap );
+
             testMap.clear();
             additional_check( testMap );
             print_stat( testMap );
index f95b838bde4e0663a02d99eca99c9320bede26ee..a3f36f798cb8c9d437048c97e418312bbdb2a91f 100644 (file)
@@ -195,6 +195,7 @@ namespace map2 {
                 << " Map size=" << testMap.size()
                 );
 
+            check_before_cleanup( testMap );
 
             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
             timer.reset();
index 79bfc2fd498b6f2e38645ba145eb47b5ad7f7528..83965cb81a858605e6cfe45b702fd73cd1f069e6 100644 (file)
@@ -175,6 +175,8 @@ namespace map2 {
                 );
 
 
+            check_before_cleanup( testMap );
+
             CPPUNIT_MSG( "  Clear map (single-threaded)..." );
             timer.reset();
             testMap.clear();
index fc13e27f29bd4eb97faf6e3adbfbecf66874bfc9..3b279ad40842b1dcce32f2498c929db344198032 100644 (file)
@@ -145,6 +145,8 @@ namespace map2 {
             CPPUNIT_ASSERT( nInsertFailed == 0 );
             CPPUNIT_ASSERT( nFindFailed == 0 );
 
+            check_before_cleanup( testMap );
+
             testMap.clear();
             additional_check( testMap );
             print_stat( testMap );
index 5c1c3eb7a977bf1be4f7c47c5fc31c50b5455aae..d246c42a9dcbef7bfcab27e99fdfd61e65e5d2ce 100644 (file)
@@ -1838,6 +1838,10 @@ namespace map2 {
     static inline void print_stat( Map const& /*m*/ )
     {}
 
+    template <typename Map>
+    static inline void check_before_cleanup( Map& /*m*/ )
+    {}
+
     template <typename Map>
     static inline void additional_cleanup( Map& /*m*/ )
     {}
@@ -1908,16 +1912,25 @@ namespace map2 {
         ellen_bintree_check::check_stat( s.statistics() );
     }
 
+    template <typename GC, typename Key, typename T, typename Traits>
+    static inline void check_before_cleanup( cc::EllenBinTreeMap<GC, Key, T, Traits>& m )
+    {
+        CPPUNIT_MSG( "  Check internal consistency (single-threaded)..." );
+        CPPUNIT_CHECK_CURRENT( m.check_consistency() );
+    }
+
+
     // BronsonAVLTreeMap
     template <typename GC, typename Key, typename T, typename Traits>
-    static inline void print_stat( cc::BronsonAVLTreeMap<GC, Key, T, Traits> const& s )
+    static inline void print_stat( cc::BronsonAVLTreeMap<GC, Key, T, Traits> const& m )
     {
-        CPPUNIT_MSG( s.statistics() );
+        CPPUNIT_MSG( m.statistics() );
     }
 
     template <typename GC, typename Key, typename T, typename Traits>
-    static inline void additional_check( cc::BronsonAVLTreeMap<GC, Key, T, Traits>& m )
+    static inline void check_before_cleanup( cc::BronsonAVLTreeMap<GC, Key, T, Traits>& m )
     {
+        CPPUNIT_MSG( "  Check internal consistency (single-threaded)..." );
         m.check_consistency([]( size_t nLevel, size_t hLeft, size_t hRight )
             { 
                 CPPUNIT_MSG( "Tree violation on level=" << nLevel << ": hLeft=" << hLeft << ", hRight=" << hRight )