1 #include <sdbusplus/bus.hpp> 2 #include <sdbusplus/test/sdbus_mock.hpp> 3 4 #include <exception> 5 6 #include <gtest/gtest.h> 7 8 class Exception : public ::testing::Test 9 { 10 protected: 11 sdbusplus::SdBusMock sdbusMock; 12 sdbusplus::bus_t bus = sdbusplus::get_mocked_new(&sdbusMock); 13 std::exception_ptr e = 14 std::make_exception_ptr(std::runtime_error{"current exception"}); 15 16 void SetUp() override 17 { 18 bus.set_current_exception(e); 19 } 20 }; 21 22 TEST_F(Exception, BusProcessRethrowsTheCurrentException) 23 { 24 EXPECT_THROW(bus.process(), std::runtime_error); 25 } 26 27 TEST_F(Exception, BusProcessDiscardRethrowsTheCurrentException) 28 { 29 EXPECT_THROW(bus.process_discard(), std::runtime_error); 30 } 31