| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,10 +67,10 @@ namespace testing { | |||
| 67 | 67 | // To implement a matcher Foo for type T, define: | |
| 68 | 68 | // 1. a class FooMatcherMatcher that implements the matcher interface: | |
| 69 | 69 | // using is_gtest_matcher = void; | |
| 70 | - // bool MatchAndExplain(const T&, std::ostream*); | ||
| 70 | + // bool MatchAndExplain(const T&, std::ostream*) const; | ||
| 71 | 71 | // (MatchResultListener* can also be used instead of std::ostream*) | |
| 72 | - // void DescribeTo(std::ostream*); | ||
| 73 | - // void DescribeNegationTo(std::ostream*); | ||
| 72 | + // void DescribeTo(std::ostream*) const; | ||
| 73 | + // void DescribeNegationTo(std::ostream*) const; | ||
| 74 | 74 | // | |
| 75 | 75 | // 2. a factory function that creates a Matcher<T> object from a | |
| 76 | 76 | // FooMatcherMatcher. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,6 +126,10 @@ | |||
| 126 | 126 | #include <span> // NOLINT | |
| 127 | 127 | #endif // GTEST_INTERNAL_HAS_STD_SPAN | |
| 128 | 128 | ||
| 129 | + #if GTEST_INTERNAL_HAS_COMPARE_LIB | ||
| 130 | + #include <compare> // NOLINT | ||
| 131 | + #endif // GTEST_INTERNAL_HAS_COMPARE_LIB | ||
| 132 | + | ||
| 129 | 133 | namespace testing { | |
| 130 | 134 | ||
| 131 | 135 | // Definitions in the internal* namespaces are subject to change without notice. | |
@@ -782,6 +786,41 @@ void PrintTo(const std::shared_ptr<T>& ptr, std::ostream* os) { | |||
| 782 | 786 | (PrintSmartPointer<T>)(ptr, os, 0); | |
| 783 | 787 | } | |
| 784 | 788 | ||
| 789 | + #if GTEST_INTERNAL_HAS_COMPARE_LIB | ||
| 790 | + template <typename T> | ||
| 791 | + void PrintOrderingHelper(T ordering, std::ostream* os) { | ||
| 792 | + if (ordering == T::less) { | ||
| 793 | + *os << "(less)"; | ||
| 794 | + } else if (ordering == T::greater) { | ||
| 795 | + *os << "(greater)"; | ||
| 796 | + } else if (ordering == T::equivalent) { | ||
| 797 | + *os << "(equivalent)"; | ||
| 798 | + } else { | ||
| 799 | + *os << "(unknown ordering)"; | ||
| 800 | + } | ||
| 801 | + } | ||
| 802 | + | ||
| 803 | + inline void PrintTo(std::strong_ordering ordering, std::ostream* os) { | ||
| 804 | + if (ordering == std::strong_ordering::equal) { | ||
| 805 | + *os << "(equal)"; | ||
| 806 | + } else { | ||
| 807 | + PrintOrderingHelper(ordering, os); | ||
| 808 | + } | ||
| 809 | + } | ||
| 810 | + | ||
| 811 | + inline void PrintTo(std::partial_ordering ordering, std::ostream* os) { | ||
| 812 | + if (ordering == std::partial_ordering::unordered) { | ||
| 813 | + *os << "(unordered)"; | ||
| 814 | + } else { | ||
| 815 | + PrintOrderingHelper(ordering, os); | ||
| 816 | + } | ||
| 817 | + } | ||
| 818 | + | ||
| 819 | + inline void PrintTo(std::weak_ordering ordering, std::ostream* os) { | ||
| 820 | + PrintOrderingHelper(ordering, os); | ||
| 821 | + } | ||
| 822 | + #endif | ||
| 823 | + | ||
| 785 | 824 | // Helper function for printing a tuple. T must be instantiated with | |
| 786 | 825 | // a tuple type. | |
| 787 | 826 | template <typename T> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2533,4 +2533,12 @@ using Variant = ::std::variant<T...>; | |||
| 2533 | 2533 | #define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1 | |
| 2534 | 2534 | #endif | |
| 2535 | 2535 | ||
| 2536 | + #if (defined(__cpp_lib_three_way_comparison) || \ | ||
| 2537 | + (GTEST_INTERNAL_HAS_INCLUDE(<compare>) && \ | ||
| 2538 | + GTEST_INTERNAL_CPLUSPLUS_LANG >= 201907L)) | ||
| 2539 | + #define GTEST_INTERNAL_HAS_COMPARE_LIB 1 | ||
| 2540 | + #else | ||
| 2541 | + #define GTEST_INTERNAL_HAS_COMPARE_LIB 0 | ||
| 2542 | + #endif | ||
| 2543 | + | ||
| 2536 | 2544 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments