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";
}
}