From f8696776f2ac2615d18d671a1daf187a09d00941 Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 17 Mar 2015 23:28:32 +0300 Subject: [PATCH] Replaced some CPPUNIT_ASSERT with CPPUNIT_CHECK in map test --- tests/unit/map2/map_find_int.cpp | 8 ++++---- tests/unit/map2/map_find_string.cpp | 15 ++++++--------- tests/unit/map2/map_insdel_item_int.cpp | 10 +++++----- tests/unit/map2/map_insdel_string.cpp | 2 +- tests/unit/map2/map_insfind_int.cpp | 4 ++-- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/unit/map2/map_find_int.cpp b/tests/unit/map2/map_find_int.cpp index d796e48b..8e4f22c0 100644 --- a/tests/unit/map2/map_find_int.cpp +++ b/tests/unit/map2/map_find_int.cpp @@ -192,10 +192,10 @@ namespace map2 { for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { Thread * pThread = static_cast( *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 ); diff --git a/tests/unit/map2/map_find_string.cpp b/tests/unit/map2/map_find_string.cpp index fbdc0e48..e1398b9c 100644 --- a/tests/unit/map2/map_find_string.cpp +++ b/tests/unit/map2/map_find_string.cpp @@ -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 -// find int test in map in mutithreaded mode namespace map2 { # define TEST_MAP(X) void X() { test::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( *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 ); diff --git a/tests/unit/map2/map_insdel_item_int.cpp b/tests/unit/map2/map_insdel_item_int.cpp index cb4376e7..ad80499c 100644 --- a/tests/unit/map2/map_insdel_item_int.cpp +++ b/tests/unit/map2/map_insdel_item_int.cpp @@ -199,20 +199,20 @@ namespace map2 { for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { InserterThread * pThread = dynamic_cast( *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( *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() ); diff --git a/tests/unit/map2/map_insdel_string.cpp b/tests/unit/map2/map_insdel_string.cpp index a3f36f79..6fab9045 100644 --- a/tests/unit/map2/map_insdel_string.cpp +++ b/tests/unit/map2/map_insdel_string.cpp @@ -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 ); diff --git a/tests/unit/map2/map_insfind_int.cpp b/tests/unit/map2/map_insfind_int.cpp index 3b279ad4..c2b21bfc 100644 --- a/tests/unit/map2/map_insfind_int.cpp +++ b/tests/unit/map2/map_insfind_int.cpp @@ -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 ); -- 2.34.1