19#ifndef ROOT_UNITTESTSUPPORT_H
20#define ROOT_UNITTESTSUPPORT_H
30namespace TestSupport {
95 throw std::invalid_argument(
96 "ExpectedDiagRAII::requiredDiag(): severity is none of kInfo, kWarning, kError, kSysError");
110 throw std::invalid_argument(
111 "ExpectedDiagRAII::optionalDiag(): severity is none of kInfo, kWarning, kError, kSysError");
118 static void callback(
int severity,
bool abort,
const char *location,
const char *
msg)
123 throw std::logic_error(
"ExpectedDiagRAII::callback called without an active message handler.");
127 std::cerr <<
"ROOT::TestSupport::CheckDiagsRAII: Forced to abort because of diagnostic with severity "
128 << severity <<
" in '" << location <<
"' reading '" <<
msg <<
"'\n";
134 void checkDiag(
int severity,
const char *location,
const char *
msg);
158#define ROOT_EXPECT_DIAG(diag_class, expression, where, expected_diag, match_full) \
160 using namespace ROOT::TestSupport; \
161 CheckDiagsRAII EE(diag_class, where, expected_diag, match_full); \
165#define ROOT_EXPECT_NODIAG(expression) \
167 using namespace ROOT::TestSupport; \
168 CheckDiagsRAII EE{}; \
172#define ROOT_EXPECT_ERROR(expression, where, expected_diag) \
173 ROOT_EXPECT_DIAG(kError, expression, where, expected_diag, true)
175#define ROOT_EXPECT_ERROR_PARTIAL(expression, where, expected_diag) \
176 ROOT_EXPECT_DIAG(kError, expression, where, expected_diag, false)
178#define ROOT_EXPECT_WARNING(expression, where, expected_diag) \
179 ROOT_EXPECT_DIAG(kWarning, expression, where, expected_diag, true)
181#define ROOT_EXPECT_WARNING_PARTIAL(expression, where, expected_diag) \
182 ROOT_EXPECT_DIAG(kWarning, expression, where, expected_diag, false)
184#define ROOT_EXPECT_INFO(expression, where, expected_diag) \
185 ROOT_EXPECT_DIAG(kInfo, expression, where, expected_diag, true)
187#define ROOT_EXPECT_INFO_PARTIAL(expression, where, expected_diag) \
188 ROOT_EXPECT_DIAG(kInfo, expression, where, expected_diag, false)
190#define ROOT_EXPECT_SYSERROR(expression, where, expected_diag) \
191 ROOT_EXPECT_DIAG(kSysError, expression, where, expected_diag, true)
193#define ROOT_EXPECT_SYSERROR_PARTIAL(expression, where, expected_diag) \
194 ROOT_EXPECT_DIAG(kSysError, expression, where, expected_diag, false)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
constexpr Int_t kSysError
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Install a ROOT diagnostic handler to analyse diagnostics.
CheckDiagsRAII(int severity, std::string inRoutine, std::string E, bool matchFullMessage=true)
Construct from ROOT's kWarning, kError, ... and strings specifying location and message.
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.
ErrorHandlerFunc_t const fOldErrorHandler
Last active handler in case handlers are nested.
void optionalDiag(int severity, std::string location, std::string message, bool matchFullMessage=true)
Register a diagnostic that can, but need not necessarily be issued.
static CheckDiagsRAII * sActiveInstance
Last active error handler function.
std::vector< Diag_t > fUnexpectedDiags
std::vector< Diag_t > fExpectedDiags
void checkDiag(int severity, const char *location, const char *msg)
Check all received diags against list of expected ones.
CheckDiagsRAII *const fOldInstance
friend std::ostream & operator<<(std::ostream &stream, Diag_t const &diag)
void requiredDiag(int severity, std::string location, std::string message, bool matchFullMessage=true)
Register a new diagnostic to check for.
CheckDiagsRAII()
Register this instance as diagnostic handler.
Allows a user function to catch and filter/analyse ROOT and cling diagnostics, e.g.
FilterDiagsRAII(ErrorHandlerFunc_t fn)
ErrorHandlerFunc_t fPrevHandler
Namespace for new ROOT classes and functions.
@ kInfo
Informational messages; used for instance for tracing.
@ kWarning
Warnings about likely unexpected behavior.