Skip to content

Commit

Permalink
tests: add listener and dialer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Nov 23, 2024
1 parent 3ed5d7e commit 6dfdcac
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/core/sock_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,46 @@ test_dialer_options(void)
NUTS_CLOSE(s1);
}

void
test_dialer_create_url(void)
{
nng_socket s1;
nng_dialer d;
nng_url *u;
const nng_url *u2;

NUTS_OPEN(s1);

NUTS_PASS(nng_url_parse(&u, "inproc://dialer_create_url"));
NUTS_PASS(nng_dialer_create_url(&d, s1, u));
NUTS_PASS(nng_dialer_get_url(d, &u2));
NUTS_MATCH(nng_url_scheme(u), nng_url_scheme(u2));
NUTS_MATCH(nng_url_path(u), nng_url_path(u2));
nng_url_free(u);
NUTS_CLOSE(s1);
}

void
test_dial_url(void)
{
nng_socket s1;
nng_dialer d;
nng_url *u;
const nng_url *u2;

NUTS_OPEN(s1);
NUTS_PASS(nng_url_parse(&u, "inproc://dial_url"));

NUTS_PASS(nng_dial_url(s1, u, &d, NNG_FLAG_NONBLOCK));
nng_dialer_get_url(d, &u2);

NUTS_MATCH(nng_url_scheme(u), nng_url_scheme(u2));
NUTS_MATCH(nng_url_path(u), nng_url_path(u2));
nng_url_free(u);

NUTS_CLOSE(s1);
}

void
test_endpoint_absent_options(void)
{
Expand Down Expand Up @@ -515,6 +555,8 @@ NUTS_TESTS = {
{ "listener create url", test_listener_create_url },
{ "listen url", test_listen_url },
{ "dialer options", test_dialer_options },
{ "dialer create url", test_dialer_create_url },
{ "dial url", test_dial_url },
{ "timeout options", test_timeout_options },
{ "size options", test_size_options },
{ "endpoint absent options", test_endpoint_absent_options },
Expand Down

0 comments on commit 6dfdcac

Please sign in to comment.