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