summaryrefslogtreecommitdiff
path: root/tests/wssfile.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-19 16:02:37 -0700
committerGarrett D'Amore <garrett@damore.org>2018-03-20 09:53:58 -0700
commit9ca901c1b70b17d851426483d9f54611cfa8e395 (patch)
treea26b11e16f505ccdc77b5ac6681e0f9de705ff20 /tests/wssfile.c
parent9b886a9999247d87c9f6d389c3e65a4bd39be010 (diff)
downloadnng-9ca901c1b70b17d851426483d9f54611cfa8e395.tar.gz
nng-9ca901c1b70b17d851426483d9f54611cfa8e395.tar.bz2
nng-9ca901c1b70b17d851426483d9f54611cfa8e395.zip
fixes #296 Typed options should validate option type
fixes #302 nng_dialer/listener/pipe_getopt_sockaddr desired This adds plumbing to pass and check the type of options all the way through. NNG_ZT_OPT_ORBIT is type UINT64, but you can use the untyped form to pass two of them if needed. No typed access for retrieving strings yet. I think this should allocate a pointer and copy that out, but that's for later.
Diffstat (limited to 'tests/wssfile.c')
-rw-r--r--tests/wssfile.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/wssfile.c b/tests/wssfile.c
index 15f7008e..48736117 100644
--- a/tests/wssfile.c
+++ b/tests/wssfile.c
@@ -144,16 +144,21 @@ check_props(nng_msg *msg)
p = nng_msg_get_pipe(msg);
So(p > 0);
+ // Typed
z = sizeof(nng_sockaddr);
- So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0);
+ So(nng_pipe_getopt_sockaddr(p, NNG_OPT_LOCADDR, &la) == 0);
So(z == sizeof(la));
So(validloopback(&la));
+ // Untyped
z = sizeof(nng_sockaddr);
So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0);
So(z == sizeof(ra));
So(validloopback(&ra));
+ // Bad type
+ So(nng_pipe_getopt_size(p, NNG_OPT_LOCADDR, &z) == NNG_EBADTYPE);
+
// Request header
z = 0;
buf = NULL;
@@ -298,7 +303,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
char addr[NNG_MAXADDRLEN];
nng_msg * msg;
nng_pipe p;
- int v;
+ bool b;
So(nng_pair_open(&s1) == 0);
So(nng_pair_open(&s2) == 0);
@@ -337,8 +342,8 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
So(strcmp(nng_msg_body(msg), "hello") == 0);
p = nng_msg_get_pipe(msg);
So(p > 0);
- So(nng_pipe_getopt_int(p, NNG_OPT_TLS_VERIFIED, &v) == 0);
- So(v == 0);
+ So(nng_pipe_getopt_bool(p, NNG_OPT_TLS_VERIFIED, &b) == 0);
+ So(b == false);
nng_msg_free(msg);
});
@@ -350,7 +355,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
char addr[NNG_MAXADDRLEN];
nng_msg * msg;
nng_pipe p;
- int v;
+ bool b;
So(nng_pair_open(&s1) == 0);
So(nng_pair_open(&s2) == 0);
@@ -379,8 +384,8 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
So(strcmp(nng_msg_body(msg), "hello") == 0);
p = nng_msg_get_pipe(msg);
So(p > 0);
- So(nng_pipe_getopt_int(p, NNG_OPT_TLS_VERIFIED, &v) == 0);
- So(v == 1);
+ So(nng_pipe_getopt_bool(p, NNG_OPT_TLS_VERIFIED, &b) == 0);
+ So(b == true);
nng_msg_free(msg);
});