@@ -65,6 +65,7 @@ class MatcherBase : public Runnable, public Pretty {
6565 virtual std::string failure_message ();
6666 virtual std::string failure_message_when_negated ();
6767 virtual std::string description ();
68+ virtual std::string verb () { return " match" ; }
6869
6970 // Get the 'actual' object from the Expectation
7071 constexpr Actual &actual () { return expectation_.get_target (); }
@@ -113,9 +114,7 @@ std::string MatcherBase<A, E>::failure_message() {
113114 if (not custom_failure_message.empty ()) {
114115 return this ->custom_failure_message ;
115116 }
116- std::stringstream ss;
117- ss << " expected " << Pretty::to_word (actual ()) << " to " << description ();
118- return ss.str ();
117+ return std::format (" expected {} to {}" , Pretty::to_word (actual ()), description ());
119118}
120119
121120/* *
@@ -128,9 +127,7 @@ std::string MatcherBase<A, E>::failure_message_when_negated() {
128127 if (not custom_failure_message.empty ()) {
129128 return this ->custom_failure_message ;
130129 }
131- std::stringstream ss;
132- ss << " expected " << Pretty::to_word (actual ()) << " to not " << description ();
133- return ss.str ();
130+ return std::format (" expected {} to not {}" , Pretty::to_word (actual ()), description ());
134131}
135132
136133/* *
@@ -140,13 +137,11 @@ std::string MatcherBase<A, E>::failure_message_when_negated() {
140137 */
141138template <typename A, typename E>
142139std::string MatcherBase<A, E>::description() {
143- std::stringstream ss;
144- // std::string pretty_expected = this->to_sentence(expected_);
145- // ss << "match " <<
146- // this->name_to_sentence(Util::demangle(typeid(*this).name()))
147- // << "(" << pretty_expected.substr(1, pretty_expected.length()) << ")";
148- ss << " match" << Pretty::to_sentence (expected_);
149- return ss.str ();
140+ // std::string pretty_expected = this->to_sentence(expected_);
141+ // ss << "match " <<
142+ // this->name_to_sentence(Util::demangle(typeid(*this).name()))
143+ // << "(" << pretty_expected.substr(1, pretty_expected.length()) << ")";
144+ return std::format (" {} {}" , verb (), Pretty::to_sentence (expected_));
150145}
151146
152147/* *
@@ -158,15 +153,14 @@ std::string MatcherBase<A, E>::description() {
158153 */
159154template <typename A, typename E>
160155Result MatcherBase<A, E>::run(Formatters::BaseFormatter &printer) {
161- auto *par = static_cast <ItBase *>(this ->get_parent ());
156+ auto *parent = static_cast <ItBase *>(this ->get_parent ());
162157 // If we need a description for our test, generate it
163158 // unless we're ignoring the output.
164- if (par ->needs_description () && !expectation_.ignore_failure ()) {
159+ if (parent ->needs_description () && !expectation_.ignore_failure ()) {
165160 std::stringstream ss;
166161 ss << (expectation_.sign () ? PositiveExpectationHandler::verb () : NegativeExpectationHandler::verb ()) << " "
167162 << this ->description ();
168- std::string ss_str = ss.str ();
169- par->set_description (ss_str);
163+ parent->set_description (ss.str ());
170164 }
171165
172166 Result matched = expectation_.sign () ? PositiveExpectationHandler::handle_matcher (*this )
0 commit comments