Install a ROOT diagnostic handler to analyse diagnostics.
It will record all diagnostics during its lifetime, and analyse them at destruction. Required and/or optional diagnostics need to be predefined with expected location and message. Unexpected or missing diagnostics will lead to gtest failures.
Example:
Definition at line 65 of file TestSupport.hxx.
Classes | |
struct | Diag_t |
Public Member Functions | |
CheckDiagsRAII () | |
Register this instance as diagnostic handler. | |
CheckDiagsRAII (int severity, std::string inRoutine, std::string E) | |
Construct from ROOT's kWarning, kError, ... and strings specifying location and message. | |
~CheckDiagsRAII () | |
void | optionalDiag (int severity, std::string location, std::string message, bool matchFullMessage=true) |
Register a diagnostic that can, but need not necessarily be issued. | |
void | requiredDiag (int severity, std::string location, std::string message, bool matchFullMessage=true) |
Register a new diagnostic to check for. | |
Private Member Functions | |
void | checkDiag (int severity, const char *location, const char *msg) |
Check all received diags against list of expected ones. | |
void | printDiags (std::vector< Diag_t > const &diags) const |
Print the diags in diags to the terminal. | |
Static Private Member Functions | |
static void | callback (int severity, bool abort, const char *location, const char *msg) |
Message handler that hands over all diagnostics to the currently active instance. | |
Private Attributes | |
std::vector< Diag_t > | fExpectedDiags |
ErrorHandlerFunc_t const | fOldErrorHandler |
Last active handler in case handlers are nested. | |
CheckDiagsRAII *const | fOldInstance |
std::vector< Diag_t > | fUnexpectedDiags |
Static Private Attributes | |
static CheckDiagsRAII * | sActiveInstance = nullptr |
Last active error handler function. | |
#include <ROOT/TestSupport.hxx>
|
inline |
Register this instance as diagnostic handler.
With no further action, any diagnostic will lead to a test failure.
Definition at line 69 of file TestSupport.hxx.
|
inline |
Construct from ROOT's kWarning, kError, ...
and strings specifying location and message.
Definition at line 79 of file TestSupport.hxx.
ROOT::TestSupport::CheckDiagsRAII::~CheckDiagsRAII | ( | ) |
Definition at line 88 of file TestSupport.cxx.
|
inlinestaticprivate |
Message handler that hands over all diagnostics to the currently active instance.
Definition at line 124 of file TestSupport.hxx.
|
private |
Check all received diags against list of expected ones.
Search list of expected diagnostics for given arguments, and increase the receivedCount.
If no matching predefined diagnostic is found, this will trigger an unexpected diagnostic error on exit.
Definition at line 109 of file TestSupport.cxx.
|
inline |
Register a diagnostic that can, but need not necessarily be issued.
severity | One of kInfo kWarning kError kSysError. |
location | Function name where the diagnostic should be issued. |
message | Diagnostic message. |
matchFullMessage | If true, the message must be exactly identical. If false, it's sufficient that message is a substring of the diagnostic message. |
Definition at line 106 of file TestSupport.hxx.
|
private |
Print the diags in diags
to the terminal.
Definition at line 127 of file TestSupport.cxx.
|
inline |
Register a new diagnostic to check for.
severity | One of kInfo kWarning kError kSysError. |
location | Function name where the diagnostic should be issued. |
message | Diagnostic message. |
matchFullMessage | If true, the message must be exactly identical. If false, it's sufficient that message is a substring of the diagnostic message. |
Definition at line 93 of file TestSupport.hxx.
|
private |
Definition at line 143 of file TestSupport.hxx.
|
private |
Last active handler in case handlers are nested.
Definition at line 147 of file TestSupport.hxx.
|
private |
Definition at line 146 of file TestSupport.hxx.
|
private |
Definition at line 144 of file TestSupport.hxx.
|
staticprivate |
Last active error handler function.
Definition at line 149 of file TestSupport.hxx.