From 8911eddff368381f2ab397fdd87b6ad37e2c0a94 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 3 Nov 2024 01:24:38 -0700 Subject: [PATCH] Add some more tests for sub coverage. --- src/sp/protocol/pubsub0/sub_test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/sp/protocol/pubsub0/sub_test.c b/src/sp/protocol/pubsub0/sub_test.c index 9929de64a..c5e71ad46 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 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,23 @@ 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 +} + TEST_LIST = { { "sub identity", test_sub_identity }, { "sub cannot send", test_sub_cannot_send }, @@ -586,5 +608,6 @@ 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 }, { NULL, NULL }, };