Replaced some CPPUNIT_ASSERT with CPPUNIT_CHECK in map test
authorkhizmax <libcds.dev@gmail.com>
Tue, 17 Mar 2015 20:28:32 +0000 (23:28 +0300)
committerkhizmax <libcds.dev@gmail.com>
Tue, 17 Mar 2015 20:28:32 +0000 (23:28 +0300)
tests/unit/map2/map_find_int.cpp
tests/unit/map2/map_find_string.cpp
tests/unit/map2/map_insdel_item_int.cpp
tests/unit/map2/map_insdel_string.cpp
tests/unit/map2/map_insfind_int.cpp

index d796e48ba303f3189246f2a0c0127e941e486647..8e4f22c05e06538895fdaed2aaf5f416671751a4 100644 (file)
@@ -192,10 +192,10 @@ namespace map2 {
 
             for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) {
                 Thread * pThread = static_cast<Thread *>( *it );
-                CPPUNIT_ASSERT( pThread->m_KeyExists.nFailed == 0 );
-                CPPUNIT_ASSERT( pThread->m_KeyExists.nSuccess == m_nRealMapSize * c_nPassCount );
-                CPPUNIT_ASSERT( pThread->m_KeyNotExists.nFailed == 0 );
-                CPPUNIT_ASSERT( pThread->m_KeyNotExists.nSuccess == (m_Arr.size() - m_nRealMapSize) * c_nPassCount );
+                CPPUNIT_CHECK( pThread->m_KeyExists.nFailed == 0 );
+                CPPUNIT_CHECK( pThread->m_KeyExists.nSuccess == m_nRealMapSize * c_nPassCount );
+                CPPUNIT_CHECK( pThread->m_KeyNotExists.nFailed == 0 );
+                CPPUNIT_CHECK( pThread->m_KeyNotExists.nSuccess == (m_Arr.size() - m_nRealMapSize) * c_nPassCount );
             }
 
             check_before_cleanup( testMap );
index fbdc0e48a7ed036dbed19a1959da4726f375f091..e1398b9c394bce4e038e9c4499b486870bc6305a 100644 (file)
@@ -1,13 +1,10 @@
 //$$CDS-header$$
 
-// defines concurrent access to map::nonconcurrent_iterator::Sequence::TValue::nAccess field
-
 #include "map2/map_types.h"
 #include "cppunit/thread.h"
 
 #include <vector>
 
