99#include < cstring>
1010
1111#if !defined(_WIN32)
12- #include < unistd.h>
12+ #include < unistd.h>
1313#endif // !_WIN32
1414
1515TEST_CASE (" create destroy" , " [active_poller]" )
@@ -95,18 +95,15 @@ TEST_CASE("add fd handler", "[active_poller]")
9595{
9696 int fd = 1 ;
9797 zmq::active_poller_t active_poller;
98- CHECK_NOTHROW (
99- active_poller.add (fd, zmq::event_flags::pollin, no_op_handler));
98+ CHECK_NOTHROW (active_poller.add (fd, zmq::event_flags::pollin, no_op_handler));
10099}
101100
102101TEST_CASE (" remove fd handler" , " [active_poller]" )
103102{
104103 int fd = 1 ;
105104 zmq::active_poller_t active_poller;
106- CHECK_NOTHROW (
107- active_poller.add (fd, zmq::event_flags::pollin, no_op_handler));
108- CHECK_NOTHROW (
109- active_poller.remove (fd));
105+ CHECK_NOTHROW (active_poller.add (fd, zmq::event_flags::pollin, no_op_handler));
106+ CHECK_NOTHROW (active_poller.remove (fd));
110107 CHECK_THROWS_ZMQ_ERROR (EINVAL, active_poller.remove (100 ));
111108}
112109
@@ -117,7 +114,7 @@ TEST_CASE("mixed socket and fd handlers", "[active_poller]")
117114{
118115 int pipefd[2 ];
119116 ::pipe (pipefd);
120-
117+
121118 zmq::context_t context;
122119 constexpr char inprocSocketAddress[] = " inproc://mixed-handlers" ;
123120 zmq::socket_t socket_rcv{context, zmq::socket_type::pair};
@@ -128,31 +125,29 @@ TEST_CASE("mixed socket and fd handlers", "[active_poller]")
128125 unsigned eventsFd = 0 ;
129126 unsigned eventsSocket = 0 ;
130127
131- constexpr char messageText[] = " message" ;
132- constexpr size_t messageSize = sizeof (messageText);
128+ constexpr char messageText[] = " message" ;
129+ constexpr size_t messageSize = sizeof (messageText);
133130
134131 zmq::active_poller_t active_poller;
135- CHECK_NOTHROW (
136- active_poller.add (pipefd[0 ], zmq::event_flags::pollin, [&](zmq::event_flags flags) {
137- if (flags == zmq::event_flags::pollin)
138- {
139- char buffer[256 ];
140- CHECK (messageSize == ::read (pipefd[0 ], buffer, messageSize));
141- CHECK (0 == std::strcmp (buffer, messageText));
142- ++eventsFd;
143- }
144- }));
145- CHECK_NOTHROW (
146- active_poller.add (socket_rcv, zmq::event_flags::pollin, [&](zmq::event_flags flags) {
147- if (flags == zmq::event_flags::pollin)
148- {
149- zmq::message_t msg;
150- CHECK (socket_rcv.recv (msg, zmq::recv_flags::dontwait).has_value ());
151- CHECK (messageSize == msg.size ());
152- CHECK (0 == std::strcmp (messageText, msg.data <const char >()));
153- ++eventsSocket;
154- }
155- }));
132+ CHECK_NOTHROW (active_poller.add (
133+ pipefd[0 ], zmq::event_flags::pollin, [&](zmq::event_flags flags) {
134+ if (flags == zmq::event_flags::pollin) {
135+ char buffer[256 ];
136+ CHECK (messageSize == ::read (pipefd[0 ], buffer, messageSize));
137+ CHECK (0 == std::strcmp (buffer, messageText));
138+ ++eventsFd;
139+ }
140+ }));
141+ CHECK_NOTHROW (active_poller.add (
142+ socket_rcv, zmq::event_flags::pollin, [&](zmq::event_flags flags) {
143+ if (flags == zmq::event_flags::pollin) {
144+ zmq::message_t msg;
145+ CHECK (socket_rcv.recv (msg, zmq::recv_flags::dontwait).has_value ());
146+ CHECK (messageSize == msg.size ());
147+ CHECK (0 == std::strcmp (messageText, msg.data <const char >()));
148+ ++eventsSocket;
149+ }
150+ }));
156151
157152 // send/rcv socket pair
158153 zmq::message_t msg{messageText, messageSize};
@@ -369,8 +364,7 @@ TEST_CASE("modify invalid socket throws", "[active_poller]")
369364 zmq::socket_t a{context, zmq::socket_type::push};
370365 zmq::socket_t b{std::move (a)};
371366 zmq::active_poller_t active_poller;
372- CHECK_THROWS_AS (active_poller.modify (a, zmq::event_flags::pollin),
373- zmq::error_t );
367+ CHECK_THROWS_AS (active_poller.modify (a, zmq::event_flags::pollin), zmq::error_t );
374368}
375369
376370TEST_CASE (" modify not added throws" , " [active_poller]" )
@@ -380,8 +374,7 @@ TEST_CASE("modify not added throws", "[active_poller]")
380374 zmq::socket_t b{context, zmq::socket_type::push};
381375 zmq::active_poller_t active_poller;
382376 CHECK_NOTHROW (active_poller.add (a, zmq::event_flags::pollin, no_op_handler));
383- CHECK_THROWS_AS (active_poller.modify (b, zmq::event_flags::pollin),
384- zmq::error_t );
377+ CHECK_THROWS_AS (active_poller.modify (b, zmq::event_flags::pollin), zmq::error_t );
385378}
386379
387380TEST_CASE (" modify simple" , " [active_poller]" )
0 commit comments