C++Spec 1.1.0
BDD testing for C++
Loading...
Searching...
No Matches
CppSpec::Matchers::Match< A > Class Template Reference

The match matcher: the whole of the actual text matches a regular expression. More...

#include <match.hpp>

Inheritance diagram for CppSpec::Matchers::Match< A >:
Collaboration diagram for CppSpec::Matchers::Match< A >:

Public Member Functions

template<Util::is_string_like T>
 Match (Expectation< A > &expectation, const T &expected)
 Match (Expectation< A > &expectation, std::regex expected)
std::string verb () override
std::string description () override
 Get the description of the Matcher.
std::string failure_message () override
 Get the matcher's own message for a failed match; the handler puts any custom message above it.
std::string failure_message_when_negated () override
 Get the matcher's own message for a failed negated match; the handler puts any custom message above it.
bool match () override
bool negated_match () override
Public Member Functions inherited from CppSpec::Matchers::MatcherBase< A, std::regex >
 MatcherBase (MatcherBase< A, std::regex > const &copy)=default
constexpr A & actual ()
std::regex & expected ()
Expectation< A > & 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.
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.

Additional Inherited Members

Public Types inherited from CppSpec::Matchers::MatcherBase< A, std::regex >
using expected_t
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
Static Public Attributes inherited from CppSpec::Matchers::MatcherBase< A, std::regex >
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 inherited from CppSpec::Matchers::MatcherBase< A, std::regex >
std::regex expected_
Expectation< A > & expectation_

Detailed Description

template<Util::is_string_like A>
class CppSpec::Matchers::Match< A >

The match matcher: the whole of the actual text matches a regular expression.

The actual text is read through string_view_of(). A null C string, as the actual text or as the pattern, is no text, so the matcher fails it negated as well as positive.

Template Parameters
Athe type of the actual value

Member Function Documentation

◆ description()

template<Util::is_string_like A>
std::string CppSpec::Matchers::Match< A >::description ( )
inlineoverridevirtual

Get the description of the Matcher.

Returns
the description

Reimplemented from CppSpec::Matchers::MatcherBase< A, std::regex >.

◆ failure_message()

template<Util::is_string_like A>
std::string CppSpec::Matchers::Match< A >::failure_message ( )
inlineoverridevirtual

Get the matcher's own message for a failed match; the handler puts any custom message above it.

Returns
the message

Reimplemented from CppSpec::Matchers::MatcherBase< A, std::regex >.

◆ failure_message_when_negated()

template<Util::is_string_like A>
std::string CppSpec::Matchers::Match< A >::failure_message_when_negated ( )
inlineoverridevirtual

Get the matcher's own message for a failed negated match; the handler puts any custom message above it.

Returns
the message

Reimplemented from CppSpec::Matchers::MatcherBase< A, std::regex >.

◆ match()

template<Util::is_string_like A>
bool CppSpec::Matchers::Match< A >::match ( )
inlineoverridevirtual

◆ negated_match()

template<Util::is_string_like A>
bool CppSpec::Matchers::Match< A >::negated_match ( )
inlineoverridevirtual

◆ verb()

template<Util::is_string_like A>
std::string CppSpec::Matchers::Match< A >::verb ( )
inlineoverridevirtual

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