|
Hegel 0.18.2
Property-based testing for C++
|
The interface of a printable generator: one that can print what it draws, as it draws it. More...
#include <core.h>
Public Member Functions | |
| virtual T | do_draw_and_print (const TestCase &tc, Printer &printer) const =0 |
Draw a value and print it to printer. | |
| T | do_draw (const TestCase &tc) const override |
| Draw a value without printing it. | |
| virtual T | do_draw_filtered_and_print (const TestCase &tc, const std::function< bool(const T &)> &predicate, Printer &printer) const |
Draw a value that predicate accepts and print it, for filter(). | |
| Public Member Functions inherited from hegel::generators::IGenerator< T > | |
| virtual uint64_t | label () const |
| The label that identifies this generator to the engine. | |
| virtual T | do_draw_filtered (const TestCase &tc, const std::function< bool(const T &)> &predicate) const |
Draw a value that predicate accepts, for filter(). | |
Additional Inherited Members | |
| Public Types inherited from hegel::generators::IGenerator< T > | |
| using | value_type = T |
| The type of value this generator makes. | |
The interface of a printable generator: one that can print what it draws, as it draws it.
A printable generator writes the C++ representation of its value to a Printer while it draws. TestCase::draw() calls do_draw_and_print() with the printer of the failure report, so the report says what was drawn. A container prints each element as the element generator prints it, so printing that one generator chooses shows inside every value built from it.
Implement do_draw_and_print() only: do_draw() calls it with Printer::noop(), so the silent draw and the printed draw make the same choices. Draw other generators with TestCase::draw_and_print() (a printable generator) or TestCase::draw_silent().
| T | The type of value the generator makes |
|
inlineoverridevirtual |
Draw a value without printing it.
Calls do_draw_and_print() with Printer::noop().
| tc | The test case to draw from. |
Implements hegel::generators::IGenerator< T >.
|
pure virtual |
Draw a value and print it to printer.
Must make the same draws as do_draw().
| tc | The test case to draw from. |
| printer | The printer to write the value's representation to. |
|
inlinevirtual |
Draw a value that predicate accepts and print it, for filter().
Makes the same attempts as IGenerator::do_draw_filtered(), each in a speculative region of printer that is kept only for the accepted value.
| tc | The test case to draw from. |
| predicate | The condition the value must satisfy. |
| printer | The printer to write the value's representation to. |