summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-06 20:00:28 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-17 13:51:25 (GMT)
commit70d88a536135067bff693de5d6c96d866dc5b00e (patch)
treed786813f7b135ee56f76e9ad7a05f7af44b15390 /Tests
parent17690558c3ef6e6db850aa9f2993ea07467fe536 (diff)
downloadCMake-70d88a536135067bff693de5d6c96d866dc5b00e.zip
CMake-70d88a536135067bff693de5d6c96d866dc5b00e.tar.gz
CMake-70d88a536135067bff693de5d6c96d866dc5b00e.tar.bz2
cmUVHandlePtr: Add uv_idle_ptr
Wrap a `uv_idle_t` handle.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
index ce11761..1b08778 100644
--- a/Tests/CMakeLib/testUVRAII.cxx
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -162,6 +162,7 @@ static bool testAllMoves()
uv_async_ptr _13;
uv_signal_ptr _14;
uv_handle_ptr _15;
+ uv_idle_ptr _16;
};
allTypes a;
@@ -218,6 +219,30 @@ static bool testLoopDestructor()
return true;
}
+static bool testIdle()
+{
+ bool idled = false;
+
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ cm::uv_idle_ptr idle;
+ idle.init(*loop, &idled);
+ uv_idle_start(idle, [](uv_idle_t* handle) {
+ auto idledPtr = static_cast<bool*>(handle->data);
+ *idledPtr = true;
+ uv_idle_stop(handle);
+ });
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ if (!idled) {
+ std::cerr << "uv_idle_ptr did not trigger callback" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
int testUVRAII(int, char** const)
{
if (!testAsyncShutdown()) {
@@ -230,5 +255,6 @@ int testUVRAII(int, char** const)
passed = testAllMoves() && passed;
passed = testLoopReset() && passed;
passed = testLoopDestructor() && passed;
+ passed = testIdle() && passed;
return passed ? 0 : -1;
}