mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
fix CHECK_THROWS_AS usage
"Note that the exception type is extended with const& and you should not include it yourself." according to https://github.com/catchorg/Catch2/blob/devel/docs/assertions.md#exceptions
This commit is contained in:
parent
b6420aa22f
commit
eddeaf44ca
@ -93,7 +93,7 @@ TEST_CASE("add null handler fails", "[active_poller]")
|
||||
zmq::active_poller_t active_poller;
|
||||
zmq::active_poller_t::handler_type handler;
|
||||
CHECK_THROWS_AS(active_poller.add(socket, zmq::event_flags::pollin, handler),
|
||||
const std::invalid_argument &);
|
||||
std::invalid_argument);
|
||||
}
|
||||
|
||||
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0)
|
||||
@ -107,7 +107,7 @@ TEST_CASE("add handler invalid events type", "[active_poller]")
|
||||
CHECK_THROWS_AS(
|
||||
active_poller.add(socket, static_cast<zmq::event_flags>(invalid_events_type),
|
||||
no_op_handler),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
CHECK(active_poller.empty());
|
||||
CHECK(0u == active_poller.size());
|
||||
}
|
||||
@ -243,7 +243,7 @@ TEST_CASE("add invalid socket throws", "[active_poller]")
|
||||
zmq::socket_t a{context, zmq::socket_type::router};
|
||||
zmq::socket_t b{std::move(a)};
|
||||
CHECK_THROWS_AS(active_poller.add(a, zmq::event_flags::pollin, no_op_handler),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("remove invalid socket throws", "[active_poller]")
|
||||
@ -256,7 +256,7 @@ TEST_CASE("remove invalid socket throws", "[active_poller]")
|
||||
CHECK(1u == active_poller.size());
|
||||
std::vector<zmq::socket_t> sockets;
|
||||
sockets.emplace_back(std::move(socket));
|
||||
CHECK_THROWS_AS(active_poller.remove(socket), const zmq::error_t &);
|
||||
CHECK_THROWS_AS(active_poller.remove(socket), zmq::error_t);
|
||||
CHECK(1u == active_poller.size());
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ TEST_CASE("modify empty throws", "[active_poller]")
|
||||
zmq::socket_t socket{context, zmq::socket_type::push};
|
||||
zmq::active_poller_t active_poller;
|
||||
CHECK_THROWS_AS(active_poller.modify(socket, zmq::event_flags::pollin),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("modify invalid socket throws", "[active_poller]")
|
||||
@ -286,7 +286,7 @@ TEST_CASE("modify invalid socket throws", "[active_poller]")
|
||||
zmq::socket_t b{std::move(a)};
|
||||
zmq::active_poller_t active_poller;
|
||||
CHECK_THROWS_AS(active_poller.modify(a, zmq::event_flags::pollin),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("modify not added throws", "[active_poller]")
|
||||
@ -297,7 +297,7 @@ TEST_CASE("modify not added throws", "[active_poller]")
|
||||
zmq::active_poller_t active_poller;
|
||||
CHECK_NOTHROW(active_poller.add(a, zmq::event_flags::pollin, no_op_handler));
|
||||
CHECK_THROWS_AS(active_poller.modify(b, zmq::event_flags::pollin),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("modify simple", "[active_poller]")
|
||||
|
@ -69,7 +69,7 @@ TEST_CASE("multipart codec decode bad data overflow", "[codec_multipart]")
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
multipart_t::decode(wrong_size),
|
||||
const std::out_of_range&);
|
||||
std::out_of_range);
|
||||
}
|
||||
|
||||
TEST_CASE("multipart codec decode bad data extra data", "[codec_multipart]")
|
||||
@ -83,7 +83,7 @@ TEST_CASE("multipart codec decode bad data extra data", "[codec_multipart]")
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
multipart_t::decode(wrong_size),
|
||||
const std::out_of_range&);
|
||||
std::out_of_range);
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,10 +75,10 @@ TEST_CASE("context set/get options", "[context]")
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
context.set(static_cast<zmq::ctxopt>(-42), 5),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
context.get(static_cast<zmq::ctxopt>(-42)),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
#endif
|
||||
|
@ -109,7 +109,7 @@ TEST_CASE("poller add handler invalid events type", "[poller]")
|
||||
short invalid_events_type = 2 << 10;
|
||||
CHECK_THROWS_AS(
|
||||
poller.add(socket, static_cast<zmq::event_flags>(invalid_events_type)),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -121,7 +121,7 @@ TEST_CASE("poller add handler twice throws", "[poller]")
|
||||
poller.add(socket, zmq::event_flags::pollin);
|
||||
/// \todo the actual error code should be checked
|
||||
CHECK_THROWS_AS(poller.add(socket, zmq::event_flags::pollin),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller wait with no handlers throws", "[poller]")
|
||||
@ -130,7 +130,7 @@ TEST_CASE("poller wait with no handlers throws", "[poller]")
|
||||
std::vector<zmq::poller_event<>> events;
|
||||
/// \todo the actual error code should be checked
|
||||
CHECK_THROWS_AS(poller.wait_all(events, std::chrono::milliseconds{10}),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 3)
|
||||
@ -153,7 +153,7 @@ TEST_CASE("poller remove unregistered throws", "[poller]")
|
||||
zmq::socket_t socket{context, zmq::socket_type::router};
|
||||
zmq::poller_t<> poller;
|
||||
/// \todo the actual error code should be checked
|
||||
CHECK_THROWS_AS(poller.remove(socket), const zmq::error_t&);
|
||||
CHECK_THROWS_AS(poller.remove(socket), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller remove registered empty", "[poller]")
|
||||
@ -198,7 +198,7 @@ TEST_CASE("poller add invalid socket throws", "[poller]")
|
||||
zmq::poller_t<> poller;
|
||||
zmq::socket_t a{context, zmq::socket_type::router};
|
||||
zmq::socket_t b{std::move(a)};
|
||||
CHECK_THROWS_AS(poller.add(a, zmq::event_flags::pollin), const zmq::error_t&);
|
||||
CHECK_THROWS_AS(poller.add(a, zmq::event_flags::pollin), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller remove invalid socket throws", "[poller]")
|
||||
@ -209,7 +209,7 @@ TEST_CASE("poller remove invalid socket throws", "[poller]")
|
||||
CHECK_NOTHROW(poller.add(socket, zmq::event_flags::pollin));
|
||||
std::vector<zmq::socket_t> sockets;
|
||||
sockets.emplace_back(std::move(socket));
|
||||
CHECK_THROWS_AS(poller.remove(socket), const zmq::error_t&);
|
||||
CHECK_THROWS_AS(poller.remove(socket), zmq::error_t);
|
||||
CHECK_NOTHROW(poller.remove(sockets[0]));
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ TEST_CASE("poller modify empty throws", "[poller]")
|
||||
zmq::socket_t socket{context, zmq::socket_type::push};
|
||||
zmq::poller_t<> poller;
|
||||
CHECK_THROWS_AS(poller.modify(socket, zmq::event_flags::pollin),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller modify invalid socket throws", "[poller]")
|
||||
@ -228,7 +228,7 @@ TEST_CASE("poller modify invalid socket throws", "[poller]")
|
||||
zmq::socket_t a{context, zmq::socket_type::push};
|
||||
zmq::socket_t b{std::move(a)};
|
||||
zmq::poller_t<> poller;
|
||||
CHECK_THROWS_AS(poller.modify(a, zmq::event_flags::pollin), const zmq::error_t&);
|
||||
CHECK_THROWS_AS(poller.modify(a, zmq::event_flags::pollin), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller modify not added throws", "[poller]")
|
||||
@ -238,7 +238,7 @@ TEST_CASE("poller modify not added throws", "[poller]")
|
||||
zmq::socket_t b{context, zmq::socket_type::push};
|
||||
zmq::poller_t<> poller;
|
||||
CHECK_NOTHROW(poller.add(a, zmq::event_flags::pollin));
|
||||
CHECK_THROWS_AS(poller.modify(b, zmq::event_flags::pollin), const zmq::error_t&);
|
||||
CHECK_THROWS_AS(poller.modify(b, zmq::event_flags::pollin), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("poller modify simple", "[poller]")
|
||||
@ -304,7 +304,7 @@ TEST_CASE("poller wait on move constructed", "[poller]")
|
||||
std::vector<zmq::poller_event<>> events(1);
|
||||
/// \todo the actual error code should be checked
|
||||
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
CHECK(1 == b.wait_all(events, std::chrono::milliseconds{-1}));
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ TEST_CASE("poller wait on move assigned", "[poller]")
|
||||
/// \todo the TEST_CASE error code should be checked
|
||||
std::vector<zmq::poller_event<>> events(1);
|
||||
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}),
|
||||
const zmq::error_t&);
|
||||
zmq::error_t);
|
||||
CHECK(1 == b.wait_all(events, std::chrono::milliseconds{-1}));
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ TEST_CASE("recv_multipart test", "[recv_multipart]")
|
||||
std::vector<zmq::message_t> msgs;
|
||||
CHECK_THROWS_AS(
|
||||
zmq::recv_multipart(zmq::socket_ref(), std::back_inserter(msgs)),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ TEST_CASE("recv_multipart_n test", "[recv_multipart]")
|
||||
std::array<zmq::message_t, 1> msgs;
|
||||
CHECK_THROWS_AS(
|
||||
zmq::recv_multipart_n(output, msgs.data(), msgs.size()),
|
||||
const std::runtime_error&);
|
||||
std::runtime_error);
|
||||
}
|
||||
SECTION("recv 0") {
|
||||
input.send(zmq::str_buffer("hello"), zmq::send_flags::sndmore);
|
||||
@ -99,7 +99,7 @@ TEST_CASE("recv_multipart_n test", "[recv_multipart]")
|
||||
std::array<zmq::message_t, 1> msgs;
|
||||
CHECK_THROWS_AS(
|
||||
zmq::recv_multipart_n(output, msgs.data(), 0),
|
||||
const std::runtime_error&);
|
||||
std::runtime_error);
|
||||
}
|
||||
SECTION("send 2 messages") {
|
||||
input.send(zmq::str_buffer("hello"), zmq::send_flags::sndmore);
|
||||
@ -132,7 +132,7 @@ TEST_CASE("recv_multipart_n test", "[recv_multipart]")
|
||||
std::array<zmq::message_t, 1> msgs;
|
||||
CHECK_THROWS_AS(
|
||||
zmq::recv_multipart_n(zmq::socket_ref(), msgs.data(), msgs.size()),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ TEST_CASE("send_multipart test", "[send_multipart]")
|
||||
SECTION("send with invalid socket") {
|
||||
std::vector<zmq::message_t> msgs(1);
|
||||
CHECK_THROWS_AS(zmq::send_multipart(zmq::socket_ref(), msgs),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -58,7 +58,7 @@ TEST_CASE("socket options", "[socket]")
|
||||
socket.set(zmq::sockopt::immediate, false);
|
||||
CHECK(socket.get(zmq::sockopt::immediate) == false);
|
||||
// unit out of range
|
||||
CHECK_THROWS_AS(socket.set(zmq::sockopt::immediate, 80), const zmq::error_t &);
|
||||
CHECK_THROWS_AS(socket.set(zmq::sockopt::immediate, 80), zmq::error_t);
|
||||
#endif
|
||||
#ifdef ZMQ_LINGER
|
||||
socket.set(zmq::sockopt::linger, 55);
|
||||
@ -83,7 +83,7 @@ TEST_CASE("socket options", "[socket]")
|
||||
std::string id_ret_small(3, ' ');
|
||||
// truncated
|
||||
CHECK_THROWS_AS(socket.get(zmq::sockopt::routing_id, zmq::buffer(id_ret_small)),
|
||||
const zmq::error_t &);
|
||||
zmq::error_t);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -543,7 +543,7 @@ TEST_CASE("socket send exception", "[socket]")
|
||||
s.bind("inproc://test");
|
||||
|
||||
std::vector<char> buf(4);
|
||||
CHECK_THROWS_AS(s.send(zmq::buffer(buf)), const zmq::error_t &);
|
||||
CHECK_THROWS_AS(s.send(zmq::buffer(buf)), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("socket recv none", "[socket]")
|
||||
@ -631,7 +631,7 @@ TEST_CASE("socket recv dontwait", "[socket]")
|
||||
zmq::message_t msg;
|
||||
auto resm = s.recv(msg, flags);
|
||||
CHECK(!resm);
|
||||
CHECK_THROWS_AS(resm.value(), const std::exception &);
|
||||
CHECK_THROWS_AS(resm.value(), std::exception);
|
||||
CHECK(msg.size() == 0);
|
||||
}
|
||||
|
||||
@ -642,7 +642,7 @@ TEST_CASE("socket recv exception", "[socket]")
|
||||
s.bind("inproc://test");
|
||||
|
||||
std::vector<char> buf(4);
|
||||
CHECK_THROWS_AS(s.recv(zmq::buffer(buf)), const zmq::error_t &);
|
||||
CHECK_THROWS_AS(s.recv(zmq::buffer(buf)), zmq::error_t);
|
||||
}
|
||||
|
||||
TEST_CASE("socket proxy", "[socket]")
|
||||
|
Loading…
Reference in New Issue
Block a user