From: khizmax Date: Thu, 20 Nov 2014 10:11:15 +0000 (+0300) Subject: movable guarded_ptr: unit tests X-Git-Tag: v2.0.0~64 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=170cc8b0b58d99a7bd6bf8b4abfb25f29079e16e movable guarded_ptr: unit tests --- diff --git a/tests/unit/map2/map_delodd.cpp b/tests/unit/map2/map_delodd.cpp index e450051f..e7ad25f8 100644 --- a/tests/unit/map2/map_delodd.cpp +++ b/tests/unit/map2/map_delodd.cpp @@ -360,7 +360,8 @@ namespace map2 { for ( size_t k = 0; k < c_nInsThreadCount; ++k ) { for ( size_t i = 0; i < arrData.size(); ++i ) { if ( arrData[i] & 1 ) { - if ( rMap.extract_with( gp, arrData[i], key_less() )) + gp = rMap.extract_with( arrData[i], key_less()); + if ( gp ) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -374,7 +375,8 @@ namespace map2 { for ( size_t k = 0; k < c_nInsThreadCount; ++k ) { for ( size_t i = arrData.size() - 1; i > 0; --i ) { if ( arrData[i] & 1 ) { - if ( rMap.extract_with( gp, arrData[i], key_less() )) + gp = rMap.extract_with( arrData[i], key_less()); + if ( gp ) ++m_nDeleteSuccess; else ++m_nDeleteFailed; diff --git a/tests/unit/pqueue/ellen_bintree_pqueue.h b/tests/unit/pqueue/ellen_bintree_pqueue.h index 0eb71a91..8441e02d 100644 --- a/tests/unit/pqueue/ellen_bintree_pqueue.h +++ b/tests/unit/pqueue/ellen_bintree_pqueue.h @@ -20,11 +20,10 @@ namespace pqueue { template bool operator()( T& dest, Tree& container ) const { - typename Tree::guarded_ptr gp; - bool bRet = container.extract_max( gp ); - if ( bRet ) + typename Tree::guarded_ptr gp( container.extract_max()); + if ( gp ) dest = *gp; - return bRet; + return !gp.empty(); } }; @@ -47,11 +46,10 @@ namespace pqueue { template bool operator()( T& dest, Tree& container ) const { - typename Tree::guarded_ptr gp; - bool bRet = container.extract_min( gp ); - if ( bRet ) + typename Tree::guarded_ptr gp( container.extract_min()); + if ( gp ) dest = *gp; - return bRet; + return !gp.empty(); } }; diff --git a/tests/unit/pqueue/skiplist_pqueue.h b/tests/unit/pqueue/skiplist_pqueue.h index 92ef9df0..0ca4e1b8 100644 --- a/tests/unit/pqueue/skiplist_pqueue.h +++ b/tests/unit/pqueue/skiplist_pqueue.h @@ -20,11 +20,10 @@ namespace pqueue { template bool operator()( T& dest, Set& container ) const { - typename Set::guarded_ptr gp; - bool bRet = container.extract_max( gp ); - if ( bRet ) + typename Set::guarded_ptr gp( container.extract_max()); + if ( gp ) dest = *gp; - return bRet; + return !gp.empty(); } }; @@ -47,11 +46,10 @@ namespace pqueue { template bool operator()( T& dest, Set& container ) const { - typename Set::guarded_ptr gp; - bool bRet = container.extract_min( gp ); - if ( bRet ) + typename Set::guarded_ptr gp( container.extract_min()); + if ( gp ) dest = *gp; - return bRet; + return !gp.empty(); } }; diff --git a/tests/unit/set2/set_delodd.cpp b/tests/unit/set2/set_delodd.cpp index 82bc58ee..8e78a763 100644 --- a/tests/unit/set2/set_delodd.cpp +++ b/tests/unit/set2/set_delodd.cpp @@ -401,7 +401,8 @@ namespace set2 { for ( size_t k = 0; k < c_nInsThreadCount; ++k ) { for ( size_t i = 0; i < arrData.size(); ++i ) { if ( arrData[i] & 1 ) { - if ( rSet.extract_with( gp, arrData[i], key_less() )) + gp = rSet.extract_with( arrData[i], key_less()); + if ( gp ) ++m_nExtractSuccess; else ++m_nExtractFailed; @@ -415,7 +416,8 @@ namespace set2 { for ( size_t k = 0; k < c_nInsThreadCount; ++k ) { for ( size_t i = arrData.size() - 1; i > 0; --i ) { if ( arrData[i] & 1 ) { - if ( rSet.extract_with( gp, arrData[i], key_less() )) + gp = rSet.extract_with( arrData[i], key_less()); + if ( gp ) ++m_nExtractSuccess; else ++m_nExtractFailed; diff --git a/tests/unit/set2/set_insdel_string.cpp b/tests/unit/set2/set_insdel_string.cpp index 3f5ffcdd..689086de 100644 --- a/tests/unit/set2/set_insdel_string.cpp +++ b/tests/unit/set2/set_insdel_string.cpp @@ -203,7 +203,8 @@ namespace set2 { if ( m_nThreadNo & 1 ) { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) { - if ( rSet.extract( gp, arrString[nItem % nArrSize] ) ) + gp = rSet.extract( arrString[nItem % nArrSize]); + if ( gp ) ++m_nDeleteSuccess; else ++m_nDeleteFailed; @@ -213,7 +214,8 @@ namespace set2 { else { for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) { for ( size_t nItem = c_nMapSize; nItem > 0; --nItem ) { - if ( rSet.extract( gp, arrString[nItem % nArrSize] ) ) + gp = rSet.extract( arrString[nItem % nArrSize]); + if ( gp ) ++m_nDeleteSuccess; else ++m_nDeleteFailed;