88 | - SetMockTime(1);
89 | - auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
90 | - SetMockTime(2);
91 | - BOOST_CHECK_EQUAL(sec_timer.LogMsg("test secs"), "tests: test secs (1.00s)");
92 | + const std::string_view result_prefix{"tests: msg ("};
93 | + BOOST_CHECK_EQUAL(micro_timer.LogMsg("msg").substr(0, result_prefix.size()), result_prefix);
We don't need to cut all this test coverage, e.g. we can still cut the mocktime but:
- capture
auto test_start{std::chrono::steady_clock::now()} at the beginning and and ensure that LogMsg contains a duration that's longer than now() - test_start
- ensure that the different timers accurately represent s/ms/Ξs
Do you think the current timer test coverage is unnecessary?
Not sure if the goal of a unit test is to re-implement the whole function on top of fuzzy parsing? Happy to push any patch if someone writes something, though.