Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ TEST_CASE("message constructor with iterators", "[message]")
CHECK(0 == memcmp(data, hi_msg.data(), 2));
}

TEST_CASE("message constructor with ranges", "[message]")
{
SECTION("trivial type")
{
const std::vector<int> v{1,2,3};
const zmq::message_t msg(v);
CHECK(3u * sizeof(int) == hi_msg.size());
}
SECTION("char type")
{
const std::vector<char> hi{'H', 'i'};
const zmq::message_t hi_msg(hi);
CHECK(2u == hi_msg.size());
CHECK(0 == memcmp(data, hi_msg.data(), 2));
}
}

TEST_CASE("message constructor with size", "[message]")
{
const zmq::message_t msg(5);
Expand Down
3 changes: 2 additions & 1 deletion zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,9 @@ class message_t
typename = typename std::enable_if<
detail::is_range<Range>::value
&& ZMQ_IS_TRIVIALLY_COPYABLE(detail::range_value_t<Range>)
&& !detail::is_char_type<detail::range_value_t<Range>>::value
&& !std::is_same<Range, message_t>::value>::type>
&& !std::is_same<Range, std::string>::value>::type>
&& !std::is_same<Range, std::string_view>::value>::type>
explicit message_t(const Range &rng) :
message_t(detail::ranges::begin(rng), detail::ranges::end(rng))
{
Expand Down
Loading