blob: 7685a881d250c943e5d6960c33d4807b8d2b4496 [file] [log] [blame]
William A. Kennington III8f90e282018-07-17 14:40:14 -07001#include <sdeventplus/exception.hpp>
Patrick Williamsa8c11e32023-05-10 07:50:56 -05002
William A. Kennington III8f90e282018-07-17 14:40:14 -07003#include <string>
4#include <system_error>
5
Patrick Williamsa8c11e32023-05-10 07:50:56 -05006#include <gtest/gtest.h>
7
William A. Kennington III8f90e282018-07-17 14:40:14 -07008namespace sdeventplus
9{
10namespace
11{
12
13TEST(ExceptionTest, Construct)
14{
15 const int code = EINTR;
William A. Kennington III0a816c52018-07-17 14:40:14 -070016 const char* const prefix = "construct_test";
William A. Kennington III8f90e282018-07-17 14:40:14 -070017
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