about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-06-04 14:37:26 -0400
committerFedor Indutny <fedor@indutny.com>2016-06-04 14:37:26 -0400
commit0799c7c91ee710eb9ce752bcfcd6952a0838b495 (patch)
tree95438536ddd04497de650d99196eada0d822e255 /test
parentc5e93b2077a6ea27b4af440cfe4938d7bc093c2f (diff)
downloaduv_link_t-0799c7c91ee710eb9ce752bcfcd6952a0838b495.tar.gz
api: `uv_link_strerror`
Diffstat (limited to 'test')
-rw-r--r--test/src/test-list.h1
-rw-r--r--test/src/test-strerror.c35
-rw-r--r--test/test.gyp1
3 files changed, 37 insertions, 0 deletions
diff --git a/test/src/test-list.h b/test/src/test-list.h
index 591b858..abb7cda 100644
--- a/test/src/test-list.h
+++ b/test/src/test-list.h
@@ -6,6 +6,7 @@
     V(uv_link_observer_t)                                                     \
     V(close_depth)                                                            \
     V(stop_read_on_error)                                                     \
+    V(strerror)                                                               \
 
 #define TEST_DECL(N) void test__##N();
 
diff --git a/test/src/test-strerror.c b/test/src/test-strerror.c
new file mode 100644
index 0000000..c3b44c2
--- /dev/null
+++ b/test/src/test-strerror.c
@@ -0,0 +1,35 @@
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include "test-common.h"
+
+static uv_link_t st_link;
+
+static int close_cb_called;
+
+
+const char* test_strerror(uv_link_t* l, int err) {
+  CHECK_EQ(l, &st_link, "link == st_link");
+  return "Description";
+}
+
+
+static uv_link_methods_t methods = {
+  .strerror = test_strerror,
+  .close = uv_link_default_close
+};
+
+static void close_cb(uv_link_t* l) {
+  close_cb_called++;
+}
+
+
+TEST_IMPL(strerror) {
+  CHECK_EQ(uv_link_init(&st_link, &methods), 0, "uv_link_init()");
+
+  CHECK_EQ(strcmp(uv_link_strerror(&st_link, -1), "Description"), 0,
+           "error description should match");
+
+  uv_link_close(&st_link, close_cb);
+  CHECK_EQ(close_cb_called, 1, "close_cb must be called");
+}
diff --git a/test/test.gyp b/test/test.gyp
index 0bd930d..131b93a 100644
--- a/test/test.gyp
+++ b/test/test.gyp
@@ -18,6 +18,7 @@
       "src/test-uv-link-observer-t.c",
       "src/test-defaults.c",
       "src/test-close.c",
+      "src/test-strerror.c",
     ],
   }],
 }