diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-02 13:57:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-02 14:47:50 -0700 |
| commit | 279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 (patch) | |
| tree | b451ac7f845062674d6ab45eb5d530628d3ff47c /src/sp/protocol/pubsub0/sub_test.c | |
| parent | 9b27984d0e2da430b78a975e59f55c96de5f6056 (diff) | |
| download | nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.gz nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.bz2 nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.zip | |
NNG_OPT_RECVFD and NNG_OPT_SENDFD converted to functions.
These options are removed entirely, and their functionality is now
available via special functions, `nng_socket_get_send_poll_fd` and
`nng_socket_get_recv_poll_fd`, making these first class methods on
the socket.
This eliminates a bit of wasteful code, and provides type safety
for these methods.
Diffstat (limited to 'src/sp/protocol/pubsub0/sub_test.c')
| -rw-r--r-- | src/sp/protocol/pubsub0/sub_test.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/sp/protocol/pubsub0/sub_test.c b/src/sp/protocol/pubsub0/sub_test.c index a332a0a7..ef38042a 100644 --- a/src/sp/protocol/pubsub0/sub_test.c +++ b/src/sp/protocol/pubsub0/sub_test.c @@ -7,6 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // +#include "nng/nng.h" #include <nuts.h> static void @@ -70,7 +71,7 @@ test_sub_not_writeable(void) nng_socket sub; NUTS_PASS(nng_sub0_open(&sub)); - NUTS_FAIL(nng_socket_get_int(sub, NNG_OPT_SENDFD, &fd), NNG_ENOTSUP); + NUTS_FAIL(nng_socket_get_send_poll_fd(sub, &fd), NNG_ENOTSUP); NUTS_CLOSE(sub); } @@ -86,7 +87,7 @@ test_sub_poll_readable(void) NUTS_PASS(nng_socket_set(sub, NNG_OPT_SUB_SUBSCRIBE, "a", 1)); NUTS_PASS(nng_socket_set_ms(sub, NNG_OPT_RECVTIMEO, 1000)); NUTS_PASS(nng_socket_set_ms(pub, NNG_OPT_SENDTIMEO, 1000)); - NUTS_PASS(nng_socket_get_int(sub, NNG_OPT_RECVFD, &fd)); + NUTS_PASS(nng_socket_get_recv_poll_fd(sub, &fd)); NUTS_TRUE(fd >= 0); // Not readable if not connected! @@ -130,7 +131,7 @@ test_sub_recv_late(void) NUTS_PASS(nng_socket_set(sub, NNG_OPT_SUB_SUBSCRIBE, "", 0)); NUTS_PASS(nng_socket_set_ms(sub, NNG_OPT_RECVTIMEO, 1000)); NUTS_PASS(nng_socket_set_ms(pub, NNG_OPT_SENDTIMEO, 1000)); - NUTS_PASS(nng_socket_get_int(sub, NNG_OPT_RECVFD, &fd)); + NUTS_PASS(nng_socket_get_recv_poll_fd(sub, &fd)); NUTS_TRUE(fd >= 0); // Not readable if not connected! @@ -162,21 +163,6 @@ test_sub_recv_late(void) } void -test_sub_context_no_poll(void) -{ - int fd; - nng_socket sub; - nng_ctx ctx; - - NUTS_PASS(nng_sub0_open(&sub)); - NUTS_PASS(nng_ctx_open(&ctx, sub)); - NUTS_FAIL(nng_ctx_get_int(ctx, NNG_OPT_SENDFD, &fd), NNG_ENOTSUP); - NUTS_FAIL(nng_ctx_get_int(ctx, NNG_OPT_RECVFD, &fd), NNG_ENOTSUP); - NUTS_PASS(nng_ctx_close(ctx)); - NUTS_CLOSE(sub); -} - -void test_sub_validate_peer(void) { nng_socket s1, s2; @@ -603,7 +589,6 @@ TEST_LIST = { { "sub context cannot send", test_sub_context_cannot_send }, { "sub not writeable", test_sub_not_writeable }, { "sub poll readable", test_sub_poll_readable }, - { "sub context does not poll", test_sub_context_no_poll }, { "sub validate peer", test_sub_validate_peer }, { "sub recv late", test_sub_recv_late }, { "sub recv ctx closed", test_sub_recv_ctx_closed }, |
