summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
commit505a9bce029e51540739c853a6c9eef0ecfb2e90 (patch)
treed907679b6ab99bcb5da919db3d005d4976590c21 /tests
parent0aa1de1316b46bb4af23fdf26759bca08008eaf5 (diff)
downloadnng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.gz
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.bz2
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.zip
fixes #329 type checking not done for setopt
Diffstat (limited to 'tests')
-rw-r--r--tests/sock.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/sock.c b/tests/sock.c
index 30dcd1b5..a5b9bdc1 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -92,6 +92,7 @@ TestMain("Socket Operations", {
Convey("Sockname option works", {
char name[128]; // 64 is max
+ char * allocd;
size_t sz;
sz = sizeof(name);
So(nng_getopt(
@@ -110,13 +111,16 @@ TestMain("Socket Operations", {
memset(name, 'A', 64);
name[64] = '\0';
- So(nng_setopt(s1, NNG_OPT_SOCKNAME, name,
- strlen(name)) == NNG_EINVAL);
- So(nng_getopt(
- s1, NNG_OPT_SOCKNAME, name, &sz) == 0);
- So(sz == 6);
- So(strcmp(name, "hello") == 0);
+ // strings must be NULL terminated
+ So(nng_setopt(s1, NNG_OPT_SOCKNAME, name, 5) ==
+ NNG_EINVAL);
+
+ So(nng_getopt_string(
+ s1, NNG_OPT_SOCKNAME, &allocd) == 0);
+ So(strlen(allocd) == 5);
+ So(strcmp(allocd, "hello") == 0);
+ nng_strfree(allocd);
});
Convey("RAW option works", {