Go to the documentation of this file.00001 #include "cartographer/common/lockless_queue.h"
00002
00003 #include "gtest/gtest.h"
00004
00005 namespace cartographer {
00006 namespace common {
00007 namespace {
00008
00009 TEST(LocklessQueueTest, PushAndPop) {
00010 LocklessQueue<int> queue;
00011 queue.Push(absl::make_unique<int>(1));
00012 queue.Push(absl::make_unique<int>(2));
00013 EXPECT_EQ(*queue.Pop(), 1);
00014 queue.Push(absl::make_unique<int>(3));
00015 queue.Push(absl::make_unique<int>(4));
00016 EXPECT_EQ(*queue.Pop(), 2);
00017 queue.Push(absl::make_unique<int>(5));
00018 EXPECT_EQ(*queue.Pop(), 3);
00019 EXPECT_EQ(*queue.Pop(), 4);
00020 EXPECT_EQ(*queue.Pop(), 5);
00021 EXPECT_EQ(queue.Pop(), nullptr);
00022 }
00023
00024 }
00025 }
00026 }