Skip to content

Commit 7ff3427

Browse files
committed
Fix some TriviallyRelocatable test issues
1 parent 0f17a16 commit 7ff3427

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

absl/meta/type_traits_test.cc

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ TEST(TriviallyRelocatable, PrimitiveTypes) {
751751

752752
// User-defined types can be trivially relocatable as long as they don't have a
753753
// user-provided move constructor or destructor.
754-
TEST(TriviallyRelocatable, UserDefinedTriviallyReconstructible) {
754+
TEST(TriviallyRelocatable, UserDefinedTriviallyRelocatable) {
755755
struct S {
756756
int x;
757757
int y;
@@ -780,6 +780,28 @@ TEST(TriviallyRelocatable, UserProvidedCopyConstructor) {
780780
static_assert(!absl::is_trivially_relocatable<S>::value, "");
781781
}
782782

783+
// A user-provided copy assignment operator disqualifies a type from
784+
// being trivially relocatable.
785+
TEST(TriviallyRelocatable, UserProvidedCopyAssignment) {
786+
struct S {
787+
S(const S&) = default;
788+
S& operator=(const S&) { return *this; } // NOLINT(modernize-use-equals-default)
789+
};
790+
791+
static_assert(!absl::is_trivially_relocatable<S>::value, "");
792+
}
793+
794+
// A user-provided move assignment operator disqualifies a type from
795+
// being trivially relocatable.
796+
TEST(TriviallyRelocatable, UserProvidedMoveAssignment) {
797+
struct S {
798+
S(S&&) = default;
799+
S& operator=(S&&) { return *this; } // NOLINT(modernize-use-equals-default)
800+
};
801+
802+
static_assert(!absl::is_trivially_relocatable<S>::value, "");
803+
}
804+
783805
// A user-provided destructor disqualifies a type from being trivially
784806
// relocatable.
785807
TEST(TriviallyRelocatable, UserProvidedDestructor) {
@@ -801,10 +823,12 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) {
801823
// A type marked with the "trivial ABI" attribute is trivially relocatable even
802824
// if it has user-provided move/copy constructors and a user-provided
803825
// destructor.
804-
TEST(TrivallyRelocatable, TrivialAbi) {
826+
TEST(TriviallyRelocatable, TrivialAbi) {
805827
struct ABSL_ATTRIBUTE_TRIVIAL_ABI S {
806828
S(S&&) {} // NOLINT(modernize-use-equals-default)
807829
S(const S&) {} // NOLINT(modernize-use-equals-default)
830+
void operator=(S&&) {}
831+
void operator=(const S&) {}
808832
~S() {} // NOLINT(modernize-use-equals-default)
809833
};
810834

@@ -824,7 +848,7 @@ constexpr int64_t NegateIfConstantEvaluated(int64_t i) {
824848

825849
#endif // ABSL_HAVE_CONSTANT_EVALUATED
826850

827-
TEST(TrivallyRelocatable, is_constant_evaluated) {
851+
TEST(IsConstantEvaluated, is_constant_evaluated) {
828852
#ifdef ABSL_HAVE_CONSTANT_EVALUATED
829853
constexpr int64_t constant = NegateIfConstantEvaluated(42);
830854
EXPECT_EQ(constant, -42);

0 commit comments

Comments
 (0)