C++Spec 1.1.0
BDD testing for C++
Loading...
Searching...
No Matches
CppSpec::Matchers::MatcherBase< Actual, Expected > Class Template Referenceabstract

the base class for all Matcher classes and objects More...

#include <matcher_base.hpp>

Inheritance diagram for CppSpec::Matchers::MatcherBase< Actual, Expected >:
Collaboration diagram for CppSpec::Matchers::MatcherBase< Actual, Expected >:

Public Types

using expected_t = Expected

Public Member Functions

 MatcherBase (MatcherBase< Actual, Expected > const &copy)=default
 MatcherBase (Expectation< Actual > &expectation)
 MatcherBase (Expectation< Actual > &expectation, Expected expected)
virtual std::string failure_message ()
 Get the matcher's own message for a failed match; the handler puts any custom message above it.
virtual std::string failure_message_when_negated ()
 Get the matcher's own message for a failed negated match; the handler puts any custom message above it.
virtual std::string description ()
 Get the description of the Matcher.
virtual std::string verb ()
constexpr Actual & actual ()
Expected & expected ()
Expectation< Actual > & expectation ()
virtual MatcherBase & set_message (std::string message)
 Set a custom failure message.
std::string full_failure_message ()
 What a failed match reports: the custom message, when one was set, on the line above the matcher's own failure_message().
std::string full_failure_message_when_negated ()
 What a failed negated match reports: the custom message, when one was set, on the line above the matcher's own failure_message_when_negated().
std::source_location get_location () const
Result run ()
 Run the Matcher object.
virtual bool match ()=0
virtual bool negated_match ()
Public Member Functions inherited from CppSpec::Pretty
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 Attributes

static constexpr std::string_view empty_failure_message
 What a failure reports in place of a matcher's own message that is empty.

Protected Attributes

Expected expected_
Expectation< Actual > & expectation_

Additional Inherited Members

Static Public Member Functions inherited from CppSpec::Pretty
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 inherited from CppSpec::Pretty
std::string _name

Detailed Description

template<typename Actual, typename Expected>
class CppSpec::Matchers::MatcherBase< Actual, Expected >

the base class for all Matcher classes and objects

Template Parameters
Actualthe type of Actual 'thing' to match against in the context of expect(2), it would be int
Expectedthe type of Expected 'thing' to match for in the contet of expect(2).to_equal(2.0), it would be float

Member Function Documentation

◆ description()

◆ failure_message()

◆ failure_message_when_negated()

◆ run()

template<typename A, typename E>
Result CppSpec::Matchers::MatcherBase< A, E >::run ( )

Run the Matcher object.

Parameters
printerthe formatter to print using
Returns
the Result of running the Matcher

◆ set_message()

template<typename A, typename E>
MatcherBase< A, E > & CppSpec::Matchers::MatcherBase< A, E >::set_message ( std::string message)
virtual

Set a custom failure message.

Parameters
messagethe message to give
Returns
the modified Matcher

Member Data Documentation

◆ empty_failure_message

template<typename Actual, typename Expected>
std::string_view CppSpec::Matchers::MatcherBase< Actual, Expected >::empty_failure_message
staticconstexpr
Initial value:
=
"Failure message is empty. Does your matcher define the appropriate failure_message[_when_negated] method to "
"return a string?"

What a failure reports in place of a matcher's own message that is empty.


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