From 5a4a3c968b5ec69797455f0c46c815bf70e46213 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 30 Sep 2026 04:56:59 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 990912713 Change-Id: Iae4b372309fb0cf3d790dbbd5014bd49b0e06930 --- googlemock/include/gmock/gmock-actions.h | 2 +- googlemock/include/gmock/gmock-matchers.h | 37 +++++++++++-------- .../include/gmock/gmock-spec-builders.h | 13 ++++--- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 4b2c9cd5..a5fb6427 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -175,7 +175,7 @@ struct BuiltInDefaultValueGetter { template struct BuiltInDefaultValueGetter { static T Get() { - Assert(false, __FILE__, __LINE__, + Assert(/*condition=*/false, __FILE__, __LINE__, "Default action undefined for the function return type."); #if defined(__GNUC__) || defined(__clang__) __builtin_unreachable(); diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 5f5855f3..244cb27d 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1908,12 +1908,12 @@ class [[nodiscard]] FloatingEqMatcher { template class [[nodiscard]] FloatingEq2Matcher { public: - FloatingEq2Matcher() { Init(-1, false); } + FloatingEq2Matcher() { Init(-1, /*nan_eq_nan_val=*/false); } explicit FloatingEq2Matcher(bool nan_eq_nan) { Init(-1, nan_eq_nan); } explicit FloatingEq2Matcher(FloatType max_abs_error) { - Init(max_abs_error, false); + Init(max_abs_error, /*nan_eq_nan_val=*/false); } FloatingEq2Matcher(FloatType max_abs_error, bool nan_eq_nan) { @@ -2942,7 +2942,8 @@ class [[nodiscard]] ContainsMatcherImpl bool MatchAndExplain(Container container, MatchResultListener* listener) const override { - return this->MatchAndExplainImpl(false, container, listener); + return this->MatchAndExplainImpl(/*all_elements_should_match=*/false, + container, listener); } }; @@ -4740,13 +4741,13 @@ inline PolymorphicMatcher IsNan() { // Creates a matcher that matches any double argument approximately // equal to rhs, where two NANs are considered unequal. inline internal::FloatingEqMatcher DoubleEq(double rhs) { - return internal::FloatingEqMatcher(rhs, false); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/false); } // Creates a matcher that matches any double argument approximately // equal to rhs, including NaN values when rhs is NaN. inline internal::FloatingEqMatcher NanSensitiveDoubleEq(double rhs) { - return internal::FloatingEqMatcher(rhs, true); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/true); } // Creates a matcher that matches any double argument approximately equal to @@ -4754,7 +4755,8 @@ inline internal::FloatingEqMatcher NanSensitiveDoubleEq(double rhs) { // considered unequal. The max absolute error bound must be non-negative. inline internal::FloatingEqMatcher DoubleNear(double rhs, double max_abs_error) { - return internal::FloatingEqMatcher(rhs, false, max_abs_error); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/false, + max_abs_error); } // The DistanceFrom(target, get_distance, m) and DistanceFrom(target, m) @@ -4798,19 +4800,20 @@ DistanceFrom(T target, DistanceMatcher distance_matcher) { // rhs is NaN. The max absolute error bound must be non-negative. inline internal::FloatingEqMatcher NanSensitiveDoubleNear( double rhs, double max_abs_error) { - return internal::FloatingEqMatcher(rhs, true, max_abs_error); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/true, + max_abs_error); } // Creates a matcher that matches any float argument approximately // equal to rhs, where two NANs are considered unequal. inline internal::FloatingEqMatcher FloatEq(float rhs) { - return internal::FloatingEqMatcher(rhs, false); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/false); } // Creates a matcher that matches any float argument approximately // equal to rhs, including NaN values when rhs is NaN. inline internal::FloatingEqMatcher NanSensitiveFloatEq(float rhs) { - return internal::FloatingEqMatcher(rhs, true); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/true); } // Creates a matcher that matches any float argument approximately equal to @@ -4818,7 +4821,8 @@ inline internal::FloatingEqMatcher NanSensitiveFloatEq(float rhs) { // considered unequal. The max absolute error bound must be non-negative. inline internal::FloatingEqMatcher FloatNear(float rhs, float max_abs_error) { - return internal::FloatingEqMatcher(rhs, false, max_abs_error); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/false, + max_abs_error); } // Creates a matcher that matches any float argument approximately equal to @@ -4826,7 +4830,8 @@ inline internal::FloatingEqMatcher FloatNear(float rhs, // rhs is NaN. The max absolute error bound must be non-negative. inline internal::FloatingEqMatcher NanSensitiveFloatNear( float rhs, float max_abs_error) { - return internal::FloatingEqMatcher(rhs, true, max_abs_error); + return internal::FloatingEqMatcher(rhs, /*nan_eq_nan=*/true, + max_abs_error); } // Creates a matcher that matches a pointer (raw or smart) that points @@ -5069,13 +5074,13 @@ inline internal::FloatingEq2Matcher DoubleEq() { // Creates a polymorphic matcher that matches a 2-tuple where // FloatEq(first field) matches the second field with NaN equality. inline internal::FloatingEq2Matcher NanSensitiveFloatEq() { - return internal::FloatingEq2Matcher(true); + return internal::FloatingEq2Matcher(/*nan_eq_nan=*/true); } // Creates a polymorphic matcher that matches a 2-tuple where // DoubleEq(first field) matches the second field with NaN equality. inline internal::FloatingEq2Matcher NanSensitiveDoubleEq() { - return internal::FloatingEq2Matcher(true); + return internal::FloatingEq2Matcher(/*nan_eq_nan=*/true); } // Creates a polymorphic matcher that matches a 2-tuple where @@ -5095,7 +5100,8 @@ inline internal::FloatingEq2Matcher DoubleNear(double max_abs_error) { // equality. inline internal::FloatingEq2Matcher NanSensitiveFloatNear( float max_abs_error) { - return internal::FloatingEq2Matcher(max_abs_error, true); + return internal::FloatingEq2Matcher(max_abs_error, + /*nan_eq_nan=*/true); } // Creates a polymorphic matcher that matches a 2-tuple where @@ -5103,7 +5109,8 @@ inline internal::FloatingEq2Matcher NanSensitiveFloatNear( // equality. inline internal::FloatingEq2Matcher NanSensitiveDoubleNear( double max_abs_error) { - return internal::FloatingEq2Matcher(max_abs_error, true); + return internal::FloatingEq2Matcher(max_abs_error, + /*nan_eq_nan=*/true); } // Creates a matcher that matches any value of type T that m doesn't diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 1be93588..cad491da 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -909,7 +909,7 @@ class TypedExpectation : public ExpectationBase { // Implements the .With() clause. TypedExpectation& With(const Matcher& m) { if (last_clause_ == kWith) { - ExpectSpecProperty(false, + ExpectSpecProperty(/*property=*/false, ".With() cannot appear " "more than once in an EXPECT_CALL()."); } else { @@ -1032,7 +1032,7 @@ class TypedExpectation : public ExpectationBase { // Implements the .WillRepeatedly() clause. TypedExpectation& WillRepeatedly(const Action& action) { if (last_clause_ == kWillRepeatedly) { - ExpectSpecProperty(false, + ExpectSpecProperty(/*property=*/false, ".WillRepeatedly() cannot appear " "more than once in an EXPECT_CALL()."); } else { @@ -1421,11 +1421,11 @@ struct UntypedFunctionMockerBase::FailureCleanupHandler { if (!found) { // No expectation matches this call - reports a failure. - Expect(false, nullptr, -1, ss.str()); + Expect(/*condition=*/false, /*file=*/nullptr, -1, ss.str()); } else if (is_excessive) { // We had an upper-bound violation and the failure message is in ss. - Expect(false, untyped_expectation->file(), untyped_expectation->line(), - ss.str()); + Expect(/*condition=*/false, untyped_expectation->file(), + untyped_expectation->line(), ss.str()); } else { // We had an expected call and the matching expectation is // described in ss. @@ -1841,7 +1841,8 @@ R FunctionMocker::InvokeWith(ArgumentTuple&& args) const UninterestingCallCleanupHandler report_uninteresting_call = {reaction, ss}; - return PerformActionAndPrintResult(nullptr, std::move(args), ss.str(), ss); + return PerformActionAndPrintResult(/*untyped_action=*/nullptr, + std::move(args), ss.str(), ss); } bool is_excessive = false;