From aa40ee603ebbc0d4ebef4224ece54a6ae4382d0e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 23 Jun 2026 06:02:44 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 936616624 Change-Id: I3a05afadf807fc372337186c26b5d73a2bc21410 --- googlemock/test/gmock-actions_test.cc | 109 +++++++++--------- googlemock/test/gmock-function-mocker_test.cc | 2 +- googlemock/test/gmock-matchers-misc_test.cc | 2 +- googlemock/test/gmock-matchers_test.h | 3 +- 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 1bc304088..507db6b2a 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -66,30 +66,30 @@ using ::testing::internal::BuiltInDefaultValue; TEST(TypeTraits, Negation) { // Direct use with std types. - static_assert(std::is_base_of>::value, - ""); + static_assert( + std::is_base_of_v>, + ""); - static_assert(std::is_base_of>::value, - ""); + static_assert( + std::is_base_of_v>, + ""); // With other types that fit the requirement of a value member that is // convertible to bool. - static_assert(std::is_base_of< - std::true_type, - internal::negation>>::value, - ""); + static_assert( + std::is_base_of_v>>, + ""); - static_assert(std::is_base_of< - std::false_type, - internal::negation>>::value, - ""); + static_assert( + std::is_base_of_v>>, + ""); - static_assert(std::is_base_of< - std::false_type, - internal::negation>>::value, - ""); + static_assert( + std::is_base_of_v>>, + ""); } // Weird false/true types that aren't actually bool constants (but should still @@ -108,79 +108,76 @@ struct MyTrue : std::integral_constant {}; TEST(TypeTraits, Conjunction) { // Base case: always true. - static_assert(std::is_base_of>::value, - ""); + static_assert(std::is_base_of_v>, ""); // One predicate: inherits from that predicate, regardless of value. static_assert( - std::is_base_of, internal::conjunction>>::value, - ""); + std::is_base_of_v, internal::conjunction>>, ""); - static_assert( - std::is_base_of, internal::conjunction>>::value, ""); + static_assert(std::is_base_of_v, internal::conjunction>>, + ""); // Multiple predicates, with at least one false: inherits from that one. static_assert( - std::is_base_of, internal::conjunction, MyFalse<1>, - MyTrue<2>>>::value, + std::is_base_of_v< + MyFalse<1>, internal::conjunction, MyFalse<1>, MyTrue<2>>>, ""); static_assert( - std::is_base_of, internal::conjunction, MyFalse<1>, - MyFalse<2>>>::value, + std::is_base_of_v< + MyFalse<1>, internal::conjunction, MyFalse<1>, MyFalse<2>>>, ""); // Short circuiting: in the case above, additional predicates need not even // define a value member. struct Empty {}; static_assert( - std::is_base_of, internal::conjunction, MyFalse<1>, - Empty>>::value, + std::is_base_of_v, + internal::conjunction, MyFalse<1>, Empty>>, ""); // All predicates true: inherits from the last. static_assert( - std::is_base_of, internal::conjunction, MyTrue<1>, - MyTrue<2>>>::value, + std::is_base_of_v, + internal::conjunction, MyTrue<1>, MyTrue<2>>>, ""); } TEST(TypeTraits, Disjunction) { // Base case: always false. - static_assert( - std::is_base_of>::value, ""); + static_assert(std::is_base_of_v>, + ""); // One predicate: inherits from that predicate, regardless of value. static_assert( - std::is_base_of, internal::disjunction>>::value, - ""); + std::is_base_of_v, internal::disjunction>>, ""); - static_assert( - std::is_base_of, internal::disjunction>>::value, ""); + static_assert(std::is_base_of_v, internal::disjunction>>, + ""); // Multiple predicates, with at least one true: inherits from that one. static_assert( - std::is_base_of, internal::disjunction, MyTrue<1>, - MyFalse<2>>>::value, + std::is_base_of_v< + MyTrue<1>, internal::disjunction, MyTrue<1>, MyFalse<2>>>, ""); static_assert( - std::is_base_of, internal::disjunction, MyTrue<1>, - MyTrue<2>>>::value, + std::is_base_of_v< + MyTrue<1>, internal::disjunction, MyTrue<1>, MyTrue<2>>>, ""); // Short circuiting: in the case above, additional predicates need not even // define a value member. struct Empty {}; static_assert( - std::is_base_of, internal::disjunction, MyTrue<1>, - Empty>>::value, + std::is_base_of_v, + internal::disjunction, MyTrue<1>, Empty>>, ""); // All predicates false: inherits from the last. static_assert( - std::is_base_of, internal::disjunction, MyFalse<1>, - MyFalse<2>>>::value, + std::is_base_of_v, internal::disjunction< + MyFalse<0>, MyFalse<1>, MyFalse<2>>>, ""); } @@ -747,8 +744,8 @@ TEST(ReturnTest, ConversionRequiresConstLvalueReference) { using R = int; using U = std::reference_wrapper; - static_assert(std::is_convertible::value, ""); - static_assert(!std::is_convertible::value, ""); + static_assert(std::is_convertible_v, ""); + static_assert(!std::is_convertible_v, ""); MockFunction mock; EXPECT_CALL(mock, Call).WillOnce(Return(17)).WillRepeatedly(Return(19)); @@ -771,11 +768,11 @@ TEST(ReturnTest, ConversionRequiresMutableLvalueReference) { S(std::string&) {} // NOLINT }; - static_assert(std::is_convertible::value, ""); + static_assert(std::is_convertible_v, ""); #ifndef _MSC_VER - static_assert(!std::is_convertible::value, ""); + static_assert(!std::is_convertible_v, ""); #endif - static_assert(!std::is_convertible::value, ""); + static_assert(!std::is_convertible_v, ""); // It shouldn't be possible to use the result of Return(std::string) in a // context where an S is needed. @@ -784,9 +781,9 @@ TEST(ReturnTest, ConversionRequiresMutableLvalueReference) { // implementation of is_convertible causes our SFINAE to be wrong. using RA = decltype(Return(std::string())); - static_assert(!std::is_convertible>::value, ""); + static_assert(!std::is_convertible_v>, ""); #ifndef _MSC_VER - static_assert(!std::is_convertible>::value, ""); + static_assert(!std::is_convertible_v>, ""); #endif } @@ -803,8 +800,8 @@ TEST(ReturnTest, MoveOnlyResultType) { // The result of Return should not be convertible to Action (so it can't be // used with WillRepeatedly). - static_assert(!std::is_convertible())), - Action()>>::value, + static_assert(!std::is_convertible_v())), + Action()>>, ""); } @@ -2196,7 +2193,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { EXPECT_EQ(x, 3); } -ACTION(ReturnArity) { return std::tuple_size::value; } +ACTION(ReturnArity) { return std::tuple_size_v; } TEST(ActionMacro, LargeArity) { EXPECT_EQ( diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 05e26c8c4..240debd9a 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -937,7 +937,7 @@ namespace { template static constexpr bool IsMockFunctionTemplateArgumentDeducedTo( const internal::MockFunction&) { - return std::is_same::value; + return std::is_same_v; } } // namespace diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 0161169f2..16d62be24 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -789,7 +789,7 @@ class SampleVariantIntString { template friend bool holds_alternative(const SampleVariantIntString& value) { - return value.has_int_ == std::is_same::value; + return value.has_int_ == std::is_same_v; } template diff --git a/googlemock/test/gmock-matchers_test.h b/googlemock/test/gmock-matchers_test.h index 56956076d..23b8abd8b 100644 --- a/googlemock/test/gmock-matchers_test.h +++ b/googlemock/test/gmock-matchers_test.h @@ -123,8 +123,7 @@ struct GtestGreaterThanMatcher { }; template -GtestGreaterThanMatcher::type> GtestGreaterThan( - T&& rhs) { +GtestGreaterThanMatcher> GtestGreaterThan(T&& rhs) { return {rhs}; }