mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
Move string literal into variable
This commit is contained in:
parent
6143343edf
commit
76e6bacc80
@ -165,13 +165,16 @@ struct server_client_setup : common_server_client_setup
|
||||
|
||||
zmq::event_flags events = zmq::event_flags::none;
|
||||
};
|
||||
|
||||
const std::string hi_str = "Hi";
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("poll basic", "[active_poller]")
|
||||
{
|
||||
server_client_setup s;
|
||||
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
zmq::active_poller_t active_poller;
|
||||
bool message_received = false;
|
||||
@ -189,7 +192,7 @@ TEST_CASE("poll basic", "[active_poller]")
|
||||
/// \todo this contains multiple test cases that should be split up
|
||||
TEST_CASE("client server", "[active_poller]")
|
||||
{
|
||||
const std::string send_msg = "Hi";
|
||||
const std::string send_msg = hi_str;
|
||||
|
||||
// Setup server and client
|
||||
server_client_setup s;
|
||||
@ -258,7 +261,7 @@ TEST_CASE("remove invalid socket throws", "[active_poller]")
|
||||
TEST_CASE("wait on added empty handler", "[active_poller]")
|
||||
{
|
||||
server_client_setup s;
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
zmq::active_poller_t active_poller;
|
||||
zmq::active_poller_t::handler_type handler;
|
||||
CHECK_NOTHROW(active_poller.add(s.server, zmq::event_flags::pollin, handler));
|
||||
@ -320,7 +323,7 @@ TEST_CASE("poll client server", "[active_poller]")
|
||||
CHECK_NOTHROW(active_poller.add(s.server, zmq::event_flags::pollin, s.handler));
|
||||
|
||||
// client sends message
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
// wait for message and verify events
|
||||
CHECK_NOTHROW(active_poller.wait(std::chrono::milliseconds{500}));
|
||||
@ -348,7 +351,7 @@ TEST_CASE("wait one return", "[active_poller]")
|
||||
event_flags) { ++count; }));
|
||||
|
||||
// client sends message
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
// wait for message and verify events
|
||||
CHECK(1 == active_poller.wait(std::chrono::milliseconds{500}));
|
||||
@ -358,7 +361,7 @@ TEST_CASE("wait one return", "[active_poller]")
|
||||
TEST_CASE("wait on move constructed active_poller", "[active_poller]")
|
||||
{
|
||||
server_client_setup s;
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
zmq::active_poller_t a;
|
||||
zmq::active_poller_t::handler_type handler;
|
||||
CHECK_NOTHROW(a.add(s.server, zmq::event_flags::pollin, handler));
|
||||
@ -372,7 +375,7 @@ TEST_CASE("wait on move constructed active_poller", "[active_poller]")
|
||||
TEST_CASE("wait on move assigned active_poller", "[active_poller]")
|
||||
{
|
||||
server_client_setup s;
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
zmq::active_poller_t a;
|
||||
zmq::active_poller_t::handler_type handler;
|
||||
CHECK_NOTHROW(a.add(s.server, zmq::event_flags::pollin, handler));
|
||||
@ -395,14 +398,14 @@ TEST_CASE("received on move constructed active_poller", "[active_poller]")
|
||||
a.add(s.server, zmq::event_flags::pollin, [&count](zmq::event_flags) { ++
|
||||
count; }));
|
||||
// client sends message
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
// wait for message and verify it is received
|
||||
CHECK(1 == a.wait(std::chrono::milliseconds{500}));
|
||||
CHECK(1u == count);
|
||||
// Move construct active_poller b
|
||||
zmq::active_poller_t b{std::move(a)};
|
||||
// client sends message again
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
// wait for message and verify it is received
|
||||
CHECK(1 == b.wait(std::chrono::milliseconds{500}));
|
||||
CHECK(2u == count);
|
||||
@ -434,7 +437,7 @@ TEST_CASE("remove from handler", "[active_poller]")
|
||||
CHECK(ITER_NO == active_poller.size());
|
||||
// Clients send messages
|
||||
for (auto &s : setup_list) {
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
}
|
||||
|
||||
// Wait for all servers to receive a message
|
||||
|
@ -161,11 +161,13 @@ TEST_CASE("poller remove registered non empty", "[poller]")
|
||||
CHECK_NOTHROW(poller.remove(socket));
|
||||
}
|
||||
|
||||
const std::string hi_str = "Hi";
|
||||
|
||||
TEST_CASE("poller poll basic", "[poller]")
|
||||
{
|
||||
common_server_client_setup s;
|
||||
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
zmq::poller_t<int> poller;
|
||||
std::vector<zmq::poller_event<int>> events{1};
|
||||
@ -245,7 +247,7 @@ TEST_CASE("poller poll client server", "[poller]")
|
||||
CHECK_NOTHROW(poller.add(s.server, zmq::event_flags::pollin, &s.server));
|
||||
|
||||
// client sends message
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
// wait for message and verify events
|
||||
std::vector<zmq::poller_event<zmq::socket_t>> events(1);
|
||||
@ -271,7 +273,7 @@ TEST_CASE("poller wait one return", "[poller]")
|
||||
CHECK_NOTHROW(poller.add(s.server, zmq::event_flags::pollin));
|
||||
|
||||
// client sends message
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
|
||||
// wait for message and verify events
|
||||
std::vector<zmq::poller_event<>> events(1);
|
||||
@ -281,7 +283,7 @@ TEST_CASE("poller wait one return", "[poller]")
|
||||
TEST_CASE("poller wait on move constructed", "[poller]")
|
||||
{
|
||||
common_server_client_setup s;
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
zmq::poller_t<> a;
|
||||
CHECK_NOTHROW(a.add(s.server, zmq::event_flags::pollin));
|
||||
zmq::poller_t<> b{std::move(a)};
|
||||
@ -295,7 +297,7 @@ TEST_CASE("poller wait on move constructed", "[poller]")
|
||||
TEST_CASE("poller wait on move assigned", "[poller]")
|
||||
{
|
||||
common_server_client_setup s;
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
zmq::poller_t<> a;
|
||||
CHECK_NOTHROW(a.add(s.server, zmq::event_flags::pollin));
|
||||
zmq::poller_t<> b;
|
||||
@ -323,7 +325,7 @@ TEST_CASE("poller remove from handler", "[poller]")
|
||||
}
|
||||
// Clients send messages
|
||||
for (auto &s : setup_list) {
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{"Hi"}, zmq::send_flags::none));
|
||||
CHECK_NOTHROW(s.client.send(zmq::message_t{hi_str}, zmq::send_flags::none));
|
||||
}
|
||||
|
||||
// Wait for all servers to receive a message
|
||||
|
Loading…
Reference in New Issue
Block a user