mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-10-15 15:16:52 +02:00
Problem: message_t ctor for ranges too greedy
Solution: Detect ranges with enable_if idiom
This commit is contained in:
@@ -13,6 +13,17 @@ static_assert(std::is_nothrow_swappable<zmq::message_t>::value,
|
||||
"message_t should be nothrow swappable");
|
||||
#endif
|
||||
|
||||
#ifdef ZMQ_CPP11
|
||||
TEST_CASE("range SFINAE", "[message]")
|
||||
{
|
||||
CHECK(!zmq::detail::is_range<int>::value);
|
||||
CHECK(zmq::detail::is_range<std::string>::value);
|
||||
CHECK(zmq::detail::is_range<std::string&>::value);
|
||||
CHECK(zmq::detail::is_range<const std::string&>::value);
|
||||
CHECK(zmq::detail::is_range<decltype("hello")>::value);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE("message default constructed", "[message]")
|
||||
{
|
||||
const zmq::message_t message;
|
||||
@@ -48,6 +59,12 @@ TEST_CASE("message constructor with iterators", "[message]")
|
||||
CHECK(0 == memcmp(data, hi_msg.data(), 2));
|
||||
}
|
||||
|
||||
TEST_CASE("message constructor with size", "[message]")
|
||||
{
|
||||
const zmq::message_t msg(5);
|
||||
CHECK(msg.size() == 5);
|
||||
}
|
||||
|
||||
TEST_CASE("message constructor with buffer and size", "[message]")
|
||||
{
|
||||
const std::string hi(data);
|
||||
|
Reference in New Issue
Block a user