| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 571cec4 commit 9835860
14 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,7 +137,7 @@ namespace testing { | |||
| 137 | 137 | class [[nodiscard]] AssertionResult; | |
| 138 | 138 | #endif // !SWIG | |
| 139 | 139 | ||
| 140 | - class GTEST_API_ AssertionResult { | ||
| 140 | + class GTEST_API_ [[nodiscard]] AssertionResult { | ||
| 141 | 141 | public: | |
| 142 | 142 | // Copy constructor. | |
| 143 | 143 | // Used in EXPECT_TRUE/FALSE(assertion_result). | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,7 +192,7 @@ GTEST_API_ bool InDeathTestChild(); | |||
| 192 | 192 | // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: | |
| 193 | 193 | ||
| 194 | 194 | // Tests that an exit code describes a normal exit with a given exit code. | |
| 195 | - class GTEST_API_ ExitedWithCode { | ||
| 195 | + class GTEST_API_ [[nodiscard]] ExitedWithCode { | ||
| 196 | 196 | public: | |
| 197 | 197 | explicit ExitedWithCode(int exit_code); | |
| 198 | 198 | ExitedWithCode(const ExitedWithCode&) = default; | |
@@ -206,7 +206,7 @@ class GTEST_API_ ExitedWithCode { | |||
| 206 | 206 | #if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) | |
| 207 | 207 | // Tests that an exit code describes an exit due to termination by a | |
| 208 | 208 | // given signal. | |
| 209 | - class GTEST_API_ KilledBySignal { | ||
| 209 | + class GTEST_API_ [[nodiscard]] KilledBySignal { | ||
| 210 | 210 | public: | |
| 211 | 211 | explicit KilledBySignal(int signum); | |
| 212 | 212 | bool operator()(int exit_status) const; | |
@@ -317,7 +317,7 @@ class GTEST_API_ KilledBySignal { | |||
| 317 | 317 | GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \ | |
| 318 | 318 | << "Statement '" #statement "' cannot be verified."; \ | |
| 319 | 319 | } else if (::testing::internal::AlwaysFalse()) { \ | |
| 320 | - ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ | ||
| 320 | + (void)::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ | ||
| 321 | 321 | GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ | |
| 322 | 322 | terminator; \ | |
| 323 | 323 | } else \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,7 +75,7 @@ namespace testing { | |||
| 75 | 75 | // 2. a factory function that creates a Matcher<T> object from a | |
| 76 | 76 | // FooMatcherMatcher. | |
| 77 | 77 | ||
| 78 | - class MatchResultListener { | ||
| 78 | + class [[nodiscard]] MatchResultListener { | ||
| 79 | 79 | public: | |
| 80 | 80 | // Creates a listener object with the given underlying ostream. The | |
| 81 | 81 | // listener does not own the ostream, and does not dereference it | |
@@ -111,7 +111,7 @@ inline MatchResultListener::~MatchResultListener() = default; | |||
| 111 | 111 | ||
| 112 | 112 | // An instance of a subclass of this knows how to describe itself as a | |
| 113 | 113 | // matcher. | |
| 114 | - class GTEST_API_ MatcherDescriberInterface { | ||
| 114 | + class GTEST_API_ [[nodiscard]] MatcherDescriberInterface { | ||
| 115 | 115 | public: | |
| 116 | 116 | virtual ~MatcherDescriberInterface() = default; | |
| 117 | 117 | ||
@@ -137,7 +137,7 @@ class GTEST_API_ MatcherDescriberInterface { | |||
| 137 | 137 | ||
| 138 | 138 | // The implementation of a matcher. | |
| 139 | 139 | template <typename T> | |
| 140 | - class MatcherInterface : public MatcherDescriberInterface { | ||
| 140 | + class [[nodiscard]] MatcherInterface : public MatcherDescriberInterface { | ||
| 141 | 141 | public: | |
| 142 | 142 | // Returns true if and only if the matcher matches x; also explains the | |
| 143 | 143 | // match result to 'listener' if necessary (see the next paragraph), in | |
@@ -180,7 +180,7 @@ class MatcherInterface : public MatcherDescriberInterface { | |||
| 180 | 180 | namespace internal { | |
| 181 | 181 | ||
| 182 | 182 | // A match result listener that ignores the explanation. | |
| 183 | - class DummyMatchResultListener : public MatchResultListener { | ||
| 183 | + class [[nodiscard]] DummyMatchResultListener : public MatchResultListener { | ||
| 184 | 184 | public: | |
| 185 | 185 | DummyMatchResultListener() : MatchResultListener(nullptr) {} | |
| 186 | 186 | ||
@@ -192,7 +192,7 @@ class DummyMatchResultListener : public MatchResultListener { | |||
| 192 | 192 | // A match result listener that forwards the explanation to a given | |
| 193 | 193 | // ostream. The difference between this and MatchResultListener is | |
| 194 | 194 | // that the former is concrete. | |
| 195 | - class StreamMatchResultListener : public MatchResultListener { | ||
| 195 | + class [[nodiscard]] StreamMatchResultListener : public MatchResultListener { | ||
| 196 | 196 | public: | |
| 197 | 197 | explicit StreamMatchResultListener(::std::ostream* os) | |
| 198 | 198 | : MatchResultListener(os) {} | |
@@ -225,7 +225,7 @@ struct SharedPayload : SharedPayloadBase { | |||
| 225 | 225 | // from it. We put functionalities common to all Matcher<T> | |
| 226 | 226 | // specializations here to avoid code duplication. | |
| 227 | 227 | template <typename T> | |
| 228 | - class MatcherBase : private MatcherDescriberInterface { | ||
| 228 | + class [[nodiscard]] MatcherBase : private MatcherDescriberInterface { | ||
| 229 | 229 | public: | |
| 230 | 230 | // Returns true if and only if the matcher matches x; also explains the | |
| 231 | 231 | // match result to 'listener'. | |
@@ -460,7 +460,7 @@ class MatcherBase : private MatcherDescriberInterface { | |||
| 460 | 460 | // implementation of Matcher<T> is just a std::shared_ptr to const | |
| 461 | 461 | // MatcherInterface<T>. Don't inherit from Matcher! | |
| 462 | 462 | template <typename T> | |
| 463 | - class Matcher : public internal::MatcherBase<T> { | ||
| 463 | + class [[nodiscard]] Matcher : public internal::MatcherBase<T> { | ||
| 464 | 464 | public: | |
| 465 | 465 | // Constructs a null matcher. Needed for storing Matcher objects in STL | |
| 466 | 466 | // containers. A default-constructed matcher is not yet initialized. You | |
@@ -491,8 +491,8 @@ class Matcher : public internal::MatcherBase<T> { | |||
| 491 | 491 | // instead of Eq(str) and "foo" instead of Eq("foo") when a std::string | |
| 492 | 492 | // matcher is expected. | |
| 493 | 493 | template <> | |
| 494 | - class GTEST_API_ Matcher<const std::string&> | ||
| 495 | - : public internal::MatcherBase<const std::string&> { | ||
| 494 | + class GTEST_API_ [[nodiscard]] | ||
| 495 | + Matcher<const std::string&> : public internal::MatcherBase<const std::string&> { | ||
| 496 | 496 | public: | |
| 497 | 497 | Matcher() = default; | |
| 498 | 498 | ||
@@ -513,8 +513,8 @@ class GTEST_API_ Matcher<const std::string&> | |||
| 513 | 513 | }; | |
| 514 | 514 | ||
| 515 | 515 | template <> | |
| 516 | - class GTEST_API_ Matcher<std::string> | ||
| 517 | - : public internal::MatcherBase<std::string> { | ||
| 516 | + class GTEST_API_ [[nodiscard]] | ||
| 517 | + Matcher<std::string> : public internal::MatcherBase<std::string> { | ||
| 518 | 518 | public: | |
| 519 | 519 | Matcher() = default; | |
| 520 | 520 | ||
@@ -541,7 +541,7 @@ class GTEST_API_ Matcher<std::string> | |||
| 541 | 541 | // instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view | |
| 542 | 542 | // matcher is expected. | |
| 543 | 543 | template <> | |
| 544 | - class GTEST_API_ Matcher<const internal::StringView&> | ||
| 544 | + class GTEST_API_ [[nodiscard]] Matcher<const internal::StringView&> | ||
| 545 | 545 | : public internal::MatcherBase<const internal::StringView&> { | |
| 546 | 546 | public: | |
| 547 | 547 | Matcher() = default; | |
@@ -567,7 +567,7 @@ class GTEST_API_ Matcher<const internal::StringView&> | |||
| 567 | 567 | }; | |
| 568 | 568 | ||
| 569 | 569 | template <> | |
| 570 | - class GTEST_API_ Matcher<internal::StringView> | ||
| 570 | + class GTEST_API_ [[nodiscard]] Matcher<internal::StringView> | ||
| 571 | 571 | : public internal::MatcherBase<internal::StringView> { | |
| 572 | 572 | public: | |
| 573 | 573 | Matcher() = default; | |
@@ -614,7 +614,7 @@ std::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) { | |||
| 614 | 614 | // | |
| 615 | 615 | // See the definition of NotNull() for a complete example. | |
| 616 | 616 | template <class Impl> | |
| 617 | - class PolymorphicMatcher { | ||
| 617 | + class [[nodiscard]] PolymorphicMatcher { | ||
| 618 | 618 | public: | |
| 619 | 619 | explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} | |
| 620 | 620 | ||
@@ -689,7 +689,7 @@ namespace internal { | |||
| 689 | 689 | // The following template definition assumes that the Rhs parameter is | |
| 690 | 690 | // a "bare" type (i.e. neither 'const T' nor 'T&'). | |
| 691 | 691 | template <typename D, typename Rhs, typename Op> | |
| 692 | - class ComparisonBase { | ||
| 692 | + class [[nodiscard]] ComparisonBase { | ||
| 693 | 693 | public: | |
| 694 | 694 | explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} | |
| 695 | 695 | ||
@@ -722,15 +722,16 @@ class ComparisonBase { | |||
| 722 | 722 | }; | |
| 723 | 723 | ||
| 724 | 724 | template <typename Rhs> | |
| 725 | - class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> { | ||
| 725 | + class [[nodiscard]] EqMatcher | ||
| 726 | + : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> { | ||
| 726 | 727 | public: | |
| 727 | 728 | explicit EqMatcher(const Rhs& rhs) | |
| 728 | 729 | : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {} | |
| 729 | 730 | static const char* Desc() { return "is equal to"; } | |
| 730 | 731 | static const char* NegatedDesc() { return "isn't equal to"; } | |
| 731 | 732 | }; | |
| 732 | 733 | template <typename Rhs> | |
| 733 | - class NeMatcher | ||
| 734 | + class [[nodiscard]] NeMatcher | ||
| 734 | 735 | : public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> { | |
| 735 | 736 | public: | |
| 736 | 737 | explicit NeMatcher(const Rhs& rhs) | |
@@ -739,23 +740,25 @@ class NeMatcher | |||
| 739 | 740 | static const char* NegatedDesc() { return "is equal to"; } | |
| 740 | 741 | }; | |
| 741 | 742 | template <typename Rhs> | |
| 742 | - class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> { | ||
| 743 | + class [[nodiscard]] LtMatcher | ||
| 744 | + : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> { | ||
| 743 | 745 | public: | |
| 744 | 746 | explicit LtMatcher(const Rhs& rhs) | |
| 745 | 747 | : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {} | |
| 746 | 748 | static const char* Desc() { return "is <"; } | |
| 747 | 749 | static const char* NegatedDesc() { return "isn't <"; } | |
| 748 | 750 | }; | |
| 749 | 751 | template <typename Rhs> | |
| 750 | - class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> { | ||
| 752 | + class [[nodiscard]] GtMatcher | ||
| 753 | + : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> { | ||
| 751 | 754 | public: | |
| 752 | 755 | explicit GtMatcher(const Rhs& rhs) | |
| 753 | 756 | : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {} | |
| 754 | 757 | static const char* Desc() { return "is >"; } | |
| 755 | 758 | static const char* NegatedDesc() { return "isn't >"; } | |
| 756 | 759 | }; | |
| 757 | 760 | template <typename Rhs> | |
| 758 | - class LeMatcher | ||
| 761 | + class [[nodiscard]] LeMatcher | ||
| 759 | 762 | : public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> { | |
| 760 | 763 | public: | |
| 761 | 764 | explicit LeMatcher(const Rhs& rhs) | |
@@ -764,7 +767,7 @@ class LeMatcher | |||
| 764 | 767 | static const char* NegatedDesc() { return "isn't <="; } | |
| 765 | 768 | }; | |
| 766 | 769 | template <typename Rhs> | |
| 767 | - class GeMatcher | ||
| 770 | + class [[nodiscard]] GeMatcher | ||
| 768 | 771 | : public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> { | |
| 769 | 772 | public: | |
| 770 | 773 | explicit GeMatcher(const Rhs& rhs) | |
@@ -776,7 +779,7 @@ class GeMatcher | |||
| 776 | 779 | // Same as `EqMatcher<Rhs>`, except that the `rhs` is stored as `StoredRhs` and | |
| 777 | 780 | // must be implicitly convertible to `Rhs`. | |
| 778 | 781 | template <typename Rhs, typename StoredRhs> | |
| 779 | - class ImplicitCastEqMatcher { | ||
| 782 | + class [[nodiscard]] ImplicitCastEqMatcher { | ||
| 780 | 783 | public: | |
| 781 | 784 | explicit ImplicitCastEqMatcher(const StoredRhs& rhs) : stored_rhs_(rhs) {} | |
| 782 | 785 | ||
@@ -809,7 +812,7 @@ using StringLike = T; | |||
| 809 | 812 | // Implements polymorphic matchers MatchesRegex(regex) and | |
| 810 | 813 | // ContainsRegex(regex), which can be used as a Matcher<T> as long as | |
| 811 | 814 | // T can be converted to a string. | |
| 812 | - class MatchesRegexMatcher { | ||
| 815 | + class [[nodiscard]] MatchesRegexMatcher { | ||
| 813 | 816 | public: | |
| 814 | 817 | MatchesRegexMatcher(const RE* regex, bool full_match) | |
| 815 | 818 | : regex_(regex), full_match_(full_match) {} | |
| Back | FazBrowse Home | New Git URL |
0 commit comments