From 6a3d632f40a1882cb09aeefa767f0fdf1f61c80e Mon Sep 17 00:00:00 2001 From: misterg Date: Mon, 26 Aug 2019 14:31:27 -0400 Subject: Googletest export Add tuple version of Optional() matches. This allows Optional() to be used in Pointwise matchers. PiperOrigin-RevId: 265501882 --- googlemock/include/gmock/gmock-matchers.h | 51 +------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) (limited to 'googlemock/include/gmock') diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 40e0452f..b1c0dc04 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3239,16 +3239,10 @@ class OptionalMatcher { : value_matcher_(value_matcher) {} template - operator Matcher() const { // NOLINT + operator Matcher() const { return Matcher(new Impl(value_matcher_)); } - template - operator Matcher>() const { // NOLINT - return MakeMatcher( - new PairImpl(value_matcher_)); - } - template class Impl : public MatcherInterface { public: @@ -3287,49 +3281,6 @@ class OptionalMatcher { GTEST_DISALLOW_ASSIGN_(Impl); }; - template - class PairImpl : public MatcherInterface> { - public: - typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Optional1) Optional1View; - typedef typename Optional1View::value_type ValueType1; - typedef std::tuple OptionalTuple; - typedef std::tuple ValuePair; - - explicit PairImpl(const ValueMatcher& value_matcher) - : value_matcher_(MatcherCast(value_matcher)) {} - - void DescribeTo(::std::ostream* os) const override { - *os << "are optionals where the values "; - value_matcher_.DescribeTo(os); - } - - void DescribeNegationTo(::std::ostream* os) const override { - *os << "are optionals where the values "; - value_matcher_.DescribeNegationTo(os); - } - - bool MatchAndExplain(OptionalTuple optional_tuple, - MatchResultListener* listener) const override { - const auto& optional1 = std::get<0>(optional_tuple); - const auto& value2 = std::get<1>(optional_tuple); - if (!optional1) { - *listener << "left is nullopt"; - return false; - } - const ValueType1& value1 = *optional1; - StringMatchResultListener value_listener; - const bool match = value_matcher_.MatchAndExplain( - std::make_tuple(value1, value2), &value_listener); - *listener << (match ? "which match" : "whose values don't match"); - PrintIfNotEmpty(value_listener.str(), listener->stream()); - return match; - } - - private: - const Matcher value_matcher_; - GTEST_DISALLOW_ASSIGN_(PairImpl); - }; - private: const ValueMatcher value_matcher_; GTEST_DISALLOW_ASSIGN_(OptionalMatcher); -- cgit v1.2.3