Allow generators to declare themselves (infinite)

This will be useful later to implement warning on infinitely
running `GENERATE` expressions.
This commit is contained in:
Martin Hořeňovský committed 2026-02-10 09:37:15 +01:00
1 parent 0056cd4efb
commit d079ee13ab
31 files changed
+869 -18

No files matched your search

+11
View File
@@ -276,11 +276,22 @@ struct IGenerator : GeneratorUntypedBase {
* Going backwards is not supported.
*/
virtual void skipToNthElementImpl( std::size_t n );
/**
* Returns true if calls to `next` will eventually return false
*
* Note that for backwards compatibility this is currently defaulted
* to return `true`, but in the future all generators will have to
* provide their own implementation.
*/
virtual bool isFinite() const = 0;
};
```
> `skipToNthElementImpl` was added in Catch2 vX.Y.Z
> `isFinite` was added in Catch2 vX.Y.Z
However, to be able to use your custom generator inside `GENERATE`, it
will need to be wrapped inside a `GeneratorWrapper<T>`.
`GeneratorWrapper<T>` is a value wrapper around a