20 #include <glog/logging.h> 49 TEST(UncaughtExceptions, no_exception) {
53 TEST(UncaughtExceptions, no_uncaught_exception) {
54 Validator validator(0,
"no_uncaught_exception");
56 throw std::runtime_error(
"exception");
57 }
catch (
const std::runtime_error& e) {
62 TEST(UncaughtExceptions, one_uncaught_exception) {
64 Validator validator(1,
"one_uncaught_exception");
65 throw std::runtime_error(
"exception");
66 }
catch (
const std::runtime_error& e) {
70 TEST(UncaughtExceptions, catch_rethrow) {
72 Validator validatorOuter(1,
"catch_rethrow_outer");
74 Validator validatorInner(1,
"catch_rethrow_inner");
75 throw std::runtime_error(
"exception");
76 }
catch (
const std::runtime_error& e) {
78 Validator validatorRethrow(1,
"catch_rethrow");
81 }
catch (
const std::runtime_error& e) {
87 Validator validator(1,
"one_uncaught_exception_in_function");
88 throw std::runtime_error(
"exception");
91 TEST(UncaughtExceptions, one_uncaught_exception_in_function) {
104 template <
size_t N,
size_t I = N>
112 (void)stackObjectThrowingOnUnwind;
114 N - I + 1,
"validating in " + folly::to<std::string>(I));
115 LOG(INFO) <<
"throwing in ~ThrowInDestructor " << I;
116 throw std::logic_error(
"inner");
117 }
catch (
const std::logic_error& e) {
118 LOG(INFO) <<
"catching in ~ThrowInDestructor " << I <<
" expecting " 120 EXPECT_EQ(N - I, folly::uncaught_exceptions());
134 TEST(UncaughtExceptions, two_uncaught_exceptions) {
138 TEST(UncaughtExceptions, ten_uncaught_exceptions) {
144 throw std::runtime_error(
"exception");
151 :
Validator(1,
"one_exception_in_ctor_initializer_expression"),
161 TEST(UncaughtExceptions, one_exception_in_ctor_initializer_expression) {
Validator(int expectedCount, const std::string &msg)
#define EXPECT_THROW(statement, expected_exception)
#define EXPECT_EQ(val1, val2)
requires E e noexcept(noexcept(s.error(std::move(e))))
int uncaught_exceptions() noexcept
InheritsThrowingConstructor()
const int32_t expectedCount_
TEST(UncaughtExceptions, no_exception)
ThrowingConstructor() noexcept(false)