Hegel 0.18.2
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::generators::Mapped< U, SourcePrintable > Class Template Reference

The generator that map() returns. More...

#include <core.h>

Inheritance diagram for hegel::generators::Mapped< U, SourcePrintable >:

Public Member Functions

Generator< U > print_as_call (std::string_view function) const
 Make a generator that prints a call of function with the drawn input.

Detailed Description

template<typename U, bool SourcePrintable>
class hegel::generators::Mapped< U, SourcePrintable >

The generator that map() returns.

It derives from Generator<U> when hegel::is_representable_v is true for U, and from AnyGenerator<U> otherwise, so it can be used wherever those can.

Template Parameters
UThe type of the values it makes
SourcePrintableWhether the mapped generator is printable

Member Function Documentation

◆ print_as_call()

template<typename U, bool SourcePrintable>
Generator< U > hegel::generators::Mapped< U, SourcePrintable >::print_as_call ( std::string_view function) const
inline

Make a generator that prints a call of function with the drawn input.

A map() prints the value it made. This prints the value drawn from the mapped generator instead, as that generator prints it, in a call of function, so a type with no C++ representation can be printed. The mapped generator must be printable.

auto keys = gs::integers<uint64_t>()
.map(KeyData::from_ffi)
.print_as_call("KeyData::from_ffi");
// A failure report prints `auto key = KeyData::from_ffi(3);`
Parameters
functionThe name of the mapping function.
Returns
A Generator<U>
Exceptions
std::invalid_argumentif function is empty.

The documentation for this class was generated from the following file: