ScopedDiagnosticChecker#
Fully qualified name: usdex::test::ScopedDiagnosticChecker
-
class ScopedDiagnosticChecker#
A scoped class to capture and assert expected
TfDiagnosticsandTfErrorMarksfor use in adoctestsuite.Construct a
ScopedDiagnosticCheckerand a list of expected diagnostic messages.Each
DiagnosticPatternmust contain:One
TfDiagnosticType(e.gTF_DIAGNOSTIC_STATUS_TYPE)A regex pattern matching the expected diagnostic commentary (message)
On context exit, the
ScopedDiagnosticCheckerwill assert that all expectedTfDiagnosticsandTfErrorMarkswere emmitted.Example:
#include <usdex/test/ScopedDiagnosticChecker.h> #include <pxr/base/tf/diagnostic.h> #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL #include <doctest/doctest.h> using namespace pxr; TEST_CASE("My Test Case") { { usdex::test::ScopedDiagnosticChecker check({ { TF_DIAGNOSTIC_WARNING_TYPE, ".*foo" } }); TF_WARN("This message ends in foo"); } }
Note
TfErrorMarkswill be diagnosed before any generalTfDiagnostics. The supplied list of expected values should account for this.Public Types
-
using DiagnosticPatterns = std::vector<std::pair<pxr::TfEnum, std::string>>#
A vector of expected
TfDiagnosticTypesandstd::regexcompliant match patterns.
Public Functions
-
ScopedDiagnosticChecker() = default#
Construct a default
ScopedDiagnosticCheckerto assert that noTfDiagnosticsorTfErrorMarksare emitted.
-
inline ScopedDiagnosticChecker(DiagnosticPatterns expected)#
Construct a
ScopedDiagnosticCheckerwith a vector of expectedDiagnosticPatternpairs.
-
inline ~ScopedDiagnosticChecker()#
On destruction the
ScopedDiagnosticCheckerwill assert the expectedTfDiagnosticsandTfErrorMarkswere emitted using doctestCHECK