xref: /openbmc/sdeventplus/test/exception.cpp (revision 8f90e28b500d384fbabcf97119879c7ba3c88724)
1  #include <gtest/gtest.h>
2  #include <sdeventplus/exception.hpp>
3  #include <string>
4  #include <system_error>
5  
6  namespace sdeventplus
7  {
8  namespace
9  {
10  
11  TEST(ExceptionTest, Construct)
12  {
13      const int code = EINTR;
14      const char *const prefix = "construct_test";
15  
16      std::system_error expected(code, std::generic_category(), prefix);
17      SdEventError err(code, prefix);
18  
19      EXPECT_EQ(std::string{expected.what()}, err.what());
20      EXPECT_EQ(code, err.code().value());
21      EXPECT_EQ(std::generic_category(), err.code().category());
22  }
23  
24  } // namespace
25  } // namespace sdeventplus
26