Hegel 0.18.2
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::Document Class Reference

A document of its own, outside a test case. More...

#include <printer.h>

Public Member Functions

 Document (std::size_t max_width=79)
 Make an empty document.
 Document (const Document &)=delete
Document & operator= (const Document &)=delete
Printer & printer ()
 The printer that writes to this document.
std::string finish () &&
 Lay out the document and return it.

Detailed Description

A document of its own, outside a test case.

Use it to check what a printing function writes.

hegel::Document document(20);
document.printer().repr(std::vector<int>{1, 2});
std::string out = std::move(document).finish();
// std::vector<int>{1, 2}
A document of its own, outside a test case.
Definition printer.h:326

Constructor & Destructor Documentation

◆ Document()

hegel::Document::Document ( std::size_t max_width = 79)
explicit

Make an empty document.

Parameters
max_widthThe width the engine lays the document out in.
Exceptions
std::runtime_errorif max_width is 0.

Member Function Documentation

◆ finish()

std::string hegel::Document::finish ( ) &&

Lay out the document and return it.

Later writes to the document's printers are discarded.

Returns
The text of the document.

◆ printer()

Printer & hegel::Document::printer ( )
inline

The printer that writes to this document.

Returns
The document's printer.

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