Problem: monitor_t tests not event driven

Solution: instead of waiting for fixed amount of time for events, react
as soon as events are triggered.

- Total running time of unittest reduced 10x (from ~300ms to 30ms).
- Reduced code duplication by reusing testutil's constructs.
This commit is contained in:
Pawel Kurdybacha
2018-07-04 23:46:47 +01:00
parent 4a066be66a
commit 57454dff4b
2 changed files with 50 additions and 43 deletions

View File

@@ -3,7 +3,7 @@
#include <gtest/gtest.h>
#include <zmq.hpp>
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11)
#if defined(ZMQ_CPP11)
#include <array>
class loopback_ip4_binder
@@ -31,7 +31,11 @@ class loopback_ip4_binder
struct common_server_client_setup
{
common_server_client_setup() { init(); }
common_server_client_setup(bool initialize = true)
{
if (initialize)
init();
}
void init()
{
@@ -40,8 +44,8 @@ struct common_server_client_setup
}
zmq::context_t context;
zmq::socket_t server{context, zmq::socket_type::server};
zmq::socket_t client{context, zmq::socket_type::client};
zmq::socket_t server{context, zmq::socket_type::pair};
zmq::socket_t client{context, zmq::socket_type::pair};
std::string endpoint;
};
#endif