Skip to content

Commit

Permalink
Merge pull request zeromq#315 from gummif/gfa/test-warnings
Browse files Browse the repository at this point in the history
Problem: Compiler warnings in tests
  • Loading branch information
sigiesec authored Apr 15, 2019
2 parents f65ddd7 + c2e595b commit b0ac8ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
28 changes: 14 additions & 14 deletions tests/active_poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST_CASE("add handler invalid events type", "[active_poller]")
zmq::active_poller_t active_poller;
zmq::active_poller_t::handler_t handler;
short invalid_events_type = 2 << 10;
CHECK_THROWS_AS(active_poller.add(socket, invalid_events_type, handler), zmq::error_t);
CHECK_THROWS_AS(active_poller.add(socket, invalid_events_type, handler), const zmq::error_t&);
CHECK(active_poller.empty());
CHECK(0u == active_poller.size());
}
Expand All @@ -106,14 +106,14 @@ TEST_CASE("add handler twice throws", "[active_poller]")
zmq::active_poller_t::handler_t handler;
active_poller.add(socket, ZMQ_POLLIN, handler);
/// \todo the actual error code should be checked
CHECK_THROWS_AS(active_poller.add(socket, ZMQ_POLLIN, handler), zmq::error_t);
CHECK_THROWS_AS(active_poller.add(socket, ZMQ_POLLIN, handler), const zmq::error_t&);
}

TEST_CASE("wait with no handlers throws", "[active_poller]")
{
zmq::active_poller_t active_poller;
/// \todo the actual error code should be checked
CHECK_THROWS_AS(active_poller.wait(std::chrono::milliseconds{10}), zmq::error_t);
CHECK_THROWS_AS(active_poller.wait(std::chrono::milliseconds{10}), const zmq::error_t&);
}

TEST_CASE("remove unregistered throws", "[active_poller]")
Expand All @@ -122,7 +122,7 @@ TEST_CASE("remove unregistered throws", "[active_poller]")
zmq::socket_t socket{context, zmq::socket_type::router};
zmq::active_poller_t active_poller;
/// \todo the actual error code should be checked
CHECK_THROWS_AS(active_poller.remove(socket), zmq::error_t);
CHECK_THROWS_AS(active_poller.remove(socket), const zmq::error_t&);
}

TEST_CASE("remove registered empty", "[active_poller]")
Expand Down Expand Up @@ -216,7 +216,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_POLLIN, zmq::active_poller_t::handler_t{}),
zmq::error_t);
const zmq::error_t&);
}

TEST_CASE("remove invalid socket throws", "[active_poller]")
Expand All @@ -229,7 +229,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), zmq::error_t);
CHECK_THROWS_AS(active_poller.remove(socket), const zmq::error_t&);
CHECK(1u == active_poller.size());
}

