2018-09-23 17:14:25 +01:00
|
|
|
#include <catch.hpp>
|
2018-04-03 12:02:08 +02:00
|
|
|
#include <zmq.hpp>
|
|
|
|
|
2018-09-23 17:14:25 +01:00
|
|
|
TEST_CASE("socket create destroy", "[socket]")
|
2018-04-03 12:02:08 +02:00
|
|
|
{
|
|
|
|
zmq::context_t context;
|
2018-05-12 17:28:28 +01:00
|
|
|
zmq::socket_t socket(context, ZMQ_ROUTER);
|
2018-04-03 12:02:08 +02:00
|
|
|
}
|
|
|
|
|
2018-04-03 12:04:23 +02:00
|
|
|
#ifdef ZMQ_CPP11
|
2018-09-23 17:14:25 +01:00
|
|
|
TEST_CASE("socket create by enum and destroy", "[socket]")
|
2018-04-03 12:04:23 +02:00
|
|
|
{
|
|
|
|
zmq::context_t context;
|
2018-05-12 17:28:28 +01:00
|
|
|
zmq::socket_t socket(context, zmq::socket_type::router);
|
2018-04-03 12:04:23 +02:00
|
|
|
}
|
|
|
|
#endif
|
2018-08-21 13:36:01 +02:00
|
|
|
|
2018-09-23 17:14:25 +01:00
|
|
|
TEST_CASE("socket sends and receives const buffer", "[socket]")
|
2018-08-21 13:36:01 +02:00
|
|
|
{
|
|
|
|
zmq::context_t context;
|
|
|
|
zmq::socket_t sender(context, ZMQ_PAIR);
|
|
|
|
zmq::socket_t receiver(context, ZMQ_PAIR);
|
|
|
|
receiver.bind("inproc://test");
|
|
|
|
sender.connect("inproc://test");
|
2018-09-23 17:14:25 +01:00
|
|
|
CHECK(2 == sender.send("Hi", 2));
|
2018-08-21 13:36:01 +02:00
|
|
|
char buf[2];
|
2018-09-23 17:14:25 +01:00
|
|
|
CHECK(2 == receiver.recv(buf, 2));
|
|
|
|
CHECK(0 == memcmp(buf, "Hi", 2));
|
2018-08-21 13:36:01 +02:00
|
|
|
}
|