mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-01 01:18:02 +00:00
Catch and register startup exceptions in autoregistrars
Previously they were registered where they would be thrown otherwise
This commit is contained in:
parent
da0edcbe25
commit
860de28b8d
3 changed files with 28 additions and 41 deletions
|
@ -38,16 +38,10 @@ namespace Catch {
|
|||
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] );
|
||||
}
|
||||
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
|
||||
// Do not throw when constructing global objects, instead register the exception to be processed later
|
||||
if (isReservedTag(tag)) {
|
||||
getMutableRegistryHub().registerStartupException(
|
||||
std::make_exception_ptr(
|
||||
CATCH_PREPARE_EXCEPTION(std::domain_error, "Tag name: [" << tag << "] is not allowed.\n"
|
||||
<< "Tag names starting with non alpha-numeric characters are reserved\n"
|
||||
<< _lineInfo)
|
||||
)
|
||||
);
|
||||
}
|
||||
CATCH_ENFORCE( !isReservedTag(tag),
|
||||
"Tag name: [" << tag << "] is not allowed.\n"
|
||||
<< "Tag names starting with non alpha-numeric characters are reserved\n"
|
||||
<< _lineInfo );
|
||||
}
|
||||
|
||||
TestCase makeTestCase( ITestCase* _testCase,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue