Skip to content

Commit

Permalink
Add some more tests for sub coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Nov 3, 2024
1 parent b3fc8a4 commit 8911edd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/sp/protocol/pubsub0/sub_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#include "nng/nng.h"
#include "nng/protocol/pubsub0/sub.h"
#include <nuts.h>

static void
Expand Down Expand Up @@ -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);
Expand All @@ -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 },
Expand All @@ -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 },
};

0 comments on commit 8911edd

Please sign in to comment.