18 #include <gtest/gtest.h> 19 #include <gmock/gmock.h> 29 auto status_monitor = std::make_shared<StatusMonitor>();
33 observed_queue.
enqueue(
"hello");
36 ASSERT_TRUE(observed_queue.
dequeue(data, std::chrono::microseconds(0)));
37 EXPECT_EQ(
"hello", data);
38 EXPECT_TRUE(observed_queue.
empty());
42 TEST(observed_queue_test, Sanity) {
46 TEST(observed_queue_test, enqueue_dequeue_test) {
51 TEST(observed_queue_test, blocking_enqueue_dequeue_test) {
56 TEST(observed_queue_test, synchronized_enqueue_dequeue_test) {
61 TEST(observed_queue_test, enqueue_blocked_dequeue_test) {
63 auto status_monitor = std::make_shared<StatusMonitor>();
67 EXPECT_TRUE(observed_queue.
tryEnqueue(
"hello", std::chrono::seconds(0)));
68 EXPECT_FALSE(observed_queue.
tryEnqueue(
"fail", std::chrono::seconds(0)));
70 ASSERT_TRUE(observed_queue.
dequeue(data, std::chrono::microseconds(0)));
71 EXPECT_EQ(
"hello", data);
72 EXPECT_TRUE(observed_queue.
tryEnqueue(
"hello", std::chrono::seconds(0)));
virtual void setStatusMonitor(std::shared_ptr< StatusMonitor > status_monitor)=0
void test_enqueue_dequeue(IObservedQueue< std::string > &observed_queue)
bool dequeue(T &data, const std::chrono::microseconds &duration) override
void setStatusMonitor(std::shared_ptr< StatusMonitor > status_monitor) override
bool tryEnqueue(T &value, const std::chrono::microseconds &duration) override
TEST(observed_queue_test, Sanity)
virtual bool dequeue(T &, const std::chrono::microseconds &duration)=0
virtual bool enqueue(T &&value)=0
virtual bool empty() const =0