movable guarded_ptr: unit tests
authorkhizmax <khizmax@gmail.com>
Thu, 20 Nov 2014 10:11:15 +0000 (13:11 +0300)
committerkhizmax <khizmax@gmail.com>
Thu, 20 Nov 2014 10:11:15 +0000 (13:11 +0300)
tests/unit/map2/map_delodd.cpp
tests/unit/pqueue/ellen_bintree_pqueue.h
tests/unit/pqueue/skiplist_pqueue.h
tests/unit/set2/set_delodd.cpp
tests/unit/set2/set_insdel_string.cpp

index e450051..e7ad25f 100644 (file)
@@ -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;
index 0eb71a9..8441e02 100644 (file)
@@ -20,11 +20,10 @@ namespace pqueue {
         template <typename T, typename Tree>
         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 <typename T, typename Tree>
         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();
         }
     };
 
index 92ef9df..0ca4e1b 100644 (file)
@@ -20,11 +20,10 @@ namespace pqueue {
         template <typename T, typename Set>
         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 <typename T, typename Set>
         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();
         }
     };
 
index 82bc58e..8e78a76 100644 (file)
@@ -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;
index 3f5ffcd..689086d 100644 (file)
@@ -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;