24 #include "gtest/gtest.h" 30 TEST(BlockingQueueTest, testPushPeekPop) {
31 BlockingQueue<std::unique_ptr<int>> blocking_queue;
32 blocking_queue.Push(common::make_unique<int>(42));
33 ASSERT_EQ(1, blocking_queue.Size());
34 blocking_queue.Push(common::make_unique<int>(24));
35 ASSERT_EQ(2, blocking_queue.Size());
36 EXPECT_EQ(42, *blocking_queue.Peek<
int>());
37 ASSERT_EQ(2, blocking_queue.Size());
38 EXPECT_EQ(42, *blocking_queue.Pop());
39 ASSERT_EQ(1, blocking_queue.Size());
40 EXPECT_EQ(24, *blocking_queue.Pop());
41 ASSERT_EQ(0, blocking_queue.Size());
42 EXPECT_EQ(
nullptr, blocking_queue.Peek<
int>());
43 ASSERT_EQ(0, blocking_queue.Size());
46 TEST(BlockingQueueTest, testPushPopSharedPtr) {
47 BlockingQueue<std::shared_ptr<int>> blocking_queue;
48 blocking_queue.Push(std::make_shared<int>(42));
49 blocking_queue.Push(std::make_shared<int>(24));
50 EXPECT_EQ(42, *blocking_queue.Pop());
51 EXPECT_EQ(24, *blocking_queue.Pop());
54 TEST(BlockingQueueTest, testPopWithTimeout) {
55 BlockingQueue<std::unique_ptr<int>> blocking_queue;
60 TEST(BlockingQueueTest, testPushWithTimeout) {
61 BlockingQueue<std::unique_ptr<int>> blocking_queue(1);
63 blocking_queue.PushWithTimeout(common::make_unique<int>(42),
66 blocking_queue.PushWithTimeout(common::make_unique<int>(15),
68 EXPECT_EQ(42, *blocking_queue.Pop());
69 EXPECT_EQ(0, blocking_queue.Size());
72 TEST(BlockingQueueTest, testPushWithTimeoutInfinteQueue) {
73 BlockingQueue<std::unique_ptr<int>> blocking_queue;
75 blocking_queue.PushWithTimeout(common::make_unique<int>(42),
78 blocking_queue.PushWithTimeout(common::make_unique<int>(45),
80 EXPECT_EQ(42, *blocking_queue.Pop());
81 EXPECT_EQ(45, *blocking_queue.Pop());
82 EXPECT_EQ(0, blocking_queue.Size());
85 TEST(BlockingQueueTest, testBlockingPop) {
86 BlockingQueue<std::unique_ptr<int>> blocking_queue;
87 ASSERT_EQ(0, blocking_queue.Size());
91 std::thread thread([&blocking_queue, &pop] { pop = *blocking_queue.Pop(); });
94 blocking_queue.Push(common::make_unique<int>(42));
96 ASSERT_EQ(0, blocking_queue.Size());
100 TEST(BlockingQueueTest, testBlockingPopWithTimeout) {
101 BlockingQueue<std::unique_ptr<int>> blocking_queue;
102 ASSERT_EQ(0, blocking_queue.Size());
106 std::thread thread([&blocking_queue, &pop] {
111 blocking_queue.Push(common::make_unique<int>(42));
113 ASSERT_EQ(0, blocking_queue.Size());
common::Duration FromMilliseconds(const int64 milliseconds)
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)