Skip to content

Commit 5f3a8c6

Browse files
Add Assert-Macros for the TestLogger
Also add a Clear() function to clear existing log content.
1 parent 4bd51fe commit 5f3a8c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/base-testloggerfixture.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#include <boost/test/test_tools.hpp>
1111
#include <future>
1212

13+
#define CHECK_LOG_MESSAGE(pattern, timeout) BOOST_CHECK(ExpectLogPattern(pattern, timeout))
14+
#define REQUIRE_LOG_MESSAGE(pattern, timeout) BOOST_REQUIRE(ExpectLogPattern(pattern, timeout))
15+
16+
#define CHECK_NO_LOG_MESSAGE(pattern, timeout) BOOST_CHECK(!ExpectLogPattern(pattern, timeout))
17+
#define REQUIRE_NO_LOG_MESSAGE(pattern, timeout) BOOST_REQUIRE(!ExpectLogPattern(pattern, timeout))
18+
1319
namespace icinga {
1420

1521
class TestLogger : public Logger
@@ -52,6 +58,13 @@ class TestLogger : public Logger
5258
return ret;
5359
}
5460

61+
void Clear()
62+
{
63+
std::lock_guard lock(m_Mutex);
64+
m_Expects.clear();
65+
m_LogEntries.clear();
66+
}
67+
5568
private:
5669
void ProcessLogEntry(const LogEntry& entry) override
5770
{

0 commit comments

Comments
 (0)