Add option to skip forward to the generator interface

This commit is contained in:
Martin Hořeňovský
2025-10-06 11:47:38 +02:00
parent 363ca5af18
commit fecf606a05
22 changed files with 353 additions and 19 deletions

View File

@@ -252,9 +252,23 @@ struct IGenerator : GeneratorUntypedBase {
// Returns user-friendly string showing the current generator element
// Does not have to be overridden, IGenerator provides default implementation
virtual std::string stringifyImpl() const;
/**
* Customization point for `skipToNthElement`
*
* Does not have to be overridden, there is a default implementation.
* Can be overridden for better performance.
*
* If there are not enough elements, shall throw an error.
*
* Going backwards is not supported.
*/
virtual void skipToNthElementImpl( std::size_t n );
};
```
> `skipToNthElementImpl` 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