MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_FIXTURE_TEST_CASE

Function BOOST_FIXTURE_TEST_CASE

src/test/logging_tests.cpp:113–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113BOOST_FIXTURE_TEST_CASE(logging_LogPrint, LogSetup)
114{
115 LogInstance().m_log_sourcelocations = true;
116
117 struct Case {
118 std::string msg;
119 BCLog::LogFlags category;
120 BCLog::Level level;
121 std::string prefix;
122 SourceLocation loc;
123 };
124
125 std::vector<Case> cases = {
126 {"foo1: bar1", BCLog::NET, BCLog::Level::Debug, "[net] ", SourceLocation{__func__}},
127 {"foo2: bar2", BCLog::NET, BCLog::Level::Info, "[net:info] ", SourceLocation{__func__}},
128 {"foo3: bar3", BCLog::ALL, BCLog::Level::Debug, "[debug] ", SourceLocation{__func__}},
129 {"foo4: bar4", BCLog::ALL, BCLog::Level::Info, "", SourceLocation{__func__}},
130 {"foo5: bar5", BCLog::NONE, BCLog::Level::Debug, "[debug] ", SourceLocation{__func__}},
131 {"foo6: bar6", BCLog::NONE, BCLog::Level::Info, "", SourceLocation{__func__}},
132 };
133
134 std::vector<std::string> expected;
135 for (auto& [msg, category, level, prefix, loc] : cases) {
136 expected.push_back(tfm::format("[%s:%s] [%s] %s%s", util::RemovePrefix(loc.file_name(), "./"), loc.line(), loc.function_name_short(), prefix, msg));
137 LogInstance().LogPrint({.category = category, .level = level, .should_ratelimit = false, .source_loc = std::move(loc), .message = msg});
138 }
139 std::vector<std::string> log_lines{ReadDebugLogLines()};
140 BOOST_CHECK_EQUAL_COLLECTIONS(log_lines.begin(), log_lines.end(), expected.begin(), expected.end());
141}
142
143BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros, LogSetup)
144{

Callers

nothing calls this directly

Calls 15

RemovePrefixFunction · 0.85
ReadDebugLogLinesFunction · 0.85
SplitStringFunction · 0.85
TrimStringFunction · 0.85
ResetLoggerFunction · 0.85
SetLoggingLevelFunction · 0.85
TestLogFromLocationFunction · 0.85
file_nameMethod · 0.80
lineMethod · 0.80
function_name_shortMethod · 0.80
LogPrintMethod · 0.80
EnableCategoryMethod · 0.80

Tested by

no test coverage detected