Hegel 0.18.3
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::generators::HegelRandom Class Reference

A random engine whose values Hegel generates. More...

#include <random.h>

Detailed Description

A random engine whose values Hegel generates.

Satisfies the C++ UniformRandomBitGenerator named requirement, so it can be used with any <random> distribution.

A drawn HegelRandom prints the values it gives the test, as HegelRandom{.consumed = {...}}: randoms() makes a child region of the printer (Printer::deferred()) where it is drawn, and the engine writes each value there when it is used. In true-random mode it prints its seed, HegelRandom{.seed = N}.

auto rng = tc.draw("rng", gs::randoms());
std::uniform_real_distribution<double> dist(0.0, 10.0);
double uniform_value = dist(rng);
// Using true random
auto rng = tc.draw("rng", gs::randoms({ .use_true_random = true }));
std::lognormal_distribution<double> dist(0.0, 10.0);
double uniform_value = dist(rng);

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