diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-03 01:24:38 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-03 01:26:41 -0700 |
| commit | a5807e45b1badfb5d0cb4f697e1873a8ece59a30 (patch) | |
| tree | b7afdc8fb8a8e39eeead11e6fae34478743644f6 /src/sp | |
| parent | b3fc8a44119d7ab90366a1b92a5e1327ebcb8145 (diff) | |
| download | nng-a5807e45b1badfb5d0cb4f697e1873a8ece59a30.tar.gz nng-a5807e45b1badfb5d0cb4f697e1873a8ece59a30.tar.bz2 nng-a5807e45b1badfb5d0cb4f697e1873a8ece59a30.zip | |
Add some more tests for sub coverage.
Diffstat (limited to 'src/sp')
| -rw-r--r-- | src/sp/protocol/pubsub0/sub_test.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/sp/protocol/pubsub0/sub_test.c b/src/sp/protocol/pubsub0/sub_test.c index 9929de64..d0a441ce 100644 --- a/src/sp/protocol/pubsub0/sub_test.c +++ b/src/sp/protocol/pubsub0/sub_test.c @@ -8,6 +8,7 @@ // #include "nng/nng.h" +#include "nng/protocol/pubsub0/sub.h" #include <nuts.h> static void @@ -546,6 +547,10 @@ test_sub_multi_context(void) nng_aio_wait(aio2); NUTS_FAIL(nng_aio_result(aio1), NNG_ETIMEDOUT); NUTS_FAIL(nng_aio_result(aio2), NNG_ETIMEDOUT); + + NUTS_PASS(nng_sub0_ctx_unsubscribe(c2, "two", 3)); + NUTS_PASS(nng_sub0_ctx_unsubscribe(c2, "all", 3)); + NUTS_CLOSE(sub); NUTS_CLOSE(pub); nng_aio_free(aio1); @@ -564,6 +569,38 @@ test_sub_cooked(void) NUTS_CLOSE(s); } +static void +test_sub_wrong_protocol(void) +{ +#ifdef NNG_HAVE_REQ0 + nng_socket s; + nng_ctx c; + + NUTS_PASS(nng_req0_open(&s)); + NUTS_PASS(nng_ctx_open(&c, s)); + NUTS_FAIL(nng_sub0_socket_subscribe(s, NULL, 0), NNG_ENOTSUP); + NUTS_FAIL(nng_sub0_socket_unsubscribe(s, NULL, 0), NNG_ENOTSUP); + NUTS_FAIL(nng_sub0_ctx_subscribe(c, NULL, 0), NNG_ENOTSUP); + NUTS_FAIL(nng_sub0_ctx_unsubscribe(c, NULL, 0), NNG_ENOTSUP); + NUTS_CLOSE(s); +#endif +} + +static void +test_sub_closed_socket(void) +{ + nng_socket s; + nng_ctx c; + + NUTS_PASS(nng_sub0_open(&s)); + NUTS_PASS(nng_ctx_open(&c, s)); + NUTS_CLOSE(s); + NUTS_FAIL(nng_sub0_socket_subscribe(s, NULL, 0), NNG_ECLOSED); + NUTS_FAIL(nng_sub0_socket_unsubscribe(s, NULL, 0), NNG_ECLOSED); + NUTS_FAIL(nng_sub0_ctx_subscribe(c, NULL, 0), NNG_ECLOSED); + NUTS_FAIL(nng_sub0_ctx_unsubscribe(c, NULL, 0), NNG_ECLOSED); +} + TEST_LIST = { { "sub identity", test_sub_identity }, { "sub cannot send", test_sub_cannot_send }, @@ -586,5 +623,7 @@ TEST_LIST = { { "sub filter", test_sub_filter }, { "sub multi context", test_sub_multi_context }, { "sub cooked", test_sub_cooked }, + { "sub wrong protocol", test_sub_wrong_protocol }, + { "sub closed socket", test_sub_closed_socket }, { NULL, NULL }, }; |
