William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 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; |
William A. Kennington III | 0a816c5 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 14 | const char* const prefix = "construct_test"; |
William A. Kennington III | 8f90e28 | 2018-07-17 14:40:14 -0700 | [diff] [blame] | 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 |