Skip to content

Commit 67035c9

Browse files
authored
Silence deprecation warnings in the unit tests (#672)
* Silence deprecation warnings in the unit tests * Add Windows check before diagnostic ignored #pragma
1 parent fbbff88 commit 67035c9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/message.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ TEST_CASE("message constructor with char array", "[message]")
6969
CHECK(0 == memcmp(data, hi_msg.data(), 2));
7070
}
7171

72+
#ifndef _WIN32
73+
#pragma GCC diagnostic push
74+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
75+
#endif
7276
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
7377
TEST_CASE("message constructor with container - deprecated", "[message]")
7478
{
7579
zmq::message_t hi_msg("Hi"); // deprecated
7680
REQUIRE(3u == hi_msg.size());
7781
CHECK(0 == memcmp(data, hi_msg.data(), 3));
7882
}
83+
#ifndef _WIN32
84+
#pragma GCC diagnostic pop
85+
#endif
7986

8087
TEST_CASE("message constructor with container of trivial data", "[message]")
8188
{
@@ -189,11 +196,18 @@ TEST_CASE("message to string", "[message]")
189196
CHECK(b.to_string_view() == "Foo");
190197
#endif
191198

199+
#ifndef _WIN32
200+
#pragma GCC diagnostic push
201+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
202+
#endif
192203
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
193204
const zmq::message_t depr("Foo"); // deprecated
194205
CHECK(depr.to_string() != "Foo");
195206
CHECK(depr.to_string() == std::string("Foo", 4));
196207
#endif
208+
#ifndef _WIN32
209+
#pragma GCC diagnostic pop
210+
#endif
197211
}
198212

199213
TEST_CASE("message to debug string", "[message]")

tests/socket.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ TEST_CASE("socket check integral options", "[socket]")
365365
"router_mandatory", true);
366366
#endif
367367
#ifdef ZMQ_ROUTER_RAW
368-
check_integral_opt<int>(zmq::sockopt::router_raw, router, "router_raw",
368+
check_integral_opt<int>(zmq::sockopt::router_raw, router, "router_raw",
369369
true);
370370
#endif
371371
#ifdef ZMQ_ROUTER_NOTIFY
@@ -619,9 +619,16 @@ TEST_CASE("socket send recv message_t by pointer", "[socket]")
619619
CHECK(*res_send == 10);
620620
CHECK(smsg.size() == 0);
621621

622+
#ifndef _WIN32
623+
#pragma GCC diagnostic push
624+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
625+
#endif
622626
zmq::message_t rmsg;
623627
const bool res = s.recv(&rmsg);
624628
CHECK(res);
629+
#ifndef _WIN32
630+
#pragma GCC diagnostic pop
631+
#endif
625632
}
626633

627634
TEST_CASE("socket recv dontwait", "[socket]")

0 commit comments

Comments
 (0)