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. | |
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. | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, Diag_t const &diag) |
#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 101 of file TestSupport.cxx.
|
inlinestaticprivate |
Message handler that hands over all diagnostics to the currently active instance.
Definition at line 115 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 119 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.
|
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.
|
friend |
Definition at line 138 of file TestSupport.cxx.
|
private |
Definition at line 142 of file TestSupport.hxx.
|
private |
Last active handler in case handlers are nested.
Definition at line 146 of file TestSupport.hxx.
|
private |
Definition at line 145 of file TestSupport.hxx.
|
private |
Definition at line 143 of file TestSupport.hxx.
|
staticprivate |
Last active error handler function.
Definition at line 148 of file TestSupport.hxx.