about summary refs log tree commit diff stats
path: root/test/src
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/src
parentefbf1ba3234e62f74b538c74dc4b9a4c850a47da (diff)
downloaduv_link_t-27b6c247c5a19e0fe812c9fc9df1a56d5350ade7.tar.gz
src: move methods to separate read-only structure
Diffstat (limited to 'test/src')
-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();
2 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479