From 572e261b607585d7044ad3321f9530d5c14a2564 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 31 Jan 2020 12:03:06 -0500 Subject: Googletest export Fix use of reserved names. Minimize code duplication needed for explict-vs-nonexplicit constructor. PiperOrigin-RevId: 292555014 --- googlemock/test/gmock-matchers_test.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'googlemock/test') diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index c667ecbe..2bcbe5cf 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -2875,6 +2875,33 @@ TEST(ExplainMatchResultTest, WorksWithMonomorphicMatcher) { EXPECT_EQ("", listener2.str()); } +MATCHER(ConstructNoArg, "") { return true; } +MATCHER_P(Construct1Arg, arg1, "") { return true; } +MATCHER_P2(Construct2Args, arg1, arg2, "") { return true; } + +TEST(MatcherConstruct, ExplicitVsImplicit) { + { + // No arg constructor can be constructed with empty brace. + ConstructNoArgMatcher m = {}; + (void)m; + // And with no args + ConstructNoArgMatcher m2; + (void)m2; + } + { + // The one arg constructor has an explicit constructor. + // This is to prevent the implicit conversion. + using M = Construct1ArgMatcherP; + EXPECT_TRUE((std::is_constructible::value)); + EXPECT_FALSE((std::is_convertible::value)); + } + { + // Multiple arg matchers can be constructed with an implicit construction. + Construct2ArgsMatcherP2 m = {1, 2.2}; + (void)m; + } +} + MATCHER_P(Really, inner_matcher, "") { return ExplainMatchResult(inner_matcher, arg, result_listener); } -- cgit v1.2.3