Problem: message_t should be easier to construct

* Added overload constructor (c++11 only) taking iteratable object.
  It would be easier to use std::string, std::array etc to construct
  a message now. Making it a draft for now in case it is too greedy
  and needs to be more specialize.
* Added equal and not euqal operator to message_t as a recommended
  and expected way of comparing objects in C++.
* deprecated C style equal method as operator== should be used instead
  (point above).
* Added message_t test covering all available message_t's constructors
This commit is contained in:
Pawel Kurdybacha
2018-04-14 12:03:44 +01:00
parent 3185dd1051
commit 6caa5d19d3
4 changed files with 56 additions and 7 deletions

View File

@@ -167,10 +167,7 @@ TEST(poller, poll_basic)
zmq::socket_t sink{context, zmq::socket_type::pull};
ASSERT_NO_THROW(sink.connect(endpoint));
const std::string message = "H";
// TODO: send overload for string would be handy.
ASSERT_NO_THROW(vent.send(std::begin(message), std::end(message)));
ASSERT_NO_THROW(vent.send("Hi"));
zmq::poller_t poller;
bool message_received = false;
@@ -217,7 +214,7 @@ TEST(poller, client_server)
// Setup client and send message
zmq::socket_t client{context, zmq::socket_type::dealer};
ASSERT_NO_THROW(client.connect(endpoint));
ASSERT_NO_THROW(client.send(std::begin(send_msg), std::end(send_msg)));
ASSERT_NO_THROW(client.send(send_msg));
ASSERT_NO_THROW(poller.wait(std::chrono::milliseconds{-1}));
ASSERT_TRUE(got_pollin);