diff options
Diffstat (limited to 'absl/base/internal/exception_safety_testing.cc')
-rw-r--r-- | absl/base/internal/exception_safety_testing.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/absl/base/internal/exception_safety_testing.cc b/absl/base/internal/exception_safety_testing.cc new file mode 100644 index 000000000000..383c9c595251 --- /dev/null +++ b/absl/base/internal/exception_safety_testing.cc @@ -0,0 +1,21 @@ +#include "absl/base/internal/exception_safety_testing.h" + +#include "gtest/gtest.h" +#include "absl/meta/type_traits.h" + +namespace absl { +namespace exceptions_internal { + +int countdown = -1; + +void MaybeThrow(absl::string_view msg) { + if (countdown-- == 0) throw TestException(msg); +} + +testing::AssertionResult FailureMessage(const TestException& e, + int countdown) noexcept { + return testing::AssertionFailure() + << "Exception number " << countdown + 1 << " thrown from " << e.what(); +} +} // namespace exceptions_internal +} // namespace absl |