From a91522f65e137aae4d2a219fad120f3aa7dbbc07 Mon Sep 17 00:00:00 2001 From: trya Date: Thu, 14 Mar 2019 14:25:50 +0100 Subject: [PATCH] Unit tests for message_t::get() Testing ZMQ_SHARED property only, since other properties (ZMQ_MORE and ZMQ_SRCFD) depend on socket operations. --- tests/message.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/message.cpp b/tests/message.cpp index 6761ea3..693e607 100644 --- a/tests/message.cpp +++ b/tests/message.cpp @@ -137,3 +137,20 @@ TEST_CASE("message group persists", "[message]") CHECK(std::string(msg.group()) == "mygroup"); } #endif + +#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3, 2, 0) +TEST_CASE("message is not shared", "[message]") +{ + zmq::message_t msg; + CHECK(msg.get(ZMQ_SHARED) == 0); +} + +TEST_CASE("message is shared", "[message]") +{ + size_t msg_sz = 1024; // large enough to be a type_lmsg + zmq::message_t msg1(msg_sz); + zmq::message_t msg2; + msg2.copy(&msg1); + CHECK(msg2.get(ZMQ_SHARED) == 1); +} +#endif