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:
CheckDiagsRAII diagRAII{CheckDiagsRAII::EDK_Error,
"TFile::TFile",
"<Expected message>"};
diagRAII.
optionalDiag(
kInfo,
"TFile::TFile",
"Message that is issued only sometimes");
<test code>
void optionalDiag(int severity, std::string location, std::string message, bool matchFullMessage=true)
Register a diagnostic that can, but need not necessarily be issued.
CheckDiagsRAII()
Register this instance as diagnostic handler.
Definition at line 67 of file TestSupport.hxx.
|
| | CheckDiagsRAII () |
| | Register this instance as diagnostic handler.
|
| | CheckDiagsRAII (int severity, std::string inRoutine, std::string E, bool matchFullMessage=true) |
| | 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.
|
|
| void | checkDiag (int severity, const char *location, const char *msg) |
| | Check all received diags against list of expected ones.
|
|
| 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.
|
#include <ROOT/TestSupport.hxx>
◆ CheckDiagsRAII() [1/2]
| ROOT::TestSupport::CheckDiagsRAII::CheckDiagsRAII |
( |
| ) |
|
|
inline |
Register this instance as diagnostic handler.
With no further action, any diagnostic will lead to a test failure.
Definition at line 71 of file TestSupport.hxx.
◆ CheckDiagsRAII() [2/2]
| ROOT::TestSupport::CheckDiagsRAII::CheckDiagsRAII |
( |
int | severity, |
|
|
std::string | inRoutine, |
|
|
std::string | E, |
|
|
bool | matchFullMessage = true ) |
|
inline |
Construct from ROOT's kWarning, kError, ... and strings specifying location and message.
Definition at line 79 of file TestSupport.hxx.
◆ ~CheckDiagsRAII()
| ROOT::TestSupport::CheckDiagsRAII::~CheckDiagsRAII |
( |
| ) |
|
◆ callback()
| void ROOT::TestSupport::CheckDiagsRAII::callback |
( |
int | severity, |
|
|
bool | abort, |
|
|
const char * | location, |
|
|
const char * | msg ) |
|
inlinestaticprivate |
Message handler that hands over all diagnostics to the currently active instance.
Definition at line 118 of file TestSupport.hxx.
◆ checkDiag()
| void ROOT::TestSupport::CheckDiagsRAII::checkDiag |
( |
int | severity, |
|
|
const char * | location, |
|
|
const char * | msg ) |
|
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 123 of file TestSupport.cxx.
◆ optionalDiag()
| void ROOT::TestSupport::CheckDiagsRAII::optionalDiag |
( |
int | severity, |
|
|
std::string | location, |
|
|
std::string | message, |
|
|
bool | matchFullMessage = true ) |
|
inline |
Register a diagnostic that can, but need not necessarily be issued.
- Parameters
-
| 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 107 of file TestSupport.hxx.
◆ requiredDiag()
| void ROOT::TestSupport::CheckDiagsRAII::requiredDiag |
( |
int | severity, |
|
|
std::string | location, |
|
|
std::string | message, |
|
|
bool | matchFullMessage = true ) |
|
inline |
Register a new diagnostic to check for.
- Parameters
-
| 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 92 of file TestSupport.hxx.
◆ operator<<
◆ fExpectedDiags
| std::vector<Diag_t> ROOT::TestSupport::CheckDiagsRAII::fExpectedDiags |
|
private |
◆ fOldErrorHandler
Last active handler in case handlers are nested.
Definition at line 150 of file TestSupport.hxx.
◆ fOldInstance
◆ fUnexpectedDiags
| std::vector<Diag_t> ROOT::TestSupport::CheckDiagsRAII::fUnexpectedDiags |
|
private |
◆ sActiveInstance
| CheckDiagsRAII * ROOT::TestSupport::CheckDiagsRAII::sActiveInstance = nullptr |
|
staticprivate |
The documentation for this class was generated from the following files: