Add --warn InfiniteGenerators

This commit is contained in:
Martin Hořeňovský committed 2026-02-10 09:37:19 +01:00
1 parent d079ee13ab
commit daadf42a0e
18 files changed
+93 -23

No files matched your search

@@ -21,7 +21,9 @@
#include <catch2/internal/catch_assertion_handler.hpp>
#include <catch2/internal/catch_test_failure_exception.hpp>
#include <catch2/internal/catch_thread_local.hpp>
#include <catch2/internal/catch_unreachable.hpp>
#include <catch2/internal/catch_result_type.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cassert>
#include <algorithm>
@@ -495,6 +497,11 @@ 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;
}