Hegel 0.3.5
Property-based testing for C++
Loading...
Searching...
No Matches
test_case.h
1#pragma once
2
3#include <string_view>
4
5namespace hegel::impl::test_case {
6 struct TestCaseData;
7}
8
9namespace hegel::generators {
10 template <typename T> class Generator;
11}
12
13namespace hegel {
14
34 class TestCase {
35 public:
36 TestCase(const TestCase&) = delete;
37 TestCase& operator=(const TestCase&) = delete;
38 TestCase(TestCase&&) = delete;
39 TestCase& operator=(TestCase&&) = delete;
40
48 template <typename T> T draw(const generators::Generator<T>& gen) const;
49
62 void assume(bool condition) const;
63
70 void note(std::string_view message) const;
71
73 explicit TestCase(impl::test_case::TestCaseData* data) : data_(data) {}
74
75 // Generators reach through this accessor to talk to the backend.
76 // Not part of the user-facing API.
77 impl::test_case::TestCaseData* data() const { return data_; }
79
80 private:
81 impl::test_case::TestCaseData* data_;
82 };
83
84} // namespace hegel
void assume(bool condition) const
Reject the current test case if condition is false.
void note(std::string_view message) const
Record a message that will be printed on the final replay of a failing test case.
T draw(const generators::Generator< T > &gen) const
Draw a random value from a generator.
Definition core.h:371
The base class of all generators.
Definition core.h:157
Hegel generators.
Definition core.h:16
Main namespace.
Definition core.h:16