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 );
//$$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 >() ; }
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 ));
}
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 );
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 );
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() );
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 );
<< " 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 );