William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 1 | #include <sdeventplus/exception.hpp> |
Patrick Williams | a8c11e3 | 2023-05-10 07:50:56 -0500 | [diff] [blame] | 2 | |
William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 3 | #include <string> |
| 4 | #include <system_error> |
| 5 | |
Patrick Williams | a8c11e3 | 2023-05-10 07:50:56 -0500 | [diff] [blame] | 6 | #include <gtest/gtest.h> |
| 7 | |
William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 8 | namespace sdeventplus |
| 9 | { |
| 10 | namespace |
| 11 | { |
| 12 | |
| 13 | TEST(ExceptionTest, Construct) |
| 14 | { |
| 15 | const int code = EINTR; |
William A. Kennington III | 0a816c5 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 16 | const char* const prefix = "construct_test"; |
William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 17 | |
| 18 | std::system_error expected(code, std::generic_category(), prefix); |
| 19 | SdEventError err(code, prefix); |
| 20 | |
| 21 | EXPECT_EQ(std::string{expected.what()}, err.what()); |
| 22 | EXPECT_EQ(code, err.code().value()); |
| 23 | EXPECT_EQ(std::generic_category(), err.code().category()); |
| 24 | } |
| 25 | |
| 26 | } // namespace |
| 27 | } // namespace sdeventplus |