Automated Code Change

PiperOrigin-RevId: 936616624
Change-Id: I3a05afadf807fc372337186c26b5d73a2bc21410
This commit is contained in:
Abseil Team
2026-06-23 06:03:11 -07:00
committed by Copybara-Service
parent 1fc11dea10
commit aa40ee603e
4 changed files with 56 additions and 60 deletions
+48 -51
View File
@@ -66,29 +66,29 @@ using ::testing::internal::BuiltInDefaultValue;
TEST(TypeTraits, Negation) { TEST(TypeTraits, Negation) {
// Direct use with std types. // Direct use with std types.
static_assert(std::is_base_of<std::false_type, static_assert(
internal::negation<std::true_type>>::value, std::is_base_of_v<std::false_type, internal::negation<std::true_type>>,
""); "");
static_assert(std::is_base_of<std::true_type, static_assert(
internal::negation<std::false_type>>::value, std::is_base_of_v<std::true_type, internal::negation<std::false_type>>,
""); "");
// With other types that fit the requirement of a value member that is // With other types that fit the requirement of a value member that is
// convertible to bool. // convertible to bool.
static_assert(std::is_base_of< static_assert(
std::true_type, std::is_base_of_v<std::true_type,
internal::negation<std::integral_constant<int, 0>>>::value, internal::negation<std::integral_constant<int, 0>>>,
""); "");
static_assert(std::is_base_of< static_assert(
std::false_type, std::is_base_of_v<std::false_type,
internal::negation<std::integral_constant<int, 1>>>::value, internal::negation<std::integral_constant<int, 1>>>,
""); "");
static_assert(std::is_base_of< static_assert(
std::false_type, std::is_base_of_v<std::false_type,
internal::negation<std::integral_constant<int, -1>>>::value, internal::negation<std::integral_constant<int, -1>>>,
""); "");
} }
@@ -108,79 +108,76 @@ struct MyTrue : std::integral_constant<int, -1> {};
TEST(TypeTraits, Conjunction) { TEST(TypeTraits, Conjunction) {
// Base case: always true. // Base case: always true.
static_assert(std::is_base_of<std::true_type, internal::conjunction<>>::value, static_assert(std::is_base_of_v<std::true_type, internal::conjunction<>>, "");
"");
// One predicate: inherits from that predicate, regardless of value. // One predicate: inherits from that predicate, regardless of value.
static_assert( static_assert(
std::is_base_of<MyFalse<0>, internal::conjunction<MyFalse<0>>>::value, std::is_base_of_v<MyFalse<0>, internal::conjunction<MyFalse<0>>>, "");
"");
static_assert( static_assert(std::is_base_of_v<MyTrue<0>, internal::conjunction<MyTrue<0>>>,
std::is_base_of<MyTrue<0>, internal::conjunction<MyTrue<0>>>::value, ""); "");
// Multiple predicates, with at least one false: inherits from that one. // Multiple predicates, with at least one false: inherits from that one.
static_assert( static_assert(
std::is_base_of<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, std::is_base_of_v<
MyTrue<2>>>::value, MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, MyTrue<2>>>,
""); "");
static_assert( static_assert(
std::is_base_of<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, std::is_base_of_v<
MyFalse<2>>>::value, MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, MyFalse<2>>>,
""); "");
// Short circuiting: in the case above, additional predicates need not even // Short circuiting: in the case above, additional predicates need not even
// define a value member. // define a value member.
struct Empty {}; struct Empty {};
static_assert( static_assert(
std::is_base_of<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, std::is_base_of_v<MyFalse<1>,
Empty>>::value, internal::conjunction<MyTrue<0>, MyFalse<1>, Empty>>,
""); "");
// All predicates true: inherits from the last. // All predicates true: inherits from the last.
static_assert( static_assert(
std::is_base_of<MyTrue<2>, internal::conjunction<MyTrue<0>, MyTrue<1>, std::is_base_of_v<MyTrue<2>,
MyTrue<2>>>::value, internal::conjunction<MyTrue<0>, MyTrue<1>, MyTrue<2>>>,
""); "");
} }
TEST(TypeTraits, Disjunction) { TEST(TypeTraits, Disjunction) {
// Base case: always false. // Base case: always false.
static_assert( static_assert(std::is_base_of_v<std::false_type, internal::disjunction<>>,
std::is_base_of<std::false_type, internal::disjunction<>>::value, ""); "");
// One predicate: inherits from that predicate, regardless of value. // One predicate: inherits from that predicate, regardless of value.
static_assert( static_assert(
std::is_base_of<MyFalse<0>, internal::disjunction<MyFalse<0>>>::value, std::is_base_of_v<MyFalse<0>, internal::disjunction<MyFalse<0>>>, "");
"");
static_assert( static_assert(std::is_base_of_v<MyTrue<0>, internal::disjunction<MyTrue<0>>>,
std::is_base_of<MyTrue<0>, internal::disjunction<MyTrue<0>>>::value, ""); "");
// Multiple predicates, with at least one true: inherits from that one. // Multiple predicates, with at least one true: inherits from that one.
static_assert( static_assert(
std::is_base_of<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, std::is_base_of_v<
MyFalse<2>>>::value, MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, MyFalse<2>>>,
""); "");
static_assert( static_assert(
std::is_base_of<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, std::is_base_of_v<
MyTrue<2>>>::value, MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, MyTrue<2>>>,
""); "");
// Short circuiting: in the case above, additional predicates need not even // Short circuiting: in the case above, additional predicates need not even
// define a value member. // define a value member.
struct Empty {}; struct Empty {};
static_assert( static_assert(
std::is_base_of<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, std::is_base_of_v<MyTrue<1>,
Empty>>::value, internal::disjunction<MyFalse<0>, MyTrue<1>, Empty>>,
""); "");
// All predicates false: inherits from the last. // All predicates false: inherits from the last.
static_assert( static_assert(
std::is_base_of<MyFalse<2>, internal::disjunction<MyFalse<0>, MyFalse<1>, std::is_base_of_v<MyFalse<2>, internal::disjunction<
MyFalse<2>>>::value, MyFalse<0>, MyFalse<1>, MyFalse<2>>>,
""); "");
} }
@@ -747,8 +744,8 @@ TEST(ReturnTest, ConversionRequiresConstLvalueReference) {
using R = int; using R = int;
using U = std::reference_wrapper<const int>; using U = std::reference_wrapper<const int>;
static_assert(std::is_convertible<const R&, U>::value, ""); static_assert(std::is_convertible_v<const R&, U>, "");
static_assert(!std::is_convertible<R, U>::value, ""); static_assert(!std::is_convertible_v<R, U>, "");
MockFunction<U()> mock; MockFunction<U()> mock;
EXPECT_CALL(mock, Call).WillOnce(Return(17)).WillRepeatedly(Return(19)); EXPECT_CALL(mock, Call).WillOnce(Return(17)).WillRepeatedly(Return(19));
@@ -771,11 +768,11 @@ TEST(ReturnTest, ConversionRequiresMutableLvalueReference) {
S(std::string&) {} // NOLINT S(std::string&) {} // NOLINT
}; };
static_assert(std::is_convertible<std::string&, S>::value, ""); static_assert(std::is_convertible_v<std::string&, S>, "");
#ifndef _MSC_VER #ifndef _MSC_VER
static_assert(!std::is_convertible<std::string&&, S>::value, ""); static_assert(!std::is_convertible_v<std::string&&, S>, "");
#endif #endif
static_assert(!std::is_convertible<const std::string&, S>::value, ""); static_assert(!std::is_convertible_v<const std::string&, S>, "");
// It shouldn't be possible to use the result of Return(std::string) in a // It shouldn't be possible to use the result of Return(std::string) in a
// context where an S is needed. // context where an S is needed.
@@ -784,9 +781,9 @@ TEST(ReturnTest, ConversionRequiresMutableLvalueReference) {
// implementation of is_convertible causes our SFINAE to be wrong. // implementation of is_convertible causes our SFINAE to be wrong.
using RA = decltype(Return(std::string())); using RA = decltype(Return(std::string()));
static_assert(!std::is_convertible<RA, Action<S()>>::value, ""); static_assert(!std::is_convertible_v<RA, Action<S()>>, "");
#ifndef _MSC_VER #ifndef _MSC_VER
static_assert(!std::is_convertible<RA, OnceAction<S()>>::value, ""); static_assert(!std::is_convertible_v<RA, OnceAction<S()>>, "");
#endif #endif
} }
@@ -803,8 +800,8 @@ TEST(ReturnTest, MoveOnlyResultType) {
// The result of Return should not be convertible to Action (so it can't be // The result of Return should not be convertible to Action (so it can't be
// used with WillRepeatedly). // used with WillRepeatedly).
static_assert(!std::is_convertible<decltype(Return(std::unique_ptr<int>())), static_assert(!std::is_convertible_v<decltype(Return(std::unique_ptr<int>())),
Action<std::unique_ptr<int>()>>::value, Action<std::unique_ptr<int>()>>,
""); "");
} }
@@ -2196,7 +2193,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
EXPECT_EQ(x, 3); EXPECT_EQ(x, 3);
} }
ACTION(ReturnArity) { return std::tuple_size<args_type>::value; } ACTION(ReturnArity) { return std::tuple_size_v<args_type>; }
TEST(ActionMacro, LargeArity) { TEST(ActionMacro, LargeArity) {
EXPECT_EQ( EXPECT_EQ(
@@ -937,7 +937,7 @@ namespace {
template <typename Expected, typename F> template <typename Expected, typename F>
static constexpr bool IsMockFunctionTemplateArgumentDeducedTo( static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(
const internal::MockFunction<F>&) { const internal::MockFunction<F>&) {
return std::is_same<F, Expected>::value; return std::is_same_v<F, Expected>;
} }
} // namespace } // namespace
+1 -1
View File
@@ -789,7 +789,7 @@ class SampleVariantIntString {
template <typename T> template <typename T>
friend bool holds_alternative(const SampleVariantIntString& value) { friend bool holds_alternative(const SampleVariantIntString& value) {
return value.has_int_ == std::is_same<T, int>::value; return value.has_int_ == std::is_same_v<T, int>;
} }
template <typename T> template <typename T>
+1 -2
View File
@@ -123,8 +123,7 @@ struct GtestGreaterThanMatcher {
}; };
template <typename T> template <typename T>
GtestGreaterThanMatcher<typename std::decay<T>::type> GtestGreaterThan( GtestGreaterThanMatcher<std::decay_t<T>> GtestGreaterThan(T&& rhs) {
T&& rhs) {
return {rhs}; return {rhs};
} }