-// find int test in map<int> in mutithreaded mode
 namespace map2 {
 
 #   define TEST_MAP(X)         void X() { test<MapTypes<key_type, value_type>::X >()    ; }
@@ -178,7 +175,7 @@ namespace map2 {
             CPPUNIT_MSG( "  Fill map...");
             timer.reset();
             for ( size_t i = 0; i < m_Arr.size(); ++i ) {
-                // Âñå êëþ÷è â arrData - óíèêàëüíûå, ïîýòîìó îøèáîê ïðè âñòàâêå áûòü íå äîëæíî
+                // All keys in arrData are unique, insert() must be successful
                 if ( m_Arr[i].bExists )
                     CPPUNIT_ASSERT( check_result( testMap.insert( *(m_Arr[i].pKey), m_Arr[i] ), testMap ));
             }
@@ -190,13 +187,13 @@ namespace map2 {
             pool.run();
             CPPUNIT_MSG( "   Duration=" << pool.avgDuration() );
 
-            // Ïðîâåðÿåì, ÷òî ó âñåõ threads ÷èñëî óñïåøíûõ ïîèñêîâ = ÷èñëó ýëåìåíòîâ â map
+            // Postcondition: the number of success searching == the number of map item
             for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) {
                 Thread * pThread = static_cast<Thread *>( *it );
-                CPPUNIT_ASSERT( pThread->m_KeyExists.nSuccess == m_nRealMapSize * c_nPassCount );
-                CPPUNIT_ASSERT( pThread->m_KeyExists.nFailed == 0 );
-                CPPUNIT_ASSERT( pThread->m_KeyNotExists.nSuccess == (m_Arr.size() - m_nRealMapSize) * c_nPassCount );
-                CPPUNIT_ASSERT( pThread->m_KeyNotExists.nFailed == 0 );
+                CPPUNIT_CHECK( pThread->m_KeyExists.nSuccess == m_nRealMapSize * c_nPassCount );
+                CPPUNIT_CHECK( pThread->m_KeyExists.nFailed == 0 );
+                CPPUNIT_CHECK( pThread->m_KeyNotExists.nSuccess == (m_Arr.size() - m_nRealMapSize) * c_nPassCount );
+                CPPUNIT_CHECK( pThread->m_KeyNotExists.nFailed == 0 );
             }
 
             check_before_cleanup( testMap );
index cb4376e7ab82e4549b403fd5a9640ed6aa487387..ad80499c13bc36437985b6037e2df1219485bb76 100644 (file)
@@ -199,20 +199,20 @@ namespace map2 {
             for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) {
                 InserterThread * pThread = dynamic_cast<InserterThread *>( *it );
                 if ( pThread ) {
-                    CPPUNIT_ASSERT( pThread->m_nInsertSuccess == c_nAttemptCount );
+                    CPPUNIT_CHECK( pThread->m_nInsertSuccess == c_nAttemptCount );
                     nInsertSuccess += pThread->m_nInsertSuccess;
                     nInsertFailed += pThread->m_nInsertFailed;
                 }
                 else {
                     DeleterThread * p = static_cast<DeleterThread *>( *it );
-                    CPPUNIT_ASSERT( p->m_nDeleteSuccess == c_nAttemptCount );
+                    CPPUNIT_CHECK( p->m_nDeleteSuccess == c_nAttemptCount );
                     nDeleteSuccess += p->m_nDeleteSuccess;
                     nDeleteFailed += p->m_nDeleteFailed;
                 }
             }
-            CPPUNIT_ASSERT( nInsertSuccess == nDeleteSuccess );
+            CPPUNIT_CHECK( nInsertSuccess == nDeleteSuccess );
             size_t nGoalItem = c_nGoalItem;
-            CPPUNIT_ASSERT( testMap.find( nGoalItem ));
+            CPPUNIT_CHECK( testMap.find( nGoalItem ));
 
 
             CPPUNIT_MSG( "    Totals: Ins fail=" << nInsertFailed << " Del fail=" << nDeleteFailed );
@@ -221,7 +221,7 @@ namespace map2 {
             CPPUNIT_MSG( "    Check if the map contains all items" );
             timer.reset();
             for ( size_t i = 0; i < c_nMapSize; ++i ) {
-                CPPUNIT_ASSERT( testMap.find( i ));
+                CPPUNIT_CHECK_EX( testMap.find( i ), "key " << i );
             }
             CPPUNIT_MSG( "    Duration=" << timer.duration() );
 
index a3f36f798cb8c9d437048c97e418312bbdb2a91f..6fab9045e1c78812c49e0cb0c7c16c766544de34 100644 (file)
@@ -202,7 +202,7 @@ namespace map2 {
             for ( size_t i = 0; i < m_parrString->size(); ++i )
                 testMap.erase( (*m_parrString)[i] );
             CPPUNIT_MSG( "   Duration=" << timer.duration() );
-            CPPUNIT_ASSERT( testMap.empty() );
+            CPPUNIT_CHECK( testMap.empty() );
 
             additional_check( testMap );
             print_stat( testMap );
index 3b279ad40842b1dcce32f2498c929db344198032..c2b21bfc77b820ce3b682ed4e60ea0d639eb501a 100644 (file)
@@ -142,8 +142,8 @@ namespace map2 {
                       << "           Find succ=" << nFindSuccess << " fail=" << nFindFailed
             );
 
-            CPPUNIT_ASSERT( nInsertFailed == 0 );
-            CPPUNIT_ASSERT( nFindFailed == 0 );
+            CPPUNIT_CHECK( nInsertFailed == 0 );
+            CPPUNIT_CHECK( nFindFailed == 0 );
 
             check_before_cleanup( testMap );