From f906e2482fc2ce9dc36fe7d49f8963dea2bb6ef9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 20 Nov 2023 17:56:20 -0500 Subject: Tests: Factor out callback in uv_idle_ptr test case --- Tests/CMakeLib/testUVHandlePtr.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/CMakeLib/testUVHandlePtr.cxx b/Tests/CMakeLib/testUVHandlePtr.cxx index 5aab556..f367047 100644 --- a/Tests/CMakeLib/testUVHandlePtr.cxx +++ b/Tests/CMakeLib/testUVHandlePtr.cxx @@ -11,13 +11,15 @@ static bool testIdle() 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 cb = [](uv_idle_t* handle) { auto idledPtr = static_cast(handle->data); *idledPtr = true; uv_idle_stop(handle); - }); + }; + + cm::uv_idle_ptr idle; + idle.init(*loop, &idled); + uv_idle_start(idle, cb); uv_run(loop, UV_RUN_DEFAULT); if (!idled) { -- cgit v0.12