| 249 | } |
| 250 | |
| 251 | bool MatchAndExplain(const Res& maybe_value, |
| 252 | testing::MatchResultListener* listener) const override { |
| 253 | const Status& status = ToStatus(maybe_value); |
| 254 | testing::StringMatchResultListener value_listener; |
| 255 | |
| 256 | bool match = status.code() == code_; |
| 257 | if (message_matcher_) { |
| 258 | match = match && |
| 259 | message_matcher_->MatchAndExplain(status.message(), &value_listener); |
| 260 | } |
| 261 | |
| 262 | if (match) { |
| 263 | *listener << "whose error matches"; |
| 264 | } else if (status.ok()) { |
| 265 | *listener << "whose non-error doesn't match"; |
| 266 | } else { |
| 267 | *listener << "whose error doesn't match"; |
| 268 | } |
| 269 | |
| 270 | testing::internal::PrintIfNotEmpty(value_listener.str(), listener->stream()); |
| 271 | return match; |
| 272 | } |
| 273 | |
| 274 | const StatusCode code_; |
| 275 | const std::optional<testing::Matcher<std::string>> message_matcher_; |
nothing calls this directly
no test coverage detected