summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-20 22:53:47 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-20 23:21:46 (GMT)
commit89435a5662320a7b77c359a15a3457ae666ae722 (patch)
treead548a3eb323d9764beedc9f28d850871f30b005 /Tests/CMakeLib
parente68e7b176808c6c8b226c15a80d6632fc2b73751 (diff)
downloadCMake-89435a5662320a7b77c359a15a3457ae666ae722.zip
CMake-89435a5662320a7b77c359a15a3457ae666ae722.tar.gz
CMake-89435a5662320a7b77c359a15a3457ae666ae722.tar.bz2
Tests: Add dedicated test to cover cmUVHandlePtr types
Move the case added by commit 70d88a5361 (cmUVHandlePtr: Add uv_idle_ptr, 2023-11-06) to a dedicated test.
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r--Tests/CMakeLib/CMakeLists.txt1
-rw-r--r--Tests/CMakeLib/testUVHandlePtr.cxx36
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx25
3 files changed, 37 insertions, 25 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
index 0e71cea..979d449 100644
--- a/Tests/CMakeLib/CMakeLists.txt
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -25,6 +25,7 @@ set(CMakeLib_TESTS
testXMLParser.cxx
testXMLSafe.cxx
testFindPackageCommand.cxx
+ testUVHandlePtr.cxx
testUVProcessChain.cxx
testUVRAII.cxx
testUVStreambuf.cxx
diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx
new file mode 100644
index 0000000..5aab556
--- /dev/null
+++ b/Tests/CMakeLib/testUVHandlePtr.cxx
@@ -0,0 +1,36 @@
+#include <iostream>
+
+#include <cm3p/uv.h>
+
+#include "cmUVHandlePtr.h"
+
+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 testUVHandlePtr(int, char** const)
+{
+ bool passed = true;
+ passed = testIdle() && passed;
+ return passed ? 0 : -1;
+}
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
index 1b08778..9e79d5c 100644
--- a/Tests/CMakeLib/testUVRAII.cxx
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -219,30 +219,6 @@ 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()) {
@@ -255,6 +231,5 @@ int testUVRAII(int, char** const)
passed = testAllMoves() && passed;
passed = testLoopReset() && passed;
passed = testLoopDestructor() && passed;
- passed = testIdle() && passed;
return passed ? 0 : -1;
}