diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-11 18:26:08 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-11 18:29:56 -0800 |
| commit | 15f63c95df73da3146d08331496f606e460d5821 (patch) | |
| tree | 379afa63ed245489849554f12c11e26a662e1cc3 | |
| parent | 4899ac728e258fcbcf5dc7c4ff279caa3ec44942 (diff) | |
| download | nng-15f63c95df73da3146d08331496f606e460d5821.tar.gz nng-15f63c95df73da3146d08331496f606e460d5821.tar.bz2 nng-15f63c95df73da3146d08331496f606e460d5821.zip | |
Add test case for bug 942.
| -rw-r--r-- | tests/pubsub.c | 27 |
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; |
