diff --git a/README.md b/README.md index 39897df..e33a649 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ 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`. +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 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 ) 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();