formatting
[libcds.git] / test / stress / queue / intrusive_push_pop.cpp
index ea229eaea9173d574cbebbccbbe3216fdc72e5f4..2db3c5396d750903635b1750ab1eda2f3f320d17 100644 (file)
@@ -1,11 +1,11 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #include "intrusive_queue_type.h"
@@ -175,7 +175,7 @@ namespace {
                     }
                     else {
                         ++m_nPopEmpty;
-                        if ( s_nProducerCount.load( atomics::memory_order_acquire ) == 0 && m_Queue.empty() )
+                        if ( s_nProducerCount.load( atomics::memory_order_acquire ) == 0 && m_Queue.empty())
                             break;
                     }
                 }
@@ -195,10 +195,10 @@ namespace {
         };
 
     public:
-        static void SetUpTestCase()\r
-        {\r
-            cds_test::config const& cfg = get_config( "queue_random" );\r
-\r
+        static void SetUpTestCase()
+        {
+            cds_test::config const& cfg = get_config( "queue_random" );
+
             s_nReaderThreadCount = cfg.get_size_t( "ReaderCount", s_nReaderThreadCount );
             s_nWriterThreadCount = cfg.get_size_t( "WriterCount", s_nWriterThreadCount );
             s_nQueueSize = cfg.get_size_t( "QueueSize", s_nQueueSize );
@@ -206,26 +206,25 @@ namespace {
             s_nFCPassCount = cfg.get_uint( "FCPassCount", s_nFCPassCount );
             s_nFCCompactFactor = cfg.get_uint( "FCCompactFactor", s_nFCCompactFactor );
 
-            if ( s_nReaderThreadCount == 0 )
+            if ( s_nReaderThreadCount == 0u )
                 s_nReaderThreadCount = 1;
-            if ( s_nWriterThreadCount == 0 )
+            if ( s_nWriterThreadCount == 0u )
                 s_nWriterThreadCount = 1;
-            if ( s_nQueueSize == 0 )
+            if ( s_nQueueSize == 0u )
                 s_nQueueSize = 1000;
-        }\r
-\r
-        //static void TearDownTestCase();\r
+        }
+
+        //static void TearDownTestCase();
 
     protected:
         template <class Queue>
         void analyze( Queue& testQueue, size_t /*nLeftOffset*/, size_t nRightOffset )
         {
             typedef Consumer<Queue> Reader;
-            typedef Producer<Queue> Writer;
             typedef typename Reader::const_data_iterator    ReaderIterator;
 
             size_t nPostTestPops = 0;
-            while ( testQueue.pop() )
+            while ( testQueue.pop())
                 ++nPostTestPops;
 
             size_t nTotalPops = 0;
@@ -243,7 +242,7 @@ namespace {
                     nTotalPops += consumer.m_nPopped;
                     nPopFalse += consumer.m_nPopEmpty;
                     arrReaders.push_back( &consumer );
-                    EXPECT_EQ( consumer.m_nBadWriter, 0 ) << "consumer " << (i - s_nWriterThreadCount);
+                    EXPECT_EQ( consumer.m_nBadWriter, 0u ) << "consumer " << (i - s_nWriterThreadCount);
 
                     size_t nPopped = 0;
                     for ( size_t n = 0; n < s_nWriterThreadCount; ++n )
@@ -260,7 +259,7 @@ namespace {
                     Producer<Queue>& producer = static_cast<Producer<Queue>&>( thr );
                     nPushFailed += producer.m_nPushFailed;
                     if ( !std::is_base_of<cds::bounded_container, Queue>::value ) {
-                        EXPECT_EQ( producer.m_nPushFailed, 0 ) << "producer " << i;
+                        EXPECT_EQ( producer.m_nPushFailed, 0u ) << "producer " << i;
                     }
                 }
             }
@@ -272,7 +271,7 @@ namespace {
 
             size_t nQueueSize = s_nThreadPushCount * s_nWriterThreadCount;
             EXPECT_EQ( nTotalPops + nPostTestPops, nQueueSize );
-            EXPECT_TRUE( testQueue.empty() );
+            EXPECT_TRUE( testQueue.empty());
 
             // Test that all items have been popped
             // Test FIFO order
@@ -294,15 +293,15 @@ namespace {
                     for ( it = arrReaders[nReader]->m_WriterData[nWriter].begin(); it != itEnd; ++it )
                         arrData.push_back( *it );
                 }
-                std::sort( arrData.begin(), arrData.end() );
+                std::sort( arrData.begin(), arrData.end());
                 for ( size_t i=1; i < arrData.size(); ++i ) {
                     if ( arrData[i-1] + 1 != arrData[i] ) {
-                        EXPECT_EQ( arrData[i-1] + 1,  arrData[i] ) << "Writer " << nWriter << ": [" << (i-1) << "]=" << arrData[i-1] 
+                        EXPECT_EQ( arrData[i-1] + 1,  arrData[i] ) << "Writer " << nWriter << ": [" << (i-1) << "]=" << arrData[i-1]
                             << ", [" << i << "]=" << arrData[i];
                     }
                 }
 
-                EXPECT_EQ( arrData[0], 0 ) << "Writer " << nWriter;
+                EXPECT_EQ( arrData[0], 0u ) << "Writer " << nWriter;
                 EXPECT_EQ( arrData[arrData.size() - 1], s_nThreadPushCount - 1 ) << "Writer " << nWriter;
             }
         }
@@ -352,7 +351,7 @@ namespace {
                     if ( it->nConsumer == c_nBadConsumer )
                         ++nBadConsumerCount;
                 }
-                EXPECT_EQ( nBadConsumerCount, 0 );
+                EXPECT_EQ( nBadConsumerCount, 0u );
             }
 
             analyze( q, nLeftOffset, nRightOffset );
@@ -437,8 +436,6 @@ namespace {
         test( q, arrValue, 0, 0 ); \
     }
 
-    CDSSTRESS_QUEUE_F( TsigasCycleQueue_dyn )
-    CDSSTRESS_QUEUE_F( TsigasCycleQueue_dyn_ic )
     CDSSTRESS_QUEUE_F( VyukovMPMCCycleQueue_dyn )
     CDSSTRESS_QUEUE_F( VyukovMPMCCycleQueue_dyn_ic )
 #undef CDSSTRESS_QUEUE_F
@@ -512,8 +509,21 @@ namespace {
     //CDSSTRESS_QUEUE_F( SegmentedQueue_DHP_mutex_padding )
     CDSSTRESS_QUEUE_F( SegmentedQueue_DHP_mutex_stat )
 
+
+#ifdef CDSTEST_GTEST_INSTANTIATE_TEST_CASE_P_HAS_4TH_ARG
+    static std::string get_test_parameter_name( testing::TestParamInfo<size_t> const& p )
+    {
+        return std::to_string( p.param );
+    }
+
     INSTANTIATE_TEST_CASE_P( SQ,
         intrusive_segmented_queue_push_pop,
-        ::testing::ValuesIn( intrusive_segmented_queue_push_pop::get_test_parameters() ) );
+        ::testing::ValuesIn( intrusive_segmented_queue_push_pop::get_test_parameters()), get_test_parameter_name );
+#else
+    INSTANTIATE_TEST_CASE_P( SQ,
+        intrusive_segmented_queue_push_pop,
+        ::testing::ValuesIn( intrusive_segmented_queue_push_pop::get_test_parameters()));
+#endif
+
 
 } // namespace