Skip to content

Commit a63726c

Browse files
Merge pull request #7 from connectivecpp/develop
Merge Develop to Main
2 parents 8fd9893 + b26b70b commit a63726c

5 files changed

Lines changed: 18 additions & 26 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Asynchronous timers from Asio are relatively easy to use. However, there are no
2424

2525
The generated Doxygen documentation for `periodic_timer` is [here](https://connectivecpp.github.io/periodic-timer/).
2626

27-
## Dependencies
27+
## Library Dependencies
2828

29-
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`.
29+
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).
3030

3131
## C++ Standard
3232

cmake/download_asio_cpm.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set ( CMAKE_THREAD_PREFER_PTHREAD TRUE )
1010
set ( THREADS_PREFER_PTHREAD_FLAG TRUE )
1111
find_package ( Threads REQUIRED )
1212

13-
CPMAddPackage ( "gh:chriskohlhoff/asio#asio-1-34-0@1.34.0" )
13+
CPMAddPackage ( "gh:chriskohlhoff/asio#asio-1-36-0@1.36.0" )
1414

1515
# ASIO doesn't use CMake, we have to configure it manually. Extra notes for using on Windows:
1616
#

cmake/download_cpm.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
file(
66
DOWNLOAD
7-
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.0/CPM.cmake
7+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.42.0/CPM.cmake
88
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
99
)
1010
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target_compile_features ( periodic_timer_test PRIVATE cxx_std_20 )
1515
# add dependencies
1616
include ( ../cmake/download_cpm.cmake )
1717

18-
CPMAddPackage ( "gh:catchorg/Catch2@3.8.0" )
18+
CPMAddPackage ( "gh:catchorg/Catch2@3.11.0" )
1919

2020
set ( CMAKE_THREAD_PREFER_PTHREAD TRUE )
2121
set ( THREADS_PREFER_PTHREAD_FLAG TRUE )

test/periodic_timer_test.cpp

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void wait_util (std::chrono::milliseconds ms, wk_guard& wg, std::thread& thr) {
4747
template <typename Clock>
4848
void test_util () {
4949

50-
GIVEN ( "A clock and a duration") {
50+
SECTION ( "Setup clock and duration") {
5151

5252
asio::io_context ioc;
5353
chops::periodic_timer<Clock> timer {ioc};
@@ -56,7 +56,7 @@ void test_util () {
5656
std::thread thr([&ioc] () { ioc.run(); } );
5757
count = 0;
5858

59-
WHEN ( "The duration is 100 ms" ) {
59+
SECTION ( "100 ms duration" ) {
6060
auto test_dur { 100 };
6161
timer.start_duration_timer(std::chrono::milliseconds(test_dur),
6262
[] (std::error_code err, typename Clock::duration elap) {
@@ -66,11 +66,9 @@ void test_util () {
6666

6767
wait_util (std::chrono::milliseconds((Expected+1)*test_dur), wg, thr);
6868

69-
THEN ( "the timer callback count should match expected") {
70-
REQUIRE (count == Expected);
71-
}
69+
REQUIRE (count == Expected);
7270
}
73-
WHEN ( "The duration is 200 ms and the start time is 2 seconds in the future" ) {
71+
SECTION ( "200 ms duration, start time is 2 seconds in the future" ) {
7472
auto test_dur { 200 };
7573
timer.start_duration_timer(std::chrono::milliseconds(test_dur), Clock::now() + std::chrono::seconds(2),
7674
[] (std::error_code err, typename Clock::duration elap) {
@@ -80,11 +78,9 @@ void test_util () {
8078

8179
wait_util(std::chrono::milliseconds((Expected+1)*test_dur + 2000), wg, thr);
8280

83-
THEN ( "the timer callback count should match expected") {
84-
REQUIRE (count == Expected);
85-
}
81+
REQUIRE (count == Expected);
8682
}
87-
WHEN ( "The duration is 100 ms and the timer pops on timepoints" ) {
83+
SECTION ( "100 ms duration, timer pops on timepoints" ) {
8884
auto test_dur { 100 };
8985
timer.start_timepoint_timer(std::chrono::milliseconds(test_dur),
9086
[] (std::error_code err, typename Clock::duration elap) {
@@ -94,11 +90,9 @@ void test_util () {
9490

9591
wait_util (std::chrono::milliseconds((Expected+1)*test_dur), wg, thr);
9692

97-
THEN ( "the timer callback count should match expected") {
98-
REQUIRE (count == Expected);
99-
}
93+
REQUIRE (count == Expected);
10094
}
101-
WHEN ( "The duration is 200 ms and the timer pops on timepoints starting 2 seconds in the future" ) {
95+
SECTION ( "200 ms duration, timer pops on timepoints starting 2 seconds in the future" ) {
10296
auto test_dur { 200 };
10397
timer.start_timepoint_timer(std::chrono::milliseconds(test_dur), Clock::now() + std::chrono::seconds(2),
10498
[] (std::error_code err, typename Clock::duration elap) {
@@ -108,25 +102,23 @@ void test_util () {
108102

109103
wait_util(std::chrono::milliseconds((Expected+1)*test_dur + 2000), wg, thr);
110104

111-
THEN ( "the timer callback count should match expected") {
112-
REQUIRE (count == Expected);
113-
}
105+
REQUIRE (count == Expected);
114106
}
115107

116-
} // end given
108+
}
117109
}
118110

119-
SCENARIO ( "A periodic timer can be instantiated on the steady clock", "[periodic_timer] [steady_clock]" ) {
111+
TEST_CASE ( "Steady clock periodic timer", "[periodic_timer] [steady_clock]" ) {
120112

121113
test_util<std::chrono::steady_clock>();
122114

123115
}
124-
SCENARIO ( "A periodic timer can be instantiated on the system clock", "[periodic_timer] [system_clock]" ) {
116+
TEST_CASE ( "System clock periodic timer", "[periodic_timer] [system_clock]" ) {
125117

126118
test_util<std::chrono::system_clock>();
127119

128120
}
129-
SCENARIO ( "A periodic timer can be instantiated on the high resolution clock", "[periodic_timer] [high_resolution_clock]" ) {
121+
TEST_CASE ( "High resolution clock periodic timer", "[periodic_timer] [high_resolution_clock]" ) {
130122

131123
test_util<std::chrono::high_resolution_clock>();
132124

0 commit comments

Comments
 (0)