Check for infinite generators before we construct generator's tracker

This commit is contained in:
Martin Hořeňovský
2026-02-13 21:17:06 +01:00
parent 120827d4d6
commit 72671fdbdf
+6 -5
View File
@@ -485,6 +485,12 @@ namespace Catch {
SourceLineInfo lineInfo,
Generators::GeneratorBasePtr&& generator ) {
if ( m_config->warnAboutInfiniteGenerators() &&
!generator->isFinite() ) {
// TBD: Would it be better to expand this macro inline?
FAIL( "GENERATE() would run infinitely" );
}
auto nameAndLoc = TestCaseTracking::NameAndLocation( static_cast<std::string>( generatorName ), lineInfo );
auto& currentTracker = m_trackerContext.currentTracker();
assert(
@@ -497,11 +503,6 @@ namespace Catch {
currentTracker.addChild( CATCH_MOVE( newTracker ) );
ret->setGenerator( CATCH_MOVE( generator ) );
if ( m_config->warnAboutInfiniteGenerators() &&
!ret->getGenerator()->isFinite() ) {
// TBD: Would it be better to expand this macro inline?
FAIL( "GENERATE() would run infinitely" );
}
ret->open();
return ret;
}