diff options
Diffstat (limited to 'absl/types/any_exception_safety_test.cc')
-rw-r--r-- | absl/types/any_exception_safety_test.cc | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/absl/types/any_exception_safety_test.cc b/absl/types/any_exception_safety_test.cc index 82c176b518a9..7a72e7263922 100644 --- a/absl/types/any_exception_safety_test.cc +++ b/absl/types/any_exception_safety_test.cc @@ -30,11 +30,6 @@ using ThrowingThrowerVec = std::vector<Thrower, ThrowingAlloc>; namespace { -class AnyExceptionSafety : public ::testing::Test { - private: - absl::ConstructorTracker inspector_; -}; - testing::AssertionResult AnyInvariants(absl::any* a) { using testing::AssertionFailure; using testing::AssertionSuccess; @@ -84,22 +79,24 @@ testing::AssertionResult AnyIsEmpty(absl::any* a) { << absl::any_cast<Thrower>(*a).Get(); } -TEST_F(AnyExceptionSafety, Ctors) { +TEST(AnyExceptionSafety, Ctors) { Thrower val(1); - auto with_val = absl::TestThrowingCtor<absl::any>(val); - auto copy = absl::TestThrowingCtor<absl::any>(with_val); - auto in_place = - absl::TestThrowingCtor<absl::any>(absl::in_place_type_t<Thrower>(), 1); - auto in_place_list = absl::TestThrowingCtor<absl::any>( - absl::in_place_type_t<ThrowerVec>(), ThrowerList{val}); - auto in_place_list_again = - absl::TestThrowingCtor<absl::any, - absl::in_place_type_t<ThrowingThrowerVec>, - ThrowerList, ThrowingAlloc>( - absl::in_place_type_t<ThrowingThrowerVec>(), {val}, ThrowingAlloc()); + absl::TestThrowingCtor<absl::any>(val); + + Thrower copy(val); + absl::TestThrowingCtor<absl::any>(copy); + + absl::TestThrowingCtor<absl::any>(absl::in_place_type_t<Thrower>(), 1); + + absl::TestThrowingCtor<absl::any>(absl::in_place_type_t<ThrowerVec>(), + ThrowerList{val}); + + absl::TestThrowingCtor<absl::any, absl::in_place_type_t<ThrowingThrowerVec>, + ThrowerList, ThrowingAlloc>( + absl::in_place_type_t<ThrowingThrowerVec>(), {val}, ThrowingAlloc()); } -TEST_F(AnyExceptionSafety, Assignment) { +TEST(AnyExceptionSafety, Assignment) { auto original = absl::any(absl::in_place_type_t<Thrower>(), 1, absl::no_throw_ctor); auto any_is_strong = [original](absl::any* ap) { @@ -139,7 +136,7 @@ TEST_F(AnyExceptionSafety, Assignment) { } // libstdc++ std::any fails this test #if !defined(ABSL_HAVE_STD_ANY) -TEST_F(AnyExceptionSafety, Emplace) { +TEST(AnyExceptionSafety, Emplace) { auto initial_val = absl::any{absl::in_place_type_t<Thrower>(), 1, absl::no_throw_ctor}; auto one_tester = absl::MakeExceptionSafetyTester() |