diff options
Diffstat (limited to 'absl/memory/memory_exception_safety_test.cc')
-rw-r--r-- | absl/memory/memory_exception_safety_test.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/absl/memory/memory_exception_safety_test.cc b/absl/memory/memory_exception_safety_test.cc index 55e8f36f2feb..fb8b561d59fb 100644 --- a/absl/memory/memory_exception_safety_test.cc +++ b/absl/memory/memory_exception_safety_test.cc @@ -20,11 +20,14 @@ namespace absl { namespace { -using Thrower = ::testing::ThrowingValue<>; +constexpr int kLength = 50; +using Thrower = testing::ThrowingValue<testing::TypeSpec::kEverythingThrows>; +using ThrowerStorage = + absl::aligned_storage_t<sizeof(Thrower), alignof(Thrower)>; +using ThrowerList = std::array<ThrowerStorage, kLength>; TEST(MakeUnique, CheckForLeaks) { constexpr int kValue = 321; - constexpr size_t kLength = 10; auto tester = testing::MakeExceptionSafetyTester() .WithInitialValue(Thrower(kValue)) // Ensures make_unique does not modify the input. The real @@ -45,5 +48,16 @@ TEST(MakeUnique, CheckForLeaks) { })); } +TEST(MemoryInternal, UninitDefaultConstructNNonTrivial) { + EXPECT_TRUE(testing::MakeExceptionSafetyTester() + .WithInitialValue(ThrowerList{}) + .WithOperation([&](ThrowerList* list_ptr) { + absl::memory_internal::uninitialized_default_construct_n( + list_ptr->data(), kLength); + }) + .WithInvariants([&](...) { return true; }) + .Test()); +} + } // namespace } // namespace absl |