mirror of
https://github.com/google/googletest.git
synced 2026-07-30 16:26:24 +08:00
Automated Code Change
PiperOrigin-RevId: 936616624 Change-Id: I3a05afadf807fc372337186c26b5d73a2bc21410
This commit is contained in:
parent
1fc11dea10
commit
aa40ee603e
@ -66,30 +66,30 @@ using ::testing::internal::BuiltInDefaultValue;
|
||||
|
||||
TEST(TypeTraits, Negation) {
|
||||
// Direct use with std types.
|
||||
static_assert(std::is_base_of<std::false_type,
|
||||
internal::negation<std::true_type>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
std::is_base_of_v<std::false_type, internal::negation<std::true_type>>,
|
||||
"");
|
||||
|
||||
static_assert(std::is_base_of<std::true_type,
|
||||
internal::negation<std::false_type>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
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
|
||||
// convertible to bool.
|
||||
static_assert(std::is_base_of<
|
||||
std::true_type,
|
||||
internal::negation<std::integral_constant<int, 0>>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
std::is_base_of_v<std::true_type,
|
||||
internal::negation<std::integral_constant<int, 0>>>,
|
||||
"");
|
||||
|
||||
static_assert(std::is_base_of<
|
||||
std::false_type,
|
||||
internal::negation<std::integral_constant<int, 1>>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
std::is_base_of_v<std::false_type,
|
||||
internal::negation<std::integral_constant<int, 1>>>,
|
||||
"");
|
||||
|
||||
static_assert(std::is_base_of<
|
||||
std::false_type,
|
||||
internal::negation<std::integral_constant<int, -1>>>::value,
|
||||
"");
|
||||
static_assert(
|
||||
std::is_base_of_v<std::false_type,
|
||||
internal::negation<std::integral_constant<int, -1>>>,
|
||||
"");
|
||||
}
|
||||
|
||||
// Weird false/true types that aren't actually bool constants (but should still
|
||||
@ -108,79 +108,76 @@ struct MyTrue : std::integral_constant<int, -1> {};
|
||||
|
||||
TEST(TypeTraits, Conjunction) {
|
||||
// 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.
|
||||
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(
|
||||
std::is_base_of<MyTrue<0>, internal::conjunction<MyTrue<0>>>::value, "");
|
||||
static_assert(std::is_base_of_v<MyTrue<0>, internal::conjunction<MyTrue<0>>>,
|
||||
"");
|
||||
|
||||
// Multiple predicates, with at least one false: inherits from that one.
|
||||
static_assert(
|
||||
std::is_base_of<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>,
|
||||
MyTrue<2>>>::value,
|
||||
std::is_base_of_v<
|
||||
MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>, MyTrue<2>>>,
|
||||
"");
|
||||
|
||||
static_assert(
|
||||
std::is_base_of<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>,
|
||||
MyFalse<2>>>::value,
|
||||
std::is_base_of_v<
|
||||
MyFalse<1>, internal::conjunction<MyTrue<0>, 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<MyFalse<1>, internal::conjunction<MyTrue<0>, MyFalse<1>,
|
||||
Empty>>::value,
|
||||
std::is_base_of_v<MyFalse<1>,
|
||||
internal::conjunction<MyTrue<0>, MyFalse<1>, Empty>>,
|
||||
"");
|
||||
|
||||
// All predicates true: inherits from the last.
|
||||
static_assert(
|
||||
std::is_base_of<MyTrue<2>, internal::conjunction<MyTrue<0>, MyTrue<1>,
|
||||
MyTrue<2>>>::value,
|
||||
std::is_base_of_v<MyTrue<2>,
|
||||
internal::conjunction<MyTrue<0>, MyTrue<1>, MyTrue<2>>>,
|
||||
"");
|
||||
}
|
||||
|
||||
TEST(TypeTraits, Disjunction) {
|
||||
// Base case: always false.
|
||||
static_assert(
|
||||
std::is_base_of<std::false_type, internal::disjunction<>>::value, "");
|
||||
static_assert(std::is_base_of_v<std::false_type, internal::disjunction<>>,
|
||||
"");
|
||||
|
||||
// One predicate: inherits from that predicate, regardless of value.
|
||||
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(
|
||||
std::is_base_of<MyTrue<0>, internal::disjunction<MyTrue<0>>>::value, "");
|
||||
static_assert(std::is_base_of_v<MyTrue<0>, internal::disjunction<MyTrue<0>>>,
|
||||
"");
|
||||
|
||||
// Multiple predicates, with at least one true: inherits from that one.
|
||||
static_assert(
|
||||
std::is_base_of<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>,
|
||||
MyFalse<2>>>::value,
|
||||
std::is_base_of_v<
|
||||
MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>, MyFalse<2>>>,
|
||||
"");
|
||||
|
||||
static_assert(
|
||||
std::is_base_of<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>,
|
||||
MyTrue<2>>>::value,
|
||||
std::is_base_of_v<
|
||||
MyTrue<1>, internal::disjunction<MyFalse<0>, 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<MyTrue<1>, internal::disjunction<MyFalse<0>, MyTrue<1>,
|
||||
Empty>>::value,
|
||||
std::is_base_of_v<MyTrue<1>,
|
||||
internal::disjunction<MyFalse<0>, MyTrue<1>, Empty>>,
|
||||
"");
|
||||
|
||||
// All predicates false: inherits from the last.
|
||||
static_assert(
|
||||
std::is_base_of<MyFalse<2>, internal::disjunction<MyFalse<0>, MyFalse<1>,
|
||||
MyFalse<2>>>::value,
|
||||
std::is_base_of_v<MyFalse<2>, internal::disjunction<
|
||||
MyFalse<0>, MyFalse<1>, MyFalse<2>>>,
|
||||
"");
|
||||
}
|
||||
|
||||
@ -747,8 +744,8 @@ TEST(ReturnTest, ConversionRequiresConstLvalueReference) {
|
||||
using R = int;
|
||||
using U = std::reference_wrapper<const int>;
|
||||
|
||||
static_assert(std::is_convertible<const R&, U>::value, "");
|
||||
static_assert(!std::is_convertible<R, U>::value, "");
|
||||
static_assert(std::is_convertible_v<const R&, U>, "");
|
||||
static_assert(!std::is_convertible_v<R, U>, "");
|
||||
|
||||
MockFunction<U()> 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<std::string&, S>::value, "");
|
||||
static_assert(std::is_convertible_v<std::string&, S>, "");
|
||||
#ifndef _MSC_VER
|
||||
static_assert(!std::is_convertible<std::string&&, S>::value, "");
|
||||
static_assert(!std::is_convertible_v<std::string&&, S>, "");
|
||||
#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
|
||||
// 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<RA, Action<S()>>::value, "");
|
||||
static_assert(!std::is_convertible_v<RA, Action<S()>>, "");
|
||||
#ifndef _MSC_VER
|
||||
static_assert(!std::is_convertible<RA, OnceAction<S()>>::value, "");
|
||||
static_assert(!std::is_convertible_v<RA, OnceAction<S()>>, "");
|
||||
#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<decltype(Return(std::unique_ptr<int>())),
|
||||
Action<std::unique_ptr<int>()>>::value,
|
||||
static_assert(!std::is_convertible_v<decltype(Return(std::unique_ptr<int>())),
|
||||
Action<std::unique_ptr<int>()>>,
|
||||
"");
|
||||
}
|
||||
|
||||
@ -2196,7 +2193,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
|
||||
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) {
|
||||
EXPECT_EQ(
|
||||
|
||||
@ -937,7 +937,7 @@ namespace {
|
||||
template <typename Expected, typename F>
|
||||
static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(
|
||||
const internal::MockFunction<F>&) {
|
||||
return std::is_same<F, Expected>::value;
|
||||
return std::is_same_v<F, Expected>;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -789,7 +789,7 @@ class SampleVariantIntString {
|
||||
|
||||
template <typename T>
|
||||
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>
|
||||
|
||||
@ -123,8 +123,7 @@ struct GtestGreaterThanMatcher {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
GtestGreaterThanMatcher<typename std::decay<T>::type> GtestGreaterThan(
|
||||
T&& rhs) {
|
||||
GtestGreaterThanMatcher<std::decay_t<T>> GtestGreaterThan(T&& rhs) {
|
||||
return {rhs};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user