about summary refs log tree commit diff stats
path: root/test/src
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-05-27 23:50:46 -0400
committerFedor Indutny <fedor@indutny.com>2016-05-27 23:50:46 -0400
commitd4069cc59b0c9d4ce00977a9268f90e306f1cdf8 (patch)
treeb4d35fb43555503db6566de9d0cf1cd71d6497f1 /test/src
parent6a1f2335d96dfaf95a4423b94c36df389e3d4ec2 (diff)
downloaduv_link_t-d4069cc59b0c9d4ce00977a9268f90e306f1cdf8.tar.gz
api: inherit structs from uv_link_t
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-uv-link-observer-t.c8
-rw-r--r--test/src/test-uv-link-source-t.c26
2 files changed, 17 insertions, 17 deletions
diff --git a/test/src/test-uv-link-observer-t.c b/test/src/test-uv-link-observer-t.c
index 0ce7b80..d81b679 100644
--- a/test/src/test-uv-link-observer-t.c
+++ b/test/src/test-uv-link-observer-t.c
@@ -40,7 +40,7 @@ static void observer_read_cb(uv_link_observer_t* o,
 
 
 static void close_cb(uv_link_t* link) {
-  CHECK_EQ(link, &observer.link, "close_cb link");
+  CHECK_EQ(link, (uv_link_t*) &observer, "close_cb link");
 
   close_cb_called++;
 }
@@ -52,10 +52,10 @@ TEST_IMPL(uv_link_observer_t) {
   CHECK_EQ(uv_link_init(&source, &methods), 0, "uv_link_init(source)");
 
   CHECK_EQ(uv_link_observer_init(&observer), 0, "uv_link_observer_init()");
-  CHECK_EQ(uv_link_chain(&source, &observer.link), 0,
+  CHECK_EQ(uv_link_chain(&source, (uv_link_t*) &observer), 0,
            "uv_link_chain");
 
-  observer.read_cb = observer_read_cb;
+  observer.observer_read_cb = observer_read_cb;
 
   uv_link_propagate_alloc_cb(&source, 1024, &buf);
 
@@ -63,7 +63,7 @@ TEST_IMPL(uv_link_observer_t) {
   uv_link_propagate_read_cb(&source, 1, &buf);
   CHECK_EQ(observer_read_cb_called, 1, "observer.read_cb must be called");
 
-  uv_link_close(&observer.link, close_cb);
+  uv_link_close((uv_link_t*) &observer, close_cb);
   CHECK_EQ(fake_close_called, 1, "fake close count");
   CHECK_EQ(close_cb_called, 1, "close_cb count");
 }
diff --git a/test/src/test-uv-link-source-t.c b/test/src/test-uv-link-source-t.c
index 1d12ac0..4024f5f 100644
--- a/test/src/test-uv-link-source-t.c
+++ b/test/src/test-uv-link-source-t.c
@@ -27,7 +27,7 @@ static void read_one() {
 }
 
 static void source_write_cb(uv_link_t* link, int status, void* arg) {
-  CHECK_EQ(link, &source.link, "link == &source.link");
+  CHECK_EQ(link, (uv_link_t*) &source, "link == &source");
   CHECK_EQ(arg, &test_arg, "arg == &test_arg");
 
   write_cb_called++;
@@ -41,18 +41,18 @@ static void test_writes() {
 
   /* .write() should work */
   buf = uv_buf_init("x", 1);
-  CHECK_EQ(uv_link_write(&source.link, &buf, 1, NULL, source_write_cb,
+  CHECK_EQ(uv_link_write((uv_link_t*) &source, &buf, 1, NULL, source_write_cb,
                          &test_arg),
            0,
-           "source.link.write() should return 0");
+           "source.write() should return 0");
 
   CHECK_EQ(uv_run(loop, UV_RUN_DEFAULT), 0, "uv_run()");
 
   CHECK_EQ(write_cb_called, 1, "source_write_cb() must be called");
 
   /* .try_write() should work too */
-  CHECK_EQ(uv_link_try_write(&source.link, &buf, 1), 1,
-           "source.link.try_write() should return 1");
+  CHECK_EQ(uv_link_try_write((uv_link_t*) &source, &buf, 1), 1,
+           "source.try_write() should return 1");
   read_one();
 }
 
@@ -62,7 +62,7 @@ static void source_alloc_cb(uv_link_t* link,
                             uv_buf_t* buf) {
   static char storage[1024];
 
-  CHECK_EQ(link, &source.link, "link == &source.link");
+  CHECK_EQ(link, (uv_link_t*) &source, "link == &source");
 
   alloc_cb_called++;
 
@@ -73,14 +73,14 @@ static void source_alloc_cb(uv_link_t* link,
 static void source_read_cb(uv_link_t* link,
                            ssize_t nread,
                            const uv_buf_t* buf) {
-  CHECK_EQ(link, &source.link, "link == &source.link");
+  CHECK_EQ(link, (uv_link_t*) &source, "link == &source");
 
   read_cb_called++;
 
   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(uv_link_read_stop(&source.link), 0, "source.link.read_stop()");
+  CHECK_EQ(uv_link_read_stop((uv_link_t*) &source), 0, "source.read_stop()");
 }
 
 
@@ -88,15 +88,15 @@ static void test_reads() {
   int err;
 
   /* alloc_cb/read_cb */
-  source.link.alloc_cb = source_alloc_cb;
-  source.link.read_cb = source_read_cb;
+  source.alloc_cb = source_alloc_cb;
+  source.read_cb = source_read_cb;
 
   do
     err = write(fds[0], "x", 1);
   while (err == -1 && errno == EINTR);
   CHECK_EQ(err, 1, "write() == 1");
 
-  CHECK_EQ(uv_link_read_start(&source.link), 0, "source.link.read_start()");
+  CHECK_EQ(uv_link_read_start((uv_link_t*) &source), 0, "source.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");
@@ -105,7 +105,7 @@ static void test_reads() {
 
 
 static void close_cb(uv_link_t* link) {
-  CHECK_EQ(link, &source.link, "close_cb link");
+  CHECK_EQ(link, (uv_link_t*) &source, "close_cb link");
   close_cb_called++;
 }
 
@@ -124,7 +124,7 @@ TEST_IMPL(uv_link_source_t) {
   test_writes();
   test_reads();
 
-  uv_link_close(&source.link, close_cb);
+  uv_link_close((uv_link_t*) &source, close_cb);
   CHECK_EQ(uv_run(loop, UV_RUN_DEFAULT), 0, "uv_run()");
   CHECK_EQ(close_cb_called, 1, "close_cb count");