diff options
author | Andy Soffer <804265+asoffer@users.noreply.github.com> | 2023-05-01 18:27:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 18:27:38 (GMT) |
commit | 76bce79a3493aa157b3baca833fec1e3934d3512 (patch) | |
tree | 535cdfa334eb203cfd03505c82904e314ba7b153 /googletest/include/gtest/gtest-matchers.h | |
parent | 6f1c4b3d7b139c7217698bf4115be9f40785f661 (diff) | |
parent | f345b2ca6adb1b505049190867eedf24d3b5eaa3 (diff) | |
download | googletest-76bce79a3493aa157b3baca833fec1e3934d3512.zip googletest-76bce79a3493aa157b3baca833fec1e3934d3512.tar.gz googletest-76bce79a3493aa157b3baca833fec1e3934d3512.tar.bz2 |
Merge branch 'main' into fixes_std_pair_diffrefs/pull/4146/head
Diffstat (limited to 'googletest/include/gtest/gtest-matchers.h')
-rw-r--r-- | googletest/include/gtest/gtest-matchers.h | 77 |
1 files changed, 22 insertions, 55 deletions
diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 4a60b0d..eae210e 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -40,6 +40,7 @@ #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ #include <atomic> +#include <functional> #include <memory> #include <ostream> #include <string> @@ -106,13 +107,13 @@ class MatchResultListener { MatchResultListener& operator=(const MatchResultListener&) = delete; }; -inline MatchResultListener::~MatchResultListener() {} +inline MatchResultListener::~MatchResultListener() = default; // An instance of a subclass of this knows how to describe itself as a // matcher. class GTEST_API_ MatcherDescriberInterface { public: - virtual ~MatcherDescriberInterface() {} + virtual ~MatcherDescriberInterface() = default; // Describes this matcher to an ostream. The function should print // a verb phrase that describes the property a value matching this @@ -178,43 +179,6 @@ class MatcherInterface : public MatcherDescriberInterface { namespace internal { -struct AnyEq { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a == b; - } -}; -struct AnyNe { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a != b; - } -}; -struct AnyLt { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a < b; - } -}; -struct AnyGt { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a > b; - } -}; -struct AnyLe { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a <= b; - } -}; -struct AnyGe { - template <typename A, typename B> - bool operator()(const A& a, const B& b) const { - return a >= b; - } -}; - // A match result listener that ignores the explanation. class DummyMatchResultListener : public MatchResultListener { public: @@ -530,7 +494,7 @@ template <> class GTEST_API_ Matcher<const std::string&> : public internal::MatcherBase<const std::string&> { public: - Matcher() {} + Matcher() = default; explicit Matcher(const MatcherInterface<const std::string&>* impl) : internal::MatcherBase<const std::string&>(impl) {} @@ -552,7 +516,7 @@ template <> class GTEST_API_ Matcher<std::string> : public internal::MatcherBase<std::string> { public: - Matcher() {} + Matcher() = default; explicit Matcher(const MatcherInterface<const std::string&>* impl) : internal::MatcherBase<std::string>(impl) {} @@ -580,7 +544,7 @@ template <> class GTEST_API_ Matcher<const internal::StringView&> : public internal::MatcherBase<const internal::StringView&> { public: - Matcher() {} + Matcher() = default; explicit Matcher(const MatcherInterface<const internal::StringView&>* impl) : internal::MatcherBase<const internal::StringView&>(impl) {} @@ -606,7 +570,7 @@ template <> class GTEST_API_ Matcher<internal::StringView> : public internal::MatcherBase<internal::StringView> { public: - Matcher() {} + Matcher() = default; explicit Matcher(const MatcherInterface<const internal::StringView&>* impl) : internal::MatcherBase<internal::StringView>(impl) {} @@ -758,50 +722,53 @@ class ComparisonBase { }; template <typename Rhs> -class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> { +class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> { public: explicit EqMatcher(const Rhs& rhs) - : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) {} + : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {} static const char* Desc() { return "is equal to"; } static const char* NegatedDesc() { return "isn't equal to"; } }; template <typename Rhs> -class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> { +class NeMatcher + : public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> { public: explicit NeMatcher(const Rhs& rhs) - : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) {} + : ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>>(rhs) {} static const char* Desc() { return "isn't equal to"; } static const char* NegatedDesc() { return "is equal to"; } }; template <typename Rhs> -class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> { +class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> { public: explicit LtMatcher(const Rhs& rhs) - : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) {} + : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {} static const char* Desc() { return "is <"; } static const char* NegatedDesc() { return "isn't <"; } }; template <typename Rhs> -class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> { +class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> { public: explicit GtMatcher(const Rhs& rhs) - : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) {} + : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {} static const char* Desc() { return "is >"; } static const char* NegatedDesc() { return "isn't >"; } }; template <typename Rhs> -class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> { +class LeMatcher + : public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> { public: explicit LeMatcher(const Rhs& rhs) - : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) {} + : ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>>(rhs) {} static const char* Desc() { return "is <="; } static const char* NegatedDesc() { return "isn't <="; } }; template <typename Rhs> -class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> { +class GeMatcher + : public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> { public: explicit GeMatcher(const Rhs& rhs) - : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) {} + : ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>>(rhs) {} static const char* Desc() { return "is >="; } static const char* NegatedDesc() { return "isn't >="; } }; |