Splits deque take & steal into 2 test caess
authorPeizhao Ou <peizhaoo@uci.edu>
Wed, 24 Jan 2018 23:18:10 +0000 (15:18 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Wed, 24 Jan 2018 23:18:10 +0000 (15:18 -0800)
test/stress/sequential/sequential-misc/deque_driver.cpp

index 066296b..9fe9813 100644 (file)
@@ -76,14 +76,35 @@ ullong ChaseLevDequeTest::push_count;
 ullong ChaseLevDequeTest::push_sum;
 Deque *ChaseLevDequeTest::deque;
 
-TEST_F(ChaseLevDequeTest, ChaseLevDeque) {
-  deque = new Deque();
+TEST_F(ChaseLevDequeTest, ChaseLevDeque_push_take) {
+  std::unique_ptr<Deque> deque(new Deque());
+  size_t sum = 0;
   int res;
   for (size_t i = 0; i < s_nDequePassCount; ++i) {
     deque->push(i);
     res = deque->take();
+    sum += res;
+  }
+  size_t supposed_sum = s_nDequePassCount * (s_nDequePassCount - 1) / 2;
+  if (sum != supposed_sum) {
+    std::cout << "Sequential deque take sum: " << sum << " != " << supposed_sum
+              << "\n";
+  }
+}
+
+TEST_F(ChaseLevDequeTest, ChaseLevDeque_push_steal) {
+  std::unique_ptr<Deque> deque(new Deque());
+  size_t sum = 0;
+  int res;
+  for (size_t i = 0; i < s_nDequePassCount; ++i) {
     deque->push(i);
     res = deque->steal();
+    sum += res;
+  }
+  size_t supposed_sum = s_nDequePassCount * (s_nDequePassCount - 1) / 2;
+  if (sum != supposed_sum) {
+    std::cout << "Sequential deque steal sum: " << sum << " != " << supposed_sum
+              << "\n";
   }
 }