diff options
author | Brad King <brad.king@kitware.com> | 2023-11-20 23:10:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-11-20 23:22:09 (GMT) |
commit | 8908f277d94ad9e0a1e04a2d9a8c69db955265e9 (patch) | |
tree | a376570697342813e4bfc1bc2abcd87b29ce8407 /Tests/CMakeLib | |
parent | f906e2482fc2ce9dc36fe7d49f8963dea2bb6ef9 (diff) | |
download | CMake-8908f277d94ad9e0a1e04a2d9a8c69db955265e9.zip CMake-8908f277d94ad9e0a1e04a2d9a8c69db955265e9.tar.gz CMake-8908f277d94ad9e0a1e04a2d9a8c69db955265e9.tar.bz2 |
Tests: Add dedicated test case for uv_timer_ptr
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r-- | Tests/CMakeLib/testUVHandlePtr.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx index f367047..02f8954 100644 --- a/Tests/CMakeLib/testUVHandlePtr.cxx +++ b/Tests/CMakeLib/testUVHandlePtr.cxx @@ -30,9 +30,36 @@ static bool testIdle() return true; } +static bool testTimer() +{ + bool timed = false; + + cm::uv_loop_ptr loop; + loop.init(); + + auto cb = [](uv_timer_t* handle) { + auto timedPtr = static_cast<bool*>(handle->data); + *timedPtr = true; + uv_timer_stop(handle); + }; + + cm::uv_timer_ptr timer; + timer.init(*loop, &timed); + timer.start(cb, 10, 0); + uv_run(loop, UV_RUN_DEFAULT); + + if (!timed) { + std::cerr << "uv_timer_ptr did not trigger callback" << std::endl; + return false; + } + + return true; +} + int testUVHandlePtr(int, char** const) { bool passed = true; passed = testIdle() && passed; + passed = testTimer() && passed; return passed ? 0 : -1; } |