|
C++Spec 1.1.0
BDD testing for C++
|
A helper base class that assists in pretty-printing various objects. More...
#include <pretty_matchers.hpp>

Public Member Functions | |
| std::string | name (const std::string &name) const |
| std::string | name_to_sentence (const std::string &name) const |
| template<typename O> | |
| std::string | inspect_object (const O &o) |
| Generate a string of the class and data of an object. | |
Static Public Member Functions | |
| static std::string | split_words (const std::string &sym) |
| static std::string | underscore (const std::string &camel_cased_word) |
| static std::string | last (const std::string &s, char delim) |
| static std::string | improve_hash_formatting (const std::string &inspect_string) |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| Formats an object as a string when operator<< is available. | |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| template<typename T> | |
| static std::string | to_word (const T &item) |
| template<typename T> | |
| static std::string | to_word (const std::optional< T > &item) |
| Formats an optional as its value, or std::nullopt when it holds none. | |
| template<typename T> | |
| static std::string | to_word_type (const T &item) |
| template<typename A, typename E> | |
| static std::string | to_word (const Matchers::MatcherBase< A, E > &matcher) |
| template<class T> | |
| static std::string | to_sentence (const T &item) |
| Take a single object and format it as a sentance. | |
| template<class T> | |
| static std::string | to_sentence (const std::vector< T > &words) |
| template<typename T> | |
| static std::string | inspect_object (const T &object) |
| static std::string | address_of (const void *address) |
| Formats an address as 0x and lowercase hex digits, the same on every platform. | |
| template<> | |
| std::string | to_word (const bool &item) |
| template<> | |
| std::string | to_word (const unsigned char &item) |
| template<> | |
| std::string | to_word (const signed char &item) |
Public Attributes | |
| std::string | _name |
A helper base class that assists in pretty-printing various objects.
This class provides helper string manipulation functions that are used to generate human-readable information and output.
|
inlinestatic |
Formats an address as 0x and lowercase hex digits, the same on every platform.
std::ostream prints a pointer in the platform's p form, which on MSVC has no 0x and uppercase digits.
| address | the address to be processed |
|
inline |
Generate a string of the class and data of an object.
| o | the object to inspect |
|
inlinestatic |
Takes a vector of objects and formats them as an English style list (i.e. "a, b, and c")
| words | the collection of objects to be processed |
|
inlinestatic |
Take a single object and format it as a sentance.
| item | the object to be processed |
|
inlinestatic |
Formats a Matcher as a string
Unlike the generic to_word(), this is specialized for Matchers, which have a custom description associated with them for better information.
| matcher | the matcher to process |
|
inlinestatic |
Formats an optional as its value, or std::nullopt when it holds none.
An optional that holds another optional wraps the value it holds, so it reads apart from an empty one: std::optional(std::nullopt) against std::nullopt.
| item | the optional to be processed |
|
inlinestatic |
Formats an object as a string when operator<< is available.
Formats an enum that has no operator<< as its type and underlying value as a number, e.g. Colour(2).
Formats a container, pair or tuple whose elements Pretty prints differently from operator<<, element by element through to_word().
Formats a pointer to signed char, unsigned char or a wide character as an address, or nullptr.
Formats a wide character (wchar_t, char8_t, char16_t or char32_t) as the number of its code unit.
Formats an object as a string when there is no operator<<.
In reality, this uses the << operator, simply providing a way to convert the object to a string without having to deal with stringstreams.
| item | the object to be processed |
| item | the object to be processed |
std::ostream has no operator<< for these, so they are printed as numbers, like byte-sized integers.
| item | the character to be processed |
Only a char pointer is read as text. These point at bytes or code units, which std::ostream would otherwise read up to a NUL (signed and unsigned char) or not print at all (wide characters).
| item | the pointer to be processed |
The container keeps cxx-prettyprint's delimiters ([1, 2], {1, 2} for a set, (1, 2) for a pair or tuple), so only the elements read differently: std::vector<std::uint8_t>{65, 66} prints [65, 66], not [A, B].
| item | the container, pair or tuple to be processed |
The value is widened to the largest integer of its signedness first, so an enum based on a character type prints a number too, not a character.
| item | the enumerator to be processed |