merging, gmock -1

This commit is contained in:
Gennadiy Civil
2018-03-22 15:35:37 -04:00
parent 4e89c76db8
commit b7c568326c
4 changed files with 132 additions and 72 deletions

View File

@@ -323,7 +323,13 @@ class Matcher : public internal::MatcherBase<T> {
explicit Matcher() {} // NOLINT
// Constructs a matcher from its implementation.
explicit Matcher(const MatcherInterface<T>* impl)
explicit Matcher(const MatcherInterface<GTEST_REFERENCE_TO_CONST_(T)>* impl)
: internal::MatcherBase<T>(impl) {}
template <typename U>
explicit Matcher(const MatcherInterface<U>* impl,
typename internal::EnableIf<!internal::IsSame<
U, GTEST_REFERENCE_TO_CONST_(U)>::value>::type* = NULL)
: internal::MatcherBase<T>(impl) {}
// Implicit constructor here allows people to write
@@ -332,64 +338,79 @@ class Matcher : public internal::MatcherBase<T> {
};
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a string
// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string
// matcher is expected.
template <>
class GTEST_API_ Matcher<const internal::string&>
: public internal::MatcherBase<const internal::string&> {
class GTEST_API_ Matcher<const std::string&>
: public internal::MatcherBase<const std::string&> {
public:
Matcher() {}
explicit Matcher(const MatcherInterface<const internal::string&>* impl)
: internal::MatcherBase<const internal::string&>(impl) {}
explicit Matcher(const MatcherInterface<const std::string&>* impl)
: internal::MatcherBase<const std::string&>(impl) {}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a string object.
Matcher(const internal::string& s); // NOLINT
// str is a std::string object.
Matcher(const std::string& s); // NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher(const ::string& s); // NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher(const char* s); // NOLINT
};
template <>
class GTEST_API_ Matcher<internal::string>
: public internal::MatcherBase<internal::string> {
class GTEST_API_ Matcher<std::string>
: public internal::MatcherBase<std::string> {
public:
Matcher() {}
explicit Matcher(const MatcherInterface<internal::string>* impl)
: internal::MatcherBase<internal::string>(impl) {}
explicit Matcher(const MatcherInterface<std::string>* impl)
: internal::MatcherBase<std::string>(impl) {}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a string object.
Matcher(const internal::string& s); // NOLINT
Matcher(const std::string& s); // NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher(const ::string& s); // NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher(const char* s); // NOLINT
};
#if GTEST_HAS_STRING_PIECE_
#if GTEST_HAS_GLOBAL_STRING
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a StringPiece
// instead of Eq(str) and "foo" instead of Eq("foo") when a ::string
// matcher is expected.
template <>
class GTEST_API_ Matcher<const StringPiece&>
: public internal::MatcherBase<const StringPiece&> {
class GTEST_API_ Matcher<const ::string&>
: public internal::MatcherBase<const ::string&> {
public:
Matcher() {}
explicit Matcher(const MatcherInterface<const StringPiece&>* impl)
: internal::MatcherBase<const StringPiece&>(impl) {}
explicit Matcher(const MatcherInterface<const ::string&>* impl)
: internal::MatcherBase<const ::string&>(impl) {}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a string object.
Matcher(const internal::string& s); // NOLINT
// str is a std::string object.
Matcher(const std::string& s); // NOLINT
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher(const ::string& s); // NOLINT
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher(const char* s); // NOLINT
};
// Allows the user to pass StringPieces directly.
Matcher(StringPiece s); // NOLINT
};
template <>
@@ -1340,7 +1361,7 @@ class MatchesRegexMatcher {
// Matches anything that can convert to std::string.
//
// This is a template, not just a plain function with const std::string&,
// because StringPiece has some interfering non-explicit constructors.
// because absl::string_view has some interfering non-explicit constructors.
template <class MatcheeStringType>
bool MatchAndExplain(const MatcheeStringType& s,
MatchResultListener* /* listener */) const {