about summary refs log tree commit diff
path: root/absl/base/internal/exception_safety_testing.cc
blob: 32d904ed23fa385a895f30af47bf898a8e2a3660 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "absl/base/internal/exception_safety_testing.h"

#include "gtest/gtest.h"
#include "absl/meta/type_traits.h"

namespace absl {
exceptions_internal::NoThrowTag no_throw_ctor;
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 thrown from " << e.what();
}
}  // namespace exceptions_internal
}  // namespace absl