forked from cory/tildefriends
libuv 1.44.2
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3934 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
27
deps/libuv/test/test-timer.c
vendored
27
deps/libuv/test/test-timer.c
vendored
@ -25,6 +25,8 @@
|
||||
|
||||
static int once_cb_called = 0;
|
||||
static int once_close_cb_called = 0;
|
||||
static int twice_cb_called = 0;
|
||||
static int twice_close_cb_called = 0;
|
||||
static int repeat_cb_called = 0;
|
||||
static int repeat_close_cb_called = 0;
|
||||
static int order_cb_called = 0;
|
||||
@ -58,6 +60,27 @@ static void once_cb(uv_timer_t* handle) {
|
||||
uv_update_time(uv_default_loop());
|
||||
}
|
||||
|
||||
static void twice_close_cb(uv_handle_t* handle) {
|
||||
printf("TWICE_CLOSE_CB\n");
|
||||
|
||||
ASSERT_NOT_NULL(handle);
|
||||
ASSERT(0 == uv_is_active(handle));
|
||||
|
||||
twice_close_cb_called++;
|
||||
}
|
||||
|
||||
static void twice_cb(uv_timer_t* handle) {
|
||||
printf("TWICE_CB %d\n", twice_cb_called);
|
||||
|
||||
ASSERT_NOT_NULL(handle);
|
||||
ASSERT(0 == uv_is_active((uv_handle_t*) handle));
|
||||
|
||||
twice_cb_called++;
|
||||
|
||||
uv_close((uv_handle_t*)handle, twice_close_cb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void repeat_close_cb(uv_handle_t* handle) {
|
||||
printf("REPEAT_CLOSE_CB\n");
|
||||
@ -144,12 +167,12 @@ TEST_IMPL(timer_start_twice) {
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&once, never_cb, 86400 * 1000, 0);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&once, once_cb, 10, 0);
|
||||
r = uv_timer_start(&once, twice_cb, 10, 0);
|
||||
ASSERT(r == 0);
|
||||
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(once_cb_called == 1);
|
||||
ASSERT(twice_cb_called == 1);
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user