From 7c402e2804eb7850943fad182e2c810bc93a762e Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Mon, 5 Feb 2024 01:51:21 +0100 Subject: [PATCH] restore fail func --- src/logging_unittest.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index 021791ff3..b2d170571 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -1582,6 +1582,8 @@ TEST(Logging, FatalThrow) { # endif // __has_attribute(noreturn) #endif // defined(__has_attribute) { throw std::logic_error{"fail"}; }); - EXPECT_THROW(LOG(FATAL) << "must throw to fail", std::logic_error); - InstallFailureFunction(fail_func); + auto restore_fail = [fail_func] { InstallFailureFunction(fail_func); }; + ScopedExit restore{restore_fail}; + EXPECT_THROW({ LOG(FATAL) << "must throw to fail"; }, std::logic_error); + }