10namespace CppSpec::Matchers {
22template <
typename A,
typename E>
23 requires Util::compares_start_and_end<A, E>
24class EndWith :
public MatcherBase<A, E> {
43 if constexpr (compares_text) {
46 A& actual = this->actual();
47 auto compare_with = [&actual](
const auto&
expected) {
50 return std::ranges::distance(
expected) <= std::ranges::distance(actual) &&
51 std::equal(std::ranges::rbegin(
expected), std::ranges::rend(
expected), std::ranges::rbegin(actual));
56 return compare_with(this->
expected());
62 EndWith(
Expectation<A>& expectation, E start) : MatcherBase<A, E>(expectation, start) {}
64 std::string verb()
override {
return "end with"; }
74 bool match()
override {
return has_values() && compare(); }
75 bool negated_match()
override {
return has_values() && !compare(); }
Wraps the target of an expectation.
Definition expectation.hpp:48
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 i...
Definition end_with.hpp:69
std::string failure_message() override
Get the matcher's own message for a failed match; the handler puts any custom message above it.
Definition end_with.hpp:65
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 i...
Definition matcher_base.hpp:190
virtual std::string failure_message()
Get the matcher's own message for a failed match; the handler puts any custom message above it.
Definition matcher_base.hpp:180
Definition have_error.hpp:9
Checks whether T is text that CppSpec::string_view_of() can view: a C string, or a type that converts...
Definition util.hpp:201
Contains the base class for all Matchers.
std::string no_text_to_search(const A &actual)
The line a matcher that searches text puts below its own message when the actual value is a null C st...
Definition matcher_base.hpp:35
std::string no_text_to_look_for(const E &expected)
The line nothing_to_look_for when the expected value is a null C string.
Definition matcher_base.hpp:57
constexpr std::optional< std::string_view > string_view_of(const T &text)
View text as a std::string_view, the one form the string matchers and the printer compare and print.
Definition util.hpp:337