LCOV - code coverage report
Current view: top level - src/test - logging_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 17 17 100.0 %
Date: 2020-09-26 01:30:44 Functions: 9 9 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2019 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include <logging.h>
       6             : #include <logging/timer.h>
       7             : #include <test/util/setup_common.h>
       8             : 
       9             : #include <chrono>
      10             : 
      11             : #include <boost/test/unit_test.hpp>
      12             : 
      13          89 : BOOST_FIXTURE_TEST_SUITE(logging_tests, BasicTestingSetup)
      14             : 
      15          95 : BOOST_AUTO_TEST_CASE(logging_timer)
      16             : {
      17             : 
      18           1 :     SetMockTime(1);
      19           1 :     auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
      20           1 :     SetMockTime(2);
      21           1 :     BOOST_CHECK_EQUAL(sec_timer.LogMsg("test secs"), "tests: test secs (1.00s)");
      22             : 
      23           1 :     SetMockTime(1);
      24           1 :     auto ms_timer = BCLog::Timer<std::chrono::milliseconds>("tests", "end_msg");
      25           1 :     SetMockTime(2);
      26           1 :     BOOST_CHECK_EQUAL(ms_timer.LogMsg("test ms"), "tests: test ms (1000.00ms)");
      27             : 
      28           1 :     SetMockTime(1);
      29           1 :     auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg");
      30           1 :     SetMockTime(2);
      31           1 :     BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000.00μs)");
      32             : 
      33           1 :     SetMockTime(0);
      34           1 : }
      35             : 
      36          89 : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.15