blob: b34398db2021e67811a0588a08ea674c04d1665f [file] [log] [blame]
Hannu Lounento90f8d9b2023-03-13 11:05:08 +02001#include <sdbusplus/bus.hpp>
2#include <sdbusplus/test/sdbus_mock.hpp>
3
4#include <exception>
5
6#include <gtest/gtest.h>
7
8class 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
22TEST_F(Exception, BusProcessRethrowsTheCurrentException)
23{
24 EXPECT_THROW(bus.process(), std::runtime_error);
25}
26
27TEST_F(Exception, BusProcessDiscardRethrowsTheCurrentException)
28{
29 EXPECT_THROW(bus.process_discard(), std::runtime_error);
30}