aboutsummaryrefslogtreecommitdiff
path: root/tests/sock.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-06 08:18:50 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-06 08:21:09 -0800
commita2801adffebb6a3679e41789b38ba925ed32832b (patch)
tree8e3a743301fedb04d19d9af3e30f5622b737c337 /tests/sock.c
parent601d7a6ca95678613ca576258314f50a6e5e742c (diff)
downloadnng-a2801adffebb6a3679e41789b38ba925ed32832b.tar.gz
nng-a2801adffebb6a3679e41789b38ba925ed32832b.tar.bz2
nng-a2801adffebb6a3679e41789b38ba925ed32832b.zip
Message API was awkward.
The use of a single function to get both size and length actually turned out to be awkward to use; better to have separate functions to get each. While here, disable some of the initialization/fork checks, because it turns out they aren't needed.
Diffstat (limited to 'tests/sock.c')
-rw-r--r--tests/sock.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/sock.c b/tests/sock.c
index e0743936..78d97a9b 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -148,8 +148,6 @@ TestMain("Socket Operations", {
nng_socket *sock2 = NULL;
int len = 1;
nng_msg *msg;
- size_t sz;
- char *ptr;
uint64_t second = 1000000;
rv = nng_open(&sock2, NNG_PROTO_PAIR);
@@ -181,11 +179,9 @@ TestMain("Socket Operations", {
rv = nng_msg_alloc(&msg, 3);
So(rv == 0);
- ptr = nng_msg_body(msg, &sz);
- So(ptr != NULL);
- So(sz == 3);
-
- memcpy(ptr, "abc", 3);
+ So(nng_msg_len(msg) == 3);
+ So(nng_msg_body(msg) != NULL);
+ memcpy(nng_msg_body(msg), "abc", 3);
rv = nng_sendmsg(sock, msg, 0);
So(rv == 0);
@@ -194,10 +190,8 @@ TestMain("Socket Operations", {
rv = nng_recvmsg(sock2, &msg, 0);
So(rv == 0);
So(msg != NULL);
- ptr = nng_msg_body(msg, &sz);
- So(ptr != NULL);
- So(sz == 3);
- So(memcmp(ptr, "abc", 3) == 0);
+ So(nng_msg_len(msg) == 3);
+ So(memcmp(nng_msg_body(msg), "abc", 3) == 0);
nng_msg_free(msg);
nng_close(sock2);
})