From 4043617afe6907f1a92ab4db65d94f42d044143f Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Mon, 4 Feb 2019 14:53:03 +0100 Subject: [PATCH] Problem: test cases for error behaviour of (active_)poller_t failing with libzmq 4.3.x Solution: adapt test cases to changed behaviour --- tests/active_poller.cpp | 12 ++++++------ tests/poller.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/active_poller.cpp b/tests/active_poller.cpp index 2e921bb..96a76a1 100644 --- a/tests/active_poller.cpp +++ b/tests/active_poller.cpp @@ -83,20 +83,20 @@ TEST_CASE("add handler", "[active_poller]") CHECK_NOTHROW(active_poller.add(socket, ZMQ_POLLIN, handler)); } +#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) +// this behaviour was added by https://github.com/zeromq/libzmq/pull/3100 TEST_CASE("add handler invalid events type", "[active_poller]") { - /// \todo is it good that this is accepted? should probably already be - /// checked by zmq_poller_add/modify in libzmq: - /// https://github.com/zeromq/libzmq/issues/3088 zmq::context_t context; zmq::socket_t socket{context, zmq::socket_type::router}; zmq::active_poller_t active_poller; zmq::active_poller_t::handler_t handler; short invalid_events_type = 2 << 10; - CHECK_NOTHROW(active_poller.add(socket, invalid_events_type, handler)); - CHECK_FALSE(active_poller.empty()); - CHECK(1u == active_poller.size()); + CHECK_THROWS_AS(active_poller.add(socket, invalid_events_type, handler), zmq::error_t); + CHECK(active_poller.empty()); + CHECK(0u == active_poller.size()); } +#endif TEST_CASE("add handler twice throws", "[active_poller]") { diff --git a/tests/poller.cpp b/tests/poller.cpp index a42fd66..47689b3 100644 --- a/tests/poller.cpp +++ b/tests/poller.cpp @@ -66,17 +66,17 @@ TEST_CASE("poller add non nullptr", "[poller]") CHECK_NOTHROW(poller.add(socket, ZMQ_POLLIN, &i)); } +#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) +// this behaviour was added by https://github.com/zeromq/libzmq/pull/3100 TEST_CASE("poller add handler invalid events type", "[poller]") { - /// \todo is it good that this is accepted? should probably already be - /// checked by zmq_poller_add/modify in libzmq: - /// https://github.com/zeromq/libzmq/issues/3088 zmq::context_t context; zmq::socket_t socket{context, zmq::socket_type::router}; zmq::poller_t<> poller; short invalid_events_type = 2 << 10; - CHECK_NOTHROW(poller.add(socket, invalid_events_type, nullptr)); + CHECK_THROWS_AS(poller.add(socket, invalid_events_type, nullptr), zmq::error_t); } +#endif TEST_CASE("poller add handler twice throws", "[poller]") {