|
17 | 17 | #include <gtest/gtest.h> |
18 | 18 |
|
19 | 19 | #include "rclcpp/experimental/buffers/simple_events_queue.hpp" |
20 | | -#include "rclcpp/experimental/buffers/bounded_events_queue.hpp" |
21 | 20 |
|
22 | 21 | using namespace std::chrono_literals; |
23 | 22 |
|
@@ -76,62 +75,3 @@ TEST_F(TestEventsQueue, SimpleQueueTest) |
76 | 75 | EXPECT_EQ(push_event.entity, front_event.entity); |
77 | 76 | EXPECT_EQ(push_event.type, front_event.type); |
78 | 77 | } |
79 | | - |
80 | | - |
81 | | -TEST_F(TestEventsQueue, BoundedQueueTest) |
82 | | -{ |
83 | | - // Create a BoundedEventsQueue with limit of 10 events and a local events queue |
84 | | - auto bounded_queue = std::make_unique<rclcpp::experimental::buffers::BoundedEventsQueue>(10); |
85 | | - std::queue<rmw_listener_event_t> local_events_queue; |
86 | | - |
87 | | - // Make sure the queue is empty after init |
88 | | - bounded_queue->init(); |
89 | | - EXPECT_TRUE(bounded_queue->empty()); |
90 | | - |
91 | | - // Push 11 messages, the eleventh msg should prune the queue |
92 | | - // and we should end up with only one event on it |
93 | | - for (int i = 0; i < 11; i++) { |
94 | | - rmw_listener_event_t stub_event; |
95 | | - bounded_queue->push(stub_event); |
96 | | - } |
97 | | - |
98 | | - local_events_queue = bounded_queue->get_all_events(); |
99 | | - |
100 | | - size_t local_queue_size = local_events_queue.size(); |
101 | | - |
102 | | - // The queue size should be 1 |
103 | | - EXPECT_EQ(1u, local_queue_size); |
104 | | - |
105 | | - // The bounded queue should be empty after taking all events |
106 | | - EXPECT_TRUE(bounded_queue->empty()); |
107 | | - |
108 | | - // Push 5 messages |
109 | | - for (int i = 0; i < 5; i++) { |
110 | | - rmw_listener_event_t stub_event; |
111 | | - bounded_queue->push(stub_event); |
112 | | - } |
113 | | - |
114 | | - // Pop one message |
115 | | - bounded_queue->pop(); |
116 | | - |
117 | | - local_events_queue = bounded_queue->get_all_events(); |
118 | | - |
119 | | - local_queue_size = local_events_queue.size(); |
120 | | - |
121 | | - // The local queue size should be 4 as the bounded queue shouldn't have been pruned |
122 | | - EXPECT_EQ(4u, local_queue_size); |
123 | | - |
124 | | - // The bounded queue should be empty after taking all events |
125 | | - EXPECT_TRUE(bounded_queue->empty()); |
126 | | - |
127 | | - // Lets push an event into the queue and get it back |
128 | | - rmw_listener_event_t push_event = {bounded_queue.get(), WAITABLE_EVENT}; |
129 | | - |
130 | | - bounded_queue->push(push_event); |
131 | | - |
132 | | - rmw_listener_event_t front_event = bounded_queue->front(); |
133 | | - |
134 | | - // The events should be the equal |
135 | | - EXPECT_EQ(push_event.entity, front_event.entity); |
136 | | - EXPECT_EQ(push_event.type, front_event.type); |
137 | | -} |
0 commit comments