William A. Kennington III | feef68f | 2018-07-17 14:40:14 -0700 | [diff] [blame^] | 1 | #include <gtest/gtest.h> |
| 2 | #include <sdeventplus/internal/utils.hpp> |
| 3 | #include <stdexcept> |
| 4 | #include <system_error> |
| 5 | |
| 6 | namespace sdeventplus |
| 7 | { |
| 8 | namespace internal |
| 9 | { |
| 10 | namespace |
| 11 | { |
| 12 | |
| 13 | TEST(UtilsTest, PerformCallbackSuccess) |
| 14 | { |
| 15 | EXPECT_EQ(0, performCallback([]() {})); |
| 16 | } |
| 17 | |
| 18 | TEST(UtilsTest, SetPrepareSystemError) |
| 19 | { |
| 20 | EXPECT_EQ(-EBUSY, performCallback([]() { |
| 21 | throw std::system_error(EBUSY, std::generic_category()); |
| 22 | })); |
| 23 | } |
| 24 | |
| 25 | TEST(UtilsTest, SetPrepareException) |
| 26 | { |
| 27 | EXPECT_EQ(-ENOSYS, |
| 28 | performCallback([]() { throw std::runtime_error("Exception"); })); |
| 29 | } |
| 30 | |
| 31 | TEST(UtilsTest, SetPrepareUnknownException) |
| 32 | { |
| 33 | EXPECT_EQ(-ENOSYS, performCallback([]() { throw static_cast<int>(1); })); |
| 34 | } |
| 35 | |
| 36 | } // namespace |
| 37 | } // namespace internal |
| 38 | } // namespace sdeventplus |