Hegel 0.18.3
Property-based testing for C++
Loading...
Searching...
No Matches
random.h
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <memory>
6#include <optional>
7#include <random>
8
9#include "hegel/core.h"
10#include "hegel/generators/numeric.h"
11
12namespace hegel::generators {
13
19 false;
24 };
25
50 public:
52 using result_type = uint32_t;
53
64 HegelRandom(const TestCase& tc, Printer consumed);
65
74 explicit HegelRandom(uint64_t seed);
75
76 static constexpr result_type min() {
77 return std::numeric_limits<result_type>::min();
78 }
79
80 static constexpr result_type max() {
81 return std::numeric_limits<result_type>::max();
82 }
83
85 result_type operator()();
87
88 private:
89 struct Record {
90 Printer consumed = Printer::noop();
91 bool live = false;
92 std::size_t count = 0;
93 };
94
95 const TestCase* tc_ = nullptr;
96 std::optional<std::mt19937> engine_;
97 std::shared_ptr<Record> record_ = std::make_shared<Record>();
98 };
99
102
135
137
138} // namespace hegel::generators
Writes to the document that a failure report shows.
Definition printer.h:55
static Printer noop()
A printer that discards everything.
Handle to the currently-executing test case.
Definition test_case.h:46
A printable generator: TestCase::draw() accepts it.
Definition core.h:470
A random engine whose values Hegel generates.
Definition random.h:49
Hegel generators.
Definition core.h:25
Generator< HegelRandom > randoms(RandomsParams params={})
Generate random number generators.
Parameters for randoms() generator.
Definition random.h:17
bool use_true_random
Definition random.h:18