From bff94231504bc7456b4aa99b27e22bf239cff47d Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 6 Dec 2017 10:36:04 -0800 Subject: [PATCH] Changes imported from Abseil "staging" branch: - 221bfcc1d2583d8bdf1f3745fa0496f92338d38a Update type_traits_test to avoid depending on triviality ... by Matt Calabrese GitOrigin-RevId: 221bfcc1d2583d8bdf1f3745fa0496f92338d38a Change-Id: I7db0f32479673d21b6976f43baaf3c18f0b73e47 --- absl/meta/type_traits_test.cc | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/absl/meta/type_traits_test.cc b/absl/meta/type_traits_test.cc index 15e1c28b..f0e341f5 100644 --- a/absl/meta/type_traits_test.cc +++ b/absl/meta/type_traits_test.cc @@ -26,6 +26,12 @@ namespace { using ::testing::StaticAssertTypeEq; +template +struct simple_pair { + T first; + U second; +}; + struct Dummy {}; TEST(VoidTTest, BasicUsage) { @@ -205,9 +211,9 @@ TEST(TypeTraitsTest, TestTrivialDefaultCtor) { EXPECT_TRUE( absl::is_trivially_default_constructible::value); - // Verify that std::pair has non-trivial constructors. - EXPECT_FALSE( - (absl::is_trivially_default_constructible>::value)); + // Verify that simple_pair has trivial constructors where applicable. + EXPECT_TRUE((absl::is_trivially_default_constructible< + simple_pair>::value)); // Verify that types without trivial constructors are // correctly marked as such. @@ -254,11 +260,11 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) { // Verify that std pair of such types is trivially copy constructible EXPECT_TRUE( - (absl::is_trivially_copy_constructible>::value)); - EXPECT_TRUE( - (absl::is_trivially_copy_constructible>::value)); + (absl::is_trivially_copy_constructible>::value)); + EXPECT_TRUE(( + absl::is_trivially_copy_constructible>::value)); EXPECT_TRUE((absl::is_trivially_copy_constructible< - std::pair>::value)); + simple_pair>::value)); // Verify that arrays are not typedef int int10[10]; @@ -267,9 +273,9 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) { // Verify that pairs of types without trivial copy constructors // are not marked as trivial. EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair>::value)); + simple_pair>::value)); EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair>::value)); + simple_pair>::value)); // Verify that types without trivial copy constructors are // correctly marked as such. @@ -317,9 +323,9 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) { typedef int int10[10]; EXPECT_FALSE(absl::is_trivially_copy_assignable::value); - // Verify that std::pair is not trivially assignable - EXPECT_FALSE( - (absl::is_trivially_copy_assignable>::value)); + // Verify that simple_pair is trivially assignable + EXPECT_TRUE( + (absl::is_trivially_copy_assignable>::value)); // Verify that types without trivial copy constructors are // correctly marked as such. @@ -357,10 +363,10 @@ TEST(TypeTraitsTest, TestTrivialDestructor) { EXPECT_TRUE(absl::is_trivially_destructible::value); EXPECT_FALSE(absl::is_trivially_destructible::value); - // std::pair of such types is trivial - EXPECT_TRUE((absl::is_trivially_destructible>::value)); + // simple_pair of such types is trivial + EXPECT_TRUE((absl::is_trivially_destructible>::value)); EXPECT_TRUE((absl::is_trivially_destructible< - std::pair>::value)); + simple_pair>::value)); // array of such types is trivial typedef int int10[10];