diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/src/test-defaults.c | 43 | ||||
-rw-r--r-- | test/src/test-list.h | 1 | ||||
-rw-r--r-- | test/test.gyp | 1 |
3 files changed, 45 insertions, 0 deletions
diff --git a/test/src/test-defaults.c b/test/src/test-defaults.c new file mode 100644 index 0000000..909594c --- /dev/null +++ b/test/src/test-defaults.c @@ -0,0 +1,43 @@ +#include <sys/socket.h> +#include <unistd.h> + +#include "test-common.h" + +static uv_link_t st_link; + +static int reading; +static int close_cb_called; + + +static int read_start(uv_link_t* link) { + reading++; + return 0; +} + + +static int read_stop(uv_link_t* link) { + reading--; + return 0; +} + + +static uv_link_methods_t methods = { + .read_start = read_start, + .read_stop = read_stop, + .close = uv_link_default_close +}; + +static void close_cb(uv_link_t* l) { + close_cb_called++; +} + + +TEST_IMPL(stop_read_on_error) { + CHECK_EQ(uv_link_init(&st_link, &methods), 0, "uv_link_init()"); + CHECK_EQ(uv_link_read_start(&st_link), 0, "uv_link_read_start()"); + uv_link_propagate_read_cb(&st_link, UV_EOF, NULL); + CHECK_EQ(reading, 0, "must not be reading after error"); + + uv_link_close(&st_link, close_cb); + CHECK_EQ(close_cb_called, 1, "close_cb must be called"); +} diff --git a/test/src/test-list.h b/test/src/test-list.h index 9385095..591b858 100644 --- a/test/src/test-list.h +++ b/test/src/test-list.h @@ -5,6 +5,7 @@ V(uv_link_source_t) \ V(uv_link_observer_t) \ V(close_depth) \ + V(stop_read_on_error) \ #define TEST_DECL(N) void test__##N(); diff --git a/test/test.gyp b/test/test.gyp index 2a5d1d4..0bd930d 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -16,6 +16,7 @@ "src/main.c", "src/test-uv-link-source-t.c", "src/test-uv-link-observer-t.c", + "src/test-defaults.c", "src/test-close.c", ], }], |