about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-05-26 02:50:14 -0400
committerFedor Indutny <fedor@indutny.com>2016-05-26 02:50:14 -0400
commit27b6c247c5a19e0fe812c9fc9df1a56d5350ade7 (patch)
tree64e62f0ca552cc50c694c9b2998148653a746324 /test
parentefbf1ba3234e62f74b538c74dc4b9a4c850a47da (diff)
downloaduv_link_t-27b6c247c5a19e0fe812c9fc9df1a56d5350ade7.tar.gz
src: move methods to separate read-only structure
Diffstat (limited to 'test')
-rw-r--r--test/src/test-uv-link-observer-t.c12
-rw-r--r--test/src/test-uv-link-source-t.c10
2 files changed, 11 insertions, 11 deletions
diff --git a/test/src/test-uv-link-observer-t.c b/test/src/test-uv-link-observer-t.c
index cb4026d..3edf9ea 100644
--- a/test/src/test-uv-link-observer-t.c
+++ b/test/src/test-uv-link-observer-t.c
@@ -3,12 +3,15 @@
 
 #include "test-common.h"
 
-static uv_loop_t* loop;
 static uv_link_t source;
 static uv_link_observer_t observer;
 
 static int observer_read_cb_called;
 
+static uv_link_methods_t methods = {
+  /* no-op, won't be called */
+};
+
 static void observer_read_cb(uv_link_observer_t* o,
                              ssize_t nread,
                              const uv_buf_t* buf) {
@@ -23,12 +26,9 @@ static void observer_read_cb(uv_link_observer_t* o,
 TEST_IMPL(uv_link_observer_t) {
   uv_buf_t buf;
 
-  loop = uv_default_loop();
-  CHECK_NE(loop, NULL, "uv_default_loop()");
-
-  CHECK_EQ(uv_link_init(loop, &source), 0, "uv_link_init(source)");
+  CHECK_EQ(uv_link_init(&source, &methods), 0, "uv_link_init(source)");
 
-  CHECK_EQ(uv_link_observer_init(loop, &observer, &source), 0,
+  CHECK_EQ(uv_link_observer_init(&observer, &source), 0,
            "uv_link_observer_init()");
 
   observer.read_cb = observer_read_cb;
diff --git a/test/src/test-uv-link-source-t.c b/test/src/test-uv-link-source-t.c
index 64ab200..404543a 100644
--- a/test/src/test-uv-link-source-t.c
+++ b/test/src/test-uv-link-source-t.c
@@ -38,7 +38,7 @@ static void test_writes() {
 
   /* .write() should work */
   buf = uv_buf_init("x", 1);
-  CHECK_EQ(source.link.write(&source.link, &buf, 1, NULL, source_write_cb), 0,
+  CHECK_EQ(uv_link_write(&source.link, &buf, 1, NULL, source_write_cb), 0,
            "source.link.write() should return 0");
 
   CHECK_EQ(uv_run(loop, UV_RUN_DEFAULT), 0, "uv_run()");
@@ -46,7 +46,7 @@ static void test_writes() {
   CHECK_EQ(write_cb_called, 1, "source_write_cb() must be called");
 
   /* .try_write() should work too */
-  CHECK_EQ(source.link.try_write(&source.link, &buf, 1), 1,
+  CHECK_EQ(uv_link_try_write(&source.link, &buf, 1), 1,
            "source.link.try_write() should return 1");
   read_one();
 }
@@ -75,7 +75,7 @@ static void source_read_cb(uv_link_t* link,
   CHECK_EQ(nread, 1, "source_read_cb must read one byte");
   CHECK_EQ(buf->base[0], 'x', "source_read_cb must read correct one byte");
 
-  CHECK_EQ(source.link.read_stop(&source.link), 0, "source.link.read_stop()");
+  CHECK_EQ(uv_link_read_stop(&source.link), 0, "source.link.read_stop()");
 }
 
 
@@ -91,7 +91,7 @@ static void test_reads() {
   while (err == -1 && errno == EINTR);
   CHECK_EQ(err, 1, "write() == 1");
 
-  CHECK_EQ(source.link.read_start(&source.link), 0, "source.link.read_start()");
+  CHECK_EQ(uv_link_read_start(&source.link), 0, "source.link.read_start()");
 
   CHECK_EQ(uv_run(loop, UV_RUN_DEFAULT), 0, "uv_run()");
   CHECK_EQ(alloc_cb_called, 1, "alloc_cb must be called once");
@@ -108,7 +108,7 @@ TEST_IMPL(uv_link_source_t) {
   CHECK_EQ(uv_pipe_init(loop, &pair_right, 0), 0, "uv_pipe_init(pair_right)");
   CHECK_EQ(uv_pipe_open(&pair_right, fds[1]), 0, "uv_pipe_open(pair_right)");
 
-  CHECK_EQ(uv_link_source_init(loop, &source, (uv_stream_t*) &pair_right), 0,
+  CHECK_EQ(uv_link_source_init(&source, (uv_stream_t*) &pair_right), 0,
            "uv_link_source_init()");
 
   test_writes();