Expand All @@ -248,7 +248,7 @@ TEST_CASE("modify empty throws", "[active_poller]")
zmq::context_t context;
zmq::socket_t socket{context, zmq::socket_type::push};
zmq::active_poller_t active_poller;
CHECK_THROWS_AS(active_poller.modify(socket, ZMQ_POLLIN), zmq::error_t);
CHECK_THROWS_AS(active_poller.modify(socket, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("modify invalid socket throws", "[active_poller]")
Expand All @@ -257,7 +257,7 @@ TEST_CASE("modify invalid socket throws", "[active_poller]")
zmq::socket_t a{context, zmq::socket_type::push};
zmq::socket_t b{std::move(a)};
zmq::active_poller_t active_poller;
CHECK_THROWS_AS(active_poller.modify(a, ZMQ_POLLIN), zmq::error_t);
CHECK_THROWS_AS(active_poller.modify(a, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("modify not added throws", "[active_poller]")
Expand All @@ -268,7 +268,7 @@ TEST_CASE("modify not added throws", "[active_poller]")
zmq::active_poller_t active_poller;
CHECK_NOTHROW(
active_poller.add(a, ZMQ_POLLIN, zmq::active_poller_t::handler_t{}));
CHECK_THROWS_AS(active_poller.modify(b, ZMQ_POLLIN), zmq::error_t);
CHECK_THROWS_AS(active_poller.modify(b, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("modify simple", "[active_poller]")
Expand Down Expand Up @@ -333,7 +333,7 @@ TEST_CASE("wait on move constructed active_poller", "[active_poller]")
zmq::active_poller_t b{std::move(a)};
CHECK(1u == b.size());
/// \todo the actual error code should be checked
CHECK_THROWS_AS(a.wait(std::chrono::milliseconds{10}), zmq::error_t);
CHECK_THROWS_AS(a.wait(std::chrono::milliseconds{10}), const zmq::error_t&);
CHECK(b.wait(std::chrono::milliseconds{-1}));
}

Expand All @@ -348,7 +348,7 @@ TEST_CASE("wait on move assigned active_poller", "[active_poller]")
b = {std::move(a)};
CHECK(1u == b.size());
/// \todo the actual error code should be checked
CHECK_THROWS_AS(a.wait(std::chrono::milliseconds{10}), zmq::error_t);
CHECK_THROWS_AS(a.wait(std::chrono::milliseconds{10}), const zmq::error_t&);
CHECK(b.wait(std::chrono::milliseconds{-1}));
}

Expand Down Expand Up @@ -377,17 +377,17 @@ TEST_CASE("received on move constructed active_poller", "[active_poller]")

TEST_CASE("remove from handler", "[active_poller]")
{
constexpr auto ITER_NO = 10;
constexpr size_t ITER_NO = 10;

// Setup servers and clients
std::vector<server_client_setup> setup_list;
for (auto i = 0; i < ITER_NO; ++i)
for (size_t i = 0; i < ITER_NO; ++i)
setup_list.emplace_back(server_client_setup{});

// Setup active_poller
zmq::active_poller_t active_poller;
int count = 0;
for (auto i = 0; i < ITER_NO; ++i) {
for (size_t i = 0; i < ITER_NO; ++i) {
CHECK_NOTHROW(
active_poller.add(setup_list[i].server, ZMQ_POLLIN, [&, i](short events) {
CHECK(events == ZMQ_POLLIN);
Expand Down
6 changes: 1 addition & 5 deletions tests/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ TEST_CASE("monitor init event count", "[monitor]")
mock_monitor_t monitor;

const int expected_event_count = 2;
int event_count = 0;
auto count_event = [&event_count](const zmq_event_t &, const char *) {
++event_count;
};

monitor.init(s.client, "inproc://foo");

CHECK_FALSE(monitor.check_event(0));
Expand All @@ -99,6 +94,7 @@ TEST_CASE("monitor init event count", "[monitor]")
}
CHECK(monitor.connect_delayed == 1);
CHECK(monitor.connected == 1);
CHECK(monitor.total == expected_event_count);
}

TEST_CASE("monitor init abort", "[monitor]")
Expand Down
28 changes: 14 additions & 14 deletions tests/poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TEST_CASE("poller add handler invalid events type", "[poller]")
zmq::socket_t socket{context, zmq::socket_type::router};
zmq::poller_t<> poller;
short invalid_events_type = 2 << 10;
CHECK_THROWS_AS(poller.add(socket, invalid_events_type, nullptr), zmq::error_t);
CHECK_THROWS_AS(poller.add(socket, invalid_events_type, nullptr), const zmq::error_t&);
}
#endif

Expand All @@ -98,7 +98,7 @@ TEST_CASE("poller add handler twice throws", "[poller]")
zmq::poller_t<> poller;
poller.add(socket, ZMQ_POLLIN, nullptr);
/// \todo the actual error code should be checked
CHECK_THROWS_AS(poller.add(socket, ZMQ_POLLIN, nullptr), zmq::error_t);
CHECK_THROWS_AS(poller.add(socket, ZMQ_POLLIN, nullptr), const zmq::error_t&);
}

TEST_CASE("poller wait with no handlers throws", "[poller]")
Expand All @@ -107,7 +107,7 @@ TEST_CASE("poller wait with no handlers throws", "[poller]")
std::vector<zmq_poller_event_t> events;
/// \todo the actual error code should be checked
CHECK_THROWS_AS(poller.wait_all(events, std::chrono::milliseconds{10}),
zmq::error_t);
const zmq::error_t&);
}

TEST_CASE("poller remove unregistered throws", "[poller]")
Expand All @@ -116,7 +116,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), zmq::error_t);
CHECK_THROWS_AS(poller.remove(socket), const zmq::error_t&);
}

TEST_CASE("poller remove registered empty", "[poller]")
Expand Down Expand Up @@ -159,7 +159,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_POLLIN, nullptr), zmq::error_t);
CHECK_THROWS_AS(poller.add(a, ZMQ_POLLIN, nullptr), const zmq::error_t&);
}

TEST_CASE("poller remove invalid socket throws", "[poller]")
Expand All @@ -170,7 +170,7 @@ TEST_CASE("poller remove invalid socket throws", "[poller]")
CHECK_NOTHROW(poller.add(socket, ZMQ_POLLIN, nullptr));
std::vector<zmq::socket_t> sockets;
sockets.emplace_back(std::move(socket));
CHECK_THROWS_AS(poller.remove(socket), zmq::error_t);
CHECK_THROWS_AS(poller.remove(socket), const zmq::error_t&);
CHECK_NOTHROW(poller.remove(sockets[0]));
}

Expand All @@ -179,7 +179,7 @@ TEST_CASE("poller modify empty throws", "[poller]")
zmq::context_t context;
zmq::socket_t socket{context, zmq::socket_type::push};
zmq::poller_t<> poller;
CHECK_THROWS_AS(poller.modify(socket, ZMQ_POLLIN), zmq::error_t);
CHECK_THROWS_AS(poller.modify(socket, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("poller modify invalid socket throws", "[poller]")
Expand All @@ -188,7 +188,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_POLLIN), zmq::error_t);
CHECK_THROWS_AS(poller.modify(a, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("poller modify not added throws", "[poller]")
Expand All @@ -198,7 +198,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_POLLIN, nullptr));
CHECK_THROWS_AS(poller.modify(b, ZMQ_POLLIN), zmq::error_t);
CHECK_THROWS_AS(poller.modify(b, ZMQ_POLLIN), const zmq::error_t&);
}

TEST_CASE("poller modify simple", "[poller]")
Expand Down Expand Up @@ -259,7 +259,7 @@ TEST_CASE("poller wait on move constructed", "[poller]")
zmq::poller_t<> b{std::move(a)};
std::vector<zmq_poller_event_t> events(1);
/// \todo the actual error code should be checked
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}), zmq::error_t);
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}), const zmq::error_t&);
CHECK(1 == b.wait_all(events, std::chrono::milliseconds{-1}));
}

Expand All @@ -273,22 +273,22 @@ TEST_CASE("poller wait on move assigned", "[poller]")
b = {std::move(a)};
/// \todo the TEST_CASE error code should be checked
std::vector<zmq_poller_event_t> events(1);
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}), zmq::error_t);
CHECK_THROWS_AS(a.wait_all(events, std::chrono::milliseconds{10}), const zmq::error_t&);
CHECK(1 == b.wait_all(events, std::chrono::milliseconds{-1}));
}

TEST_CASE("poller remove from handler", "[poller]")
{
constexpr auto ITER_NO = 10;
constexpr size_t ITER_NO = 10;

// Setup servers and clients
std::vector<common_server_client_setup> setup_list;
for (auto i = 0; i < ITER_NO; ++i)
for (size_t i = 0; i < ITER_NO; ++i)
setup_list.emplace_back(common_server_client_setup{});

// Setup poller
zmq::poller_t<> poller;
for (auto i = 0; i < ITER_NO; ++i) {
for (size_t i = 0; i < ITER_NO; ++i) {
CHECK_NOTHROW(poller.add(setup_list[i].server, ZMQ_POLLIN, nullptr));
}
// Clients send messages
Expand Down

0 comments on commit b0ac8ac

Please sign in to comment.