LCOV - code coverage report
Current view: top level - src/test/util - logging.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 3 3 100.0 %
Date: 2022-04-21 14:51:19 Functions: 2 2 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2019-2020 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                 :            : #ifndef BITCOIN_TEST_UTIL_LOGGING_H
#       6                 :            : #define BITCOIN_TEST_UTIL_LOGGING_H
#       7                 :            : 
#       8                 :            : #include <util/macros.h>
#       9                 :            : 
#      10                 :            : #include <functional>
#      11                 :            : #include <list>
#      12                 :            : #include <string>
#      13                 :            : 
#      14                 :            : class DebugLogHelper
#      15                 :            : {
#      16                 :            :     const std::string m_message;
#      17                 :            :     bool m_found{false};
#      18                 :            :     std::list<std::function<void(const std::string&)>>::iterator m_print_connection;
#      19                 :            : 
#      20                 :            :     //! Custom match checking function.
#      21                 :            :     //!
#      22                 :            :     //! Invoked with pointers to lines containing matching strings, and with
#      23                 :            :     //! null if check_found() is called without any successful match.
#      24                 :            :     //!
#      25                 :            :     //! Can return true to enable default DebugLogHelper behavior of:
#      26                 :            :     //! (1) ending search after first successful match, and
#      27                 :            :     //! (2) raising an error in check_found if no match was found
#      28                 :            :     //! Can return false to do the opposite in either case.
#      29                 :            :     using MatchFn = std::function<bool(const std::string* line)>;
#      30                 :            :     MatchFn m_match;
#      31                 :            : 
#      32                 :            :     void check_found();
#      33                 :            : 
#      34                 :            : public:
#      35                 :         15 :     explicit DebugLogHelper(std::string message, MatchFn match = [](const std::string*){ return true; });
#      36                 :         17 :     ~DebugLogHelper() { check_found(); }
#      37                 :            : };
#      38                 :            : 
#      39                 :         15 : #define ASSERT_DEBUG_LOG(message) DebugLogHelper UNIQUE_NAME(debugloghelper)(message)
#      40                 :            : 
#      41                 :            : #endif // BITCOIN_TEST_UTIL_LOGGING_H

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a