summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib/testUVRAII.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-04-23 17:37:26 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2019-04-25 16:03:08 (GMT)
commit8cfd25db711c22f9478e565a496145577df24d77 (patch)
tree4903ef06ec74137f44c375bbdd23fbbce9a99676 /Tests/CMakeLib/testUVRAII.cxx
parentc0e6b22d0a81c0e0dc1ee87366790882a3d54667 (diff)
downloadCMake-8cfd25db711c22f9478e565a496145577df24d77.zip
CMake-8cfd25db711c22f9478e565a496145577df24d77.tar.gz
CMake-8cfd25db711c22f9478e565a496145577df24d77.tar.bz2
cmUVHandlePtr: Add cm::uv_loop_ptr
Diffstat (limited to 'Tests/CMakeLib/testUVRAII.cxx')
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx50
1 files changed, 49 insertions, 1 deletions
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
index 1c1da76..2aeaf2c 100644
--- a/Tests/CMakeLib/testUVRAII.cxx
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -171,11 +171,59 @@ static bool testAllMoves()
return true;
};
+static bool testLoopReset()
+{
+ bool closed = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_t timer;
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+
+ loop.reset();
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+static bool testLoopDestructor()
+{
+ bool closed = false;
+
+ uv_timer_t timer;
+ {
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+ }
+
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
int testUVRAII(int, char** const)
{
if ((testAsyncShutdown() &&
testAsyncDtor() & testAsyncMove() & testCrossAssignment() &
- testAllMoves()) == 0) {
+ testAllMoves() & testLoopReset() & testLoopDestructor()) == 0) {
return -1;
}
return 0;