Refactors sequential misc test cases
[libcds.git] / test / stress / sequential / sequential-misc / rigtorp_mpmc_driver.cpp
index 743a64a..0066f90 100644 (file)
@@ -15,38 +15,39 @@ protected:
   static size_t s_nRigtorpMPMCQueueCapacity;
 
   static void SetUpTestCase() {
   static size_t s_nRigtorpMPMCQueueCapacity;
 
   static void SetUpTestCase() {
-    cds_test::config const &cfg = get_config("Misc");
-    GetConfig(RigtorpMPMCQueuePassCount);
-    GetConfig(RigtorpMPMCQueueEnqueueStride);
-    GetConfig(RigtorpMPMCQueueCapacity);
+    cds_test::config const &cfg = get_config("SequentialMisc");
+    GetConfigExpected(RigtorpMPMCQueuePassCount, 10000);
+    GetConfigExpected(RigtorpMPMCQueueEnqueueStride, 1024);
+    GetConfigExpected(RigtorpMPMCQueueCapacity, 2048);
+    if (s_nRigtorpMPMCQueueCapacity <= s_nRigtorpMPMCQueueEnqueueStride) {
+      s_nRigtorpMPMCQueueCapacity = 2 * s_nRigtorpMPMCQueueEnqueueStride;
+    }
   }
 
   void test() {
   }
 
   void test() {
-    rigtorp::MPMCQueue<size_t> q(s_nRigtorpMPMCQueueCapacity);
+    std::unique_ptr<rigtorp::MPMCQueue<size_t>> q(
+        new rigtorp::MPMCQueue<size_t>(s_nRigtorpMPMCQueueCapacity));
     size_t nNo = 0;
     size_t pop_sum = 0;
 
     while (nNo < s_nRigtorpMPMCQueuePassCount) {
     size_t nNo = 0;
     size_t pop_sum = 0;
 
     while (nNo < s_nRigtorpMPMCQueuePassCount) {
-      size_t curr_push_count =
-          std::min(s_nRigtorpMPMCQueuePassCount - nNo, s_nRigtorpMPMCQueueEnqueueStride);
+      size_t curr_push_count = std::min(s_nRigtorpMPMCQueuePassCount - nNo,
+                                        s_nRigtorpMPMCQueueEnqueueStride);
       for (size_t i = 0; i < curr_push_count; i++) {
       for (size_t i = 0; i < curr_push_count; i++) {
-        q.push(nNo);
+        q->push(nNo);
         ++nNo;
       }
 
       for (size_t i = 0; i < curr_push_count; i++) {
         size_t res;
         ++nNo;
       }
 
       for (size_t i = 0; i < curr_push_count; i++) {
         size_t res;
-        q.pop(res);
+        q->pop(res);
         pop_sum += res;
       }
     }
 
     size_t supposed_sum =
         s_nRigtorpMPMCQueuePassCount * (s_nRigtorpMPMCQueuePassCount - 1) / 2;
         pop_sum += res;
       }
     }
 
     size_t supposed_sum =
         s_nRigtorpMPMCQueuePassCount * (s_nRigtorpMPMCQueuePassCount - 1) / 2;
-    if (pop_sum != supposed_sum) {
-      std::cout << "Sequential rigtorpMPMC queue pop sum: " << pop_sum
-                << " != " << supposed_sum << "\n";
-    }
+    EXPECT_EQ(pop_sum, supposed_sum);
   }
 };
 
   }
 };