diff options
Diffstat (limited to 'absl/base/internal/exception_safety_testing.cc')
-rw-r--r-- | absl/base/internal/exception_safety_testing.cc | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/absl/base/internal/exception_safety_testing.cc b/absl/base/internal/exception_safety_testing.cc index d3e94074b822..f1d081f7e50d 100644 --- a/absl/base/internal/exception_safety_testing.cc +++ b/absl/base/internal/exception_safety_testing.cc @@ -21,16 +21,14 @@ namespace testing { exceptions_internal::NoThrowTag nothrow_ctor; -bool nothrow_guarantee(const void*) { - return ::testing::AssertionFailure() - << "Exception thrown violating NoThrow Guarantee"; -} exceptions_internal::StrongGuaranteeTagType strong_guarantee; namespace exceptions_internal { int countdown = -1; +ConstructorTracker* ConstructorTracker::current_tracker_instance_ = nullptr; + void MaybeThrow(absl::string_view msg, bool throw_bad_alloc) { if (countdown-- == 0) { if (throw_bad_alloc) throw TestBadAllocException(msg); @@ -43,6 +41,31 @@ testing::AssertionResult FailureMessage(const TestException& e, return testing::AssertionFailure() << "Exception thrown from " << e.what(); } +std::string GetSpecString(TypeSpec spec) { + std::string out; + absl::string_view sep; + const auto append = [&](absl::string_view s) { + absl::StrAppend(&out, sep, s); + sep = " | "; + }; + if (static_cast<bool>(TypeSpec::kNoThrowCopy & spec)) { + append("kNoThrowCopy"); + } + if (static_cast<bool>(TypeSpec::kNoThrowMove & spec)) { + append("kNoThrowMove"); + } + if (static_cast<bool>(TypeSpec::kNoThrowNew & spec)) { + append("kNoThrowNew"); + } + return out; +} + +std::string GetSpecString(AllocSpec spec) { + return static_cast<bool>(AllocSpec::kNoThrowAllocate & spec) + ? "kNoThrowAllocate" + : ""; +} + } // namespace exceptions_internal } // namespace testing |