summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/list.c9
-rw-r--r--tests/sock.c35
2 files changed, 41 insertions, 3 deletions
diff --git a/tests/list.c b/tests/list.c
index 67e3106b..10668b50 100644
--- a/tests/list.c
+++ b/tests/list.c
@@ -34,6 +34,10 @@ TestMain("Linked Lists", {
Convey("And we can add an item", {
mystruct item;
+
+ NNI_LIST_NODE_INIT(&item.nodea);
+ NNI_LIST_NODE_INIT(&item.nodeb);
+
nni_list_append(&alist, &item);
Convey("It is the first item", {
@@ -61,6 +65,11 @@ TestMain("Linked Lists", {
mystruct item1;
mystruct item2;
+ NNI_LIST_NODE_INIT(&item1.nodea);
+ NNI_LIST_NODE_INIT(&item1.nodeb);
+ NNI_LIST_NODE_INIT(&item2.nodea);
+ NNI_LIST_NODE_INIT(&item2.nodeb);
+
nni_list_append(&alist, &item1);
nni_list_append(&alist, &item2);
diff --git a/tests/sock.c b/tests/sock.c
index c4fcbee0..1179dca9 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -24,6 +24,10 @@ TestMain("Socket Operations", {
So(rv == 0);
})
+ Reset({
+ nng_close(sock);
+ })
+
Convey("It's type is still proto", {
So(nng_protocol(sock) == NNG_PROTO_PAIR);
})
@@ -101,14 +105,39 @@ TestMain("Socket Operations", {
})
})
- Convey("Dialing bogus address not supported", {
- rv = nng_dial(sock, "bogus://somewhere", NULL, 0);
- So(rv == NNG_ENOTSUP);
+ Convey("Bogus URLs not supported", {
+ Convey("Dialing fails properly", {
+ rv = nng_dial(sock, "bogus://somewhere", NULL, 0);
+ So(rv == NNG_ENOTSUP);
+ })
+ Convey("Listening fails properly", {
+ rv = nng_listen(sock, "bogus://elsewhere", NULL, 0);
+ So(rv == NNG_ENOTSUP);
+ })
})
Convey("Dialing synch can get refused", {
rv = nng_dial(sock, "inproc://notthere", NULL, NNG_FLAG_SYNCH);
So(rv == NNG_ECONNREFUSED);
})
+
+ Convey("Listening works", {
+ rv = nng_listen(sock, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == 0);
+
+ Convey("Second listen fails ADDRINUSE", {
+ rv = nng_listen(sock, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == NNG_EADDRINUSE);
+ })
+
+ Convey("We can connect to it", {
+ nng_socket *sock2 = NULL;
+ rv = nng_open(&sock2, NNG_PROTO_PAIR);
+ So(rv == 0);
+ rv = nng_dial(sock2, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == 0);
+ nng_close(sock2);
+ })
+ })
})
}) \ No newline at end of file