From a41c9ccf1a216b4ad8aac8036351e538b0811881 Mon Sep 17 00:00:00 2001 From: cliffg-softwarelibre Date: Sat, 19 Apr 2025 11:48:00 -0600 Subject: [PATCH 1/4] README doc tweaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39897df..94a9ba0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Asynchronous timers from Asio are relatively easy to use. However, there are no The generated Doxygen documentation for `periodic_timer` is [here](https://connectivecpp.github.io/periodic-timer/). -## Dependencies +## Library Dependencies The `periodic_timer` header file has the stand-alone Asio library for a dependency. Specific version (or branch) specs for the Asio dependency is in `cmake/download_asio_cpm.cmake`. From 21cce0271fb4bce77b6a2fe54df2f1eb831a8b6c Mon Sep 17 00:00:00 2001 From: cliffg-softwarelibre Date: Sat, 19 Apr 2025 12:03:31 -0600 Subject: [PATCH 2/4] README doc tweaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 94a9ba0..e33a649 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The generated Doxygen documentation for `periodic_timer` is [here](https://conne ## Library Dependencies -The `periodic_timer` header file has the stand-alone Asio library for a dependency. Specific version (or branch) specs for the Asio dependency is in `cmake/download_asio_cpm.cmake`. +The `periodic_timer` header file has the stand-alone Asio library for a dependency. Specific version (or branch) specs for the Asio dependency is in [`cmake/download_asio_cpm.cmake`](cmake/download_asio_cpm.cmake). ## C++ Standard From c931b0a4f359cc9ec4056a0de7bd6c38e6936763 Mon Sep 17 00:00:00 2001 From: cliffg-softwarelibre Date: Mon, 5 May 2025 11:38:59 -0600 Subject: [PATCH 3/4] Converting BDD tests to traditional --- test/periodic_timer_test.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/test/periodic_timer_test.cpp b/test/periodic_timer_test.cpp index 66bce16..2df689a 100644 --- a/test/periodic_timer_test.cpp +++ b/test/periodic_timer_test.cpp @@ -47,7 +47,7 @@ void wait_util (std::chrono::milliseconds ms, wk_guard& wg, std::thread& thr) { template void test_util () { - GIVEN ( "A clock and a duration") { + SECTION ( "Setup clock and duration") { asio::io_context ioc; chops::periodic_timer timer {ioc}; @@ -56,7 +56,7 @@ void test_util () { std::thread thr([&ioc] () { ioc.run(); } ); count = 0; - WHEN ( "The duration is 100 ms" ) { + SECTION ( "100 ms duration" ) { auto test_dur { 100 }; timer.start_duration_timer(std::chrono::milliseconds(test_dur), [] (std::error_code err, typename Clock::duration elap) { @@ -66,11 +66,9 @@ void test_util () { wait_util (std::chrono::milliseconds((Expected+1)*test_dur), wg, thr); - THEN ( "the timer callback count should match expected") { - REQUIRE (count == Expected); - } + REQUIRE (count == Expected); } - WHEN ( "The duration is 200 ms and the start time is 2 seconds in the future" ) { + SECTION ( "200 ms duration, start time is 2 seconds in the future" ) { auto test_dur { 200 }; timer.start_duration_timer(std::chrono::milliseconds(test_dur), Clock::now() + std::chrono::seconds(2), [] (std::error_code err, typename Clock::duration elap) { @@ -80,11 +78,9 @@ void test_util () { wait_util(std::chrono::milliseconds((Expected+1)*test_dur + 2000), wg, thr); - THEN ( "the timer callback count should match expected") { - REQUIRE (count == Expected); - } + REQUIRE (count == Expected); } - WHEN ( "The duration is 100 ms and the timer pops on timepoints" ) { + SECTION ( "100 ms duration, timer pops on timepoints" ) { auto test_dur { 100 }; timer.start_timepoint_timer(std::chrono::milliseconds(test_dur), [] (std::error_code err, typename Clock::duration elap) { @@ -94,11 +90,9 @@ void test_util () { wait_util (std::chrono::milliseconds((Expected+1)*test_dur), wg, thr); - THEN ( "the timer callback count should match expected") { - REQUIRE (count == Expected); - } + REQUIRE (count == Expected); } - WHEN ( "The duration is 200 ms and the timer pops on timepoints starting 2 seconds in the future" ) { + SECTION ( "200 ms duration, timer pops on timepoints starting 2 seconds in the future" ) { auto test_dur { 200 }; timer.start_timepoint_timer(std::chrono::milliseconds(test_dur), Clock::now() + std::chrono::seconds(2), [] (std::error_code err, typename Clock::duration elap) { @@ -108,25 +102,23 @@ void test_util () { wait_util(std::chrono::milliseconds((Expected+1)*test_dur + 2000), wg, thr); - THEN ( "the timer callback count should match expected") { - REQUIRE (count == Expected); - } + REQUIRE (count == Expected); } - } // end given + } } -SCENARIO ( "A periodic timer can be instantiated on the steady clock", "[periodic_timer] [steady_clock]" ) { +TEST_CASE ( "Steady clock periodic timer", "[periodic_timer] [steady_clock]" ) { test_util(); } -SCENARIO ( "A periodic timer can be instantiated on the system clock", "[periodic_timer] [system_clock]" ) { +TEST_CASE ( "System clock periodic timer", "[periodic_timer] [system_clock]" ) { test_util(); } -SCENARIO ( "A periodic timer can be instantiated on the high resolution clock", "[periodic_timer] [high_resolution_clock]" ) { +TEST_CASE ( "High resolution clock periodic timer", "[periodic_timer] [high_resolution_clock]" ) { test_util(); From b26b70b9db1f42692c681085788617a8a641f5a5 Mon Sep 17 00:00:00 2001 From: cliffg-softwarelibre Date: Fri, 12 Dec 2025 14:20:53 -0700 Subject: [PATCH 4/4] Updated Asio, CPM, and Catch2 --- cmake/download_asio_cpm.cmake | 2 +- cmake/download_cpm.cmake | 2 +- test/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/download_asio_cpm.cmake b/cmake/download_asio_cpm.cmake index 93df15b..c4c6f3d 100644 --- a/cmake/download_asio_cpm.cmake +++ b/cmake/download_asio_cpm.cmake @@ -10,7 +10,7 @@ set ( CMAKE_THREAD_PREFER_PTHREAD TRUE ) set ( THREADS_PREFER_PTHREAD_FLAG TRUE ) find_package ( Threads REQUIRED ) -CPMAddPackage ( "gh:chriskohlhoff/asio#asio-1-34-0@1.34.0" ) +CPMAddPackage ( "gh:chriskohlhoff/asio#asio-1-36-0@1.36.0" ) # ASIO doesn't use CMake, we have to configure it manually. Extra notes for using on Windows: # diff --git a/cmake/download_cpm.cmake b/cmake/download_cpm.cmake index dd69ebe..6d7718c 100644 --- a/cmake/download_cpm.cmake +++ b/cmake/download_cpm.cmake @@ -4,7 +4,7 @@ file( DOWNLOAD - https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.0/CPM.cmake + https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.42.0/CPM.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake ) include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 056a092..e7b95b2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,7 +15,7 @@ target_compile_features ( periodic_timer_test PRIVATE cxx_std_20 ) # add dependencies include ( ../cmake/download_cpm.cmake ) -CPMAddPackage ( "gh:catchorg/Catch2@3.8.0" ) +CPMAddPackage ( "gh:catchorg/Catch2@3.11.0" ) set ( CMAKE_THREAD_PREFER_PTHREAD TRUE ) set ( THREADS_PREFER_PTHREAD_FLAG TRUE )