diff options
author | Jon Atack <jon@atack.com> | 2021-09-06 21:01:57 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-09-07 00:37:39 +0200 |
commit | 498b323425d960274c40472a6a847afc1982201d (patch) | |
tree | da299b7dd1a8d58f8ad248f72e3d2a45db18c3f5 /src/test | |
parent | 8d2f847ed913f15677ae978a412015ac844ffceb (diff) |
log, timer: improve BCLog::LogMsg()
- make timer code more homogeneous
- replace division with multiplication
- log if the time type is unexpected
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/logging_tests.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index e2e31c62d7..0e384f72e2 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -15,9 +15,9 @@ BOOST_FIXTURE_TEST_SUITE(logging_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(logging_timer) { SetMockTime(1); - auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg"); + auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg"); SetMockTime(2); - BOOST_CHECK_EQUAL(sec_timer.LogMsg("test secs"), "tests: test secs (1.00s)"); + BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000μs)"); SetMockTime(1); auto ms_timer = BCLog::Timer<std::chrono::milliseconds>("tests", "end_msg"); @@ -25,9 +25,14 @@ BOOST_AUTO_TEST_CASE(logging_timer) BOOST_CHECK_EQUAL(ms_timer.LogMsg("test ms"), "tests: test ms (1000.00ms)"); SetMockTime(1); - auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg"); + auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg"); SetMockTime(2); - BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000μs)"); + BOOST_CHECK_EQUAL(sec_timer.LogMsg("test secs"), "tests: test secs (1.00s)"); + + SetMockTime(1); + auto minute_timer = BCLog::Timer<std::chrono::minutes>("tests", "end_msg"); + SetMockTime(2); + BOOST_CHECK_EQUAL(minute_timer.LogMsg("test minutes"), "Error: unexpected time type"); } BOOST_AUTO_TEST_SUITE_END() |