summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-06-20 11:16:10 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-06-20 11:16:10 +0200
commitada5d424721c0c0139b8011a5e9de348d061ba2f (patch)
tree4c2713ed64f5d85fcd8b6ba5a2b7a724d07a847b /tests
parentc80908c469b1fbd3d1b639ea39d86e4e4311ae57 (diff)
Basic tests now test multi-part messages instead of single-part
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/testutil.hpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/testutil.hpp b/tests/testutil.hpp
index 1fbf1f3..57db3c4 100644
--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -31,13 +31,27 @@ inline void bounce (void *sb, void *sc)
const char *content = "12345678ABCDEFGH12345678abcdefgh";
// Send the message.
- int rc = zmq_send (sc, content, 32, 0);
+ int rc = zmq_send (sc, content, 32, ZMQ_SNDMORE);
+ assert (rc == 32);
+ rc = zmq_send (sc, content, 32, 0);
assert (rc == 32);
// Bounce the message back.
char buf1 [32];
rc = zmq_recv (sb, buf1, 32, 0);
assert (rc == 32);
+ int rcvmore;
+ size_t sz = sizeof (rcvmore);
+ rc = zmq_getsockopt (sb, ZMQ_RCVMORE, &rcvmore, &sz);
+ assert (rc == 0);
+ assert (rcvmore);
+ rc = zmq_recv (sb, buf1, 32, 0);
+ assert (rc == 32);
+ rc = zmq_getsockopt (sb, ZMQ_RCVMORE, &rcvmore, &sz);
+ assert (rc == 0);
+ assert (!rcvmore);
+ rc = zmq_send (sb, buf1, 32, ZMQ_SNDMORE);
+ assert (rc == 32);
rc = zmq_send (sb, buf1, 32, 0);
assert (rc == 32);
@@ -45,6 +59,14 @@ inline void bounce (void *sb, void *sc)
char buf2 [32];
rc = zmq_recv (sc, buf2, 32, 0);
assert (rc == 32);
+ rc = zmq_getsockopt (sc, ZMQ_RCVMORE, &rcvmore, &sz);
+ assert (rc == 0);
+ assert (rcvmore);
+ rc = zmq_recv (sc, buf2, 32, 0);
+ assert (rc == 32);
+ rc = zmq_getsockopt (sc, ZMQ_RCVMORE, &rcvmore, &sz);
+ assert (rc == 0);
+ assert (!rcvmore);
// Check whether the message is still the same.
assert (memcmp (buf2, content, 32) == 0);