36 #include <gtest/gtest.h>
43 #include <boost/shared_array.hpp>
44 #include <boost/bind/bind.hpp>
45 #include <boost/thread.hpp>
56 virtual uint8_t *
serialize(uint8_t *write_ptr, uint32_t seq)
const { (void)seq;
return write_ptr; }
57 virtual uint8_t *
deserialize(uint8_t *read_ptr) {
return read_ptr; }
69 return boost::make_shared<FakeMessage>();
79 boost::mutex::scoped_lock lock(mutex_);
96 boost::function<void(
void)>
cb_;
107 ASSERT_FALSE(queue.
full());
111 ASSERT_TRUE(queue.
full());
115 ASSERT_FALSE(queue.
full());
119 ASSERT_TRUE(queue.
full());
121 ASSERT_TRUE(queue.
ready());
125 ASSERT_TRUE(queue.
full());
130 ASSERT_EQ(helper->calls_, 2);
140 ASSERT_FALSE(queue.
full());
145 ASSERT_FALSE(queue.
full());
147 for (
int i = 0; i < 10000; ++i)
152 ASSERT_FALSE(queue.
full());
154 for (
int i = 0; i < 10000; ++i)
161 ASSERT_EQ(helper->calls_, 10001);
226 boost::barrier barrier(2);
248 boost::barrier bar(2);
252 boost::thread t1(
callThread, boost::ref(queue));
253 boost::thread t2(
callThread, boost::ref(queue));
257 ASSERT_EQ(helper->calls_, 2);
274 boost::thread t1(
callThread, boost::ref(queue));
275 boost::thread t2(
callThread, boost::ref(queue));
279 ASSERT_EQ(helper->calls_, 1);
281 ASSERT_EQ(helper->calls_, 2);
284 int main(
int argc,
char** argv)
286 testing::InitGoogleTest(&argc, argv);
288 return RUN_ALL_TESTS();