ScopedDiagnosticChecker#
Fully qualified name: usdex::test::ScopedDiagnosticChecker
-
class ScopedDiagnosticChecker#
A scoped class to capture and assert expected
TfDiagnostics
andTfErrorMarks
for use in adoctest
suite.Construct a
ScopedDiagnosticChecker
and a list of expected diagnostic messages.Each
DiagnosticPattern
must contain:One
TfDiagnosticType
(e.gTF_DIAGNOSTIC_STATUS_TYPE
)A regex pattern matching the expected diagnostic commentary (message)
On context exit, the
ScopedDiagnosticChecker
will assert that all expectedTfDiagnostics
andTfErrorMarks
were 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
TfErrorMarks
will 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
TfDiagnosticTypes
andstd::regex
compliant match patterns.
Public Functions
-
ScopedDiagnosticChecker() = default#
Construct a default
ScopedDiagnosticChecker
to assert that noTfDiagnostics
orTfErrorMarks
are emitted.
-
inline ScopedDiagnosticChecker(DiagnosticPatterns expected)#
Construct a
ScopedDiagnosticChecker
with a vector of expectedDiagnosticPattern
pairs.
-
inline ~ScopedDiagnosticChecker()#
On destruction the
ScopedDiagnosticChecker
will assert the expectedTfDiagnostics
andTfErrorMarks
were emitted using doctestCHECK