aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/pubsub.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/pubsub.c b/tests/pubsub.c
index d61867ce..68b7e3a4 100644
--- a/tests/pubsub.c
+++ b/tests/pubsub.c
@@ -136,16 +136,35 @@ TestMain("PUB/SUB pattern", {
nng_msg_free(msg);
});
- Convey("Subs without subsciptions don't receive", {
+ Convey("Subs using NNG_FLAG_NONBLOCK and no sub", {
nng_msg *msg;
- So(nng_setopt_ms(sub, NNG_OPT_RECVTIMEO, 90) == 0);
So(nng_msg_alloc(&msg, 0) == 0);
APPENDSTR(msg, "/some/don't/like/it");
So(nng_sendmsg(pub, msg, 0) == 0);
- So(nng_recvmsg(sub, &msg, 0) == NNG_ETIMEDOUT);
+ So(nng_recvmsg(sub, &msg, NNG_FLAG_NONBLOCK) == NNG_EAGAIN);
});
- });
+ Convey("Subs using NNG_FLAG_NONBLOCK and empty sub", {
+ nng_msg *msg;
+ char *buf;
+ size_t size;
+
+ So(nng_setopt(sub, NNG_OPT_SUB_SUBSCRIBE, "", 0) == 0);
+ So(nng_recvmsg(sub, &msg, NNG_FLAG_NONBLOCK) == NNG_EAGAIN);
+ So(nng_recv(sub, &buf, &size, NNG_FLAG_NONBLOCK | NNG_FLAG_ALLOC) == NNG_EAGAIN);
+ });
+
+ Convey("Subs without subscriptions don't receive", {
+ nng_msg *msg;
+ So(nng_setopt_ms(sub, NNG_OPT_RECVTIMEO, 90) == 0);
+
+ So(nng_msg_alloc(&msg, 0) == 0);
+ APPENDSTR(msg, "/some/don't/like/it");
+ So(nng_sendmsg(pub, msg, 0) == 0);
+ So(nng_recvmsg(sub, &msg, 0) == NNG_ETIMEDOUT);
+ });
+
+ });
Convey("Subs in raw receive", {
nng_msg * msg;