Skip to content

Commit

Permalink
Problem: no tests for move-assignment
Browse files Browse the repository at this point in the history
Solution: added test cases
  • Loading branch information
sigiesec committed Apr 13, 2018
1 parent c92afb6 commit 4d04187
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/message.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <gtest/gtest.h>
#include <zmq.hpp>

#if defined(ZMQ_CPP11)
static_assert(!std::is_copy_constructible<zmq::message_t>::value, "message_t should not be copy-constructible");
static_assert(!std::is_copy_assignable<zmq::message_t>::value, "message_t should not be copy-assignable");
#endif

TEST (message, constructor_default)
{
const zmq::message_t message;
Expand Down Expand Up @@ -46,6 +51,28 @@ TEST (message, constructor_move)
{
zmq::message_t hi_msg (zmq::message_t(data, strlen (data)));
}

TEST (message, assign_move_empty_before)
{
zmq::message_t hi_msg;
hi_msg = zmq::message_t (data, strlen (data));
ASSERT_EQ (2u, hi_msg.size ());
ASSERT_EQ (0, memcmp (data, hi_msg.data (), 2));
}

TEST (message, assign_move_empty_after)
{
zmq::message_t hi_msg (data, strlen (data));
hi_msg = zmq::message_t();
ASSERT_EQ (0u, hi_msg.size ());
}

TEST (message, assign_move_empty_before_and_after)
{
zmq::message_t hi_msg;
hi_msg = zmq::message_t();
ASSERT_EQ (0u, hi_msg.size ());
}
#endif

TEST (message, equality_self) {
Expand Down

0 comments on commit 4d04187

Please sign in to comment.