|
Hegel 0.18.2
Property-based testing for C++
|
Values to run a test with before Hegel generates any. More...
#include <explicit.h>
Public Member Functions | |
| template<typename... Ts, typename = std::enable_if_t< !(std::is_same_v<std::decay_t<Ts>, ExplicitTestCase> || ...)>> | |
| ExplicitTestCase (Ts &&... values) | |
| An explicit test case with the given values. | |
Values to run a test with before Hegel generates any.
An explicit test case runs the test body once, in the Explicit phase (Phase::Explicit), before any generated test case. Each draw of the body returns a value of the explicit test case instead of a generated one: the value named for the draw (see hegel::named()), else the next positional value. Each value must have the exact type the draw produces, so write int64_t{5} for a draw of integers<int64_t>(). A string literal is a std::string.
Every value must be drawn. TestCase::target() and TestCase::event() do nothing, TestCase::repeat() runs its body once and then ends the test case, a TestCase::clone() draws the same values and names its draws in the same sequence as the test case it was cloned from, and TestCase::set_worker() does nothing. Anything else is a usage error, which makes hegel::test() throw std::invalid_argument without reporting a failure: a value that no draw takes, a draw with no value or a value of another type, a rejection (TestCase::assume() or TestCase::reject(), whose message begins "Explicit test cases must not be rejected"), and anything that needs generated data other than a draw (TestCase::draw_silent(), stateful testing).
If an explicit test case fails, Hegel prints what it drew and noted, and the test's exception propagates; no test case is generated. With Settings::report_multiple_failures, every explicit test case runs, the generated test cases follow, and every distinct failure is reported together, the explicit test cases' first.
|
inlineexplicit |
An explicit test case with the given values.
| Ts | The value types. A hegel::named() value is named, and every other value is positional. |
| values | The values, in the order the draws take the positional ones. |