23 #include <gmock/gmock.h> 24 #include <gtest/gtest.h> 25 #include <boost/thread/barrier.hpp> 27 using namespace folly;
43 arg0->fireReadException(arg1);
47 arg0->fireWrite(arg1);
55 TEST(PipelineTest, RealHandlersCompile) {
63 AsyncSocketHandler(
socket),
65 EXPECT_TRUE(pipeline->getHandler<AsyncSocketHandler>());
81 TEST(PipelineTest, FireActions) {
92 &handler1, &handler2);
98 EXPECT_CALL(handler1, readEOF(
_)).WillOnce(FireReadEOF());
102 EXPECT_CALL(handler1, readException(
_,
_)).WillOnce(FireReadException());
104 pipeline->readException(make_exception_wrapper<std::runtime_error>(
"blah"));
123 TEST(PipelineTest, ReachEndOfPipeline) {
131 EXPECT_CALL(handler, readEOF(
_)).WillOnce(FireReadEOF());
134 EXPECT_CALL(handler, readException(
_,
_)).WillOnce(FireReadException());
135 pipeline->readException(make_exception_wrapper<std::runtime_error>(
"blah"));
147 TEST(PipelineTest, TurnAround) {
158 &handler1, &handler2);
172 TEST(PipelineTest, DynamicFireActions) {
211 TEST(PipelineTest, DynamicAttachDetachOrder) {
230 TEST(PipelineTest, GetContext) {
238 TEST(PipelineTest, HandlerInMultiplePipelines) {
247 TEST(PipelineTest, HandlerInPipelineTwice) {
248 auto handler = std::make_shared<IntHandler>();
253 pipeline->finalize();
258 TEST(PipelineTest, NoDetachOnOwner) {
262 pipeline->setOwner(&handler);
265 template <
class Rin,
class Rout = Rin,
class Win = Rout,
class Wout = Rin>
269 void read(Context*, Rin )
override {}
283 EXPECT_THROW(pipeline->readEOF(), std::invalid_argument);
286 std::invalid_argument);
287 EXPECT_THROW(pipeline->write(0), std::invalid_argument);
406 for (
int i = 0;
i < 100000;
i++) {
416 TEST(PipelineTest, NumHandler) {
421 pipeline->addBack(&handler1);
424 pipeline->addBack(&handler2);
427 pipeline->finalize();
430 pipeline->remove(&handler1);
433 pipeline->remove(&handler2);
438 TEST(PipelineTest, HandlerReuse) {
448 EXPECT_NE(
nullptr, handler2.getContext());
452 pipeline1->removeBack();
453 ASSERT_EQ(
nullptr, handler2.getContext());
461 EXPECT_NE(
nullptr, handler2.getContext());
464 pipeline2->remove(&handler2);
465 pipeline2->remove(&handler3);
466 ASSERT_EQ(
nullptr, handler2.getContext());
467 ASSERT_EQ(
nullptr, handler3.getContext());
475 EXPECT_NE(
nullptr, handler2.getContext());
#define EXPECT_NO_THROW(statement)
#define EXPECT_THROW(statement, expected_exception)
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
void handler(int, siginfo_t *, void *)
ConcreteHandler< std::string, int > StringToIntHandler
Handler< Rin, Rout, Win, Wout >::Context Context
NetworkSocket socket(int af, int type, int protocol)
HandlerAdapter< std::string, std::string > StringHandler
#define EXPECT_TRUE(condition)
static std::shared_ptr< AsyncSocket > newSocket(EventBase *evb)
ConcreteHandler< int, std::string > IntToStringHandler
Future< Unit > write(Context *, Win) override
#define EXPECT_NE(val1, val2)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
Future< typename std::decay< T >::type > makeFuture(T &&t)
StrictMock< MockHandlerAdapter< int, int > > IntHandler
void read(Context *, Rin) override