Skip to content

Commit

Permalink
Merge pull request #324 from gummif/gfa/event-flags
Browse files Browse the repository at this point in the history
Clean up and test event flags implementation
  • Loading branch information
sigiesec authored May 29, 2019
2 parents 7f9da8d + 0ce8ef0 commit 0672e31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions tests/poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ static_assert(!std::is_copy_constructible<zmq::poller_t<>>::value,
static_assert(!std::is_copy_assignable<zmq::poller_t<>>::value,
"poller_t should not be copy-assignable");

TEST_CASE("event flags", "[poller]")
{
CHECK((zmq::event_flags::pollin | zmq::event_flags::pollout)
== static_cast<zmq::event_flags>(ZMQ_POLLIN | ZMQ_POLLOUT));
CHECK((zmq::event_flags::pollin & zmq::event_flags::pollout)
== static_cast<zmq::event_flags>(ZMQ_POLLIN & ZMQ_POLLOUT));
CHECK((zmq::event_flags::pollin ^ zmq::event_flags::pollout)
== static_cast<zmq::event_flags>(ZMQ_POLLIN ^ ZMQ_POLLOUT));
CHECK(~zmq::event_flags::pollin == static_cast<zmq::event_flags>(~ZMQ_POLLIN));
}

TEST_CASE("poller create destroy", "[poller]")
{
zmq::poller_t<> a;
Expand Down
10 changes: 7 additions & 3 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1837,15 +1837,19 @@ enum class event_flags : short

constexpr event_flags operator|(event_flags a, event_flags b) noexcept
{
return static_cast<event_flags>(static_cast<short>(a) | static_cast<short>(b));
return detail::enum_bit_or(a, b);
}
constexpr event_flags operator&(event_flags a, event_flags b) noexcept
{
return static_cast<event_flags>(static_cast<short>(a) & static_cast<short>(b));
return detail::enum_bit_and(a, b);
}
constexpr event_flags operator^(event_flags a, event_flags b) noexcept
{
return detail::enum_bit_xor(a, b);
}
constexpr event_flags operator~(event_flags a) noexcept
{
return static_cast<event_flags>(~static_cast<short>(a));
return detail::enum_bit_not(a);
}

struct no_user_data;
Expand Down

0 comments on commit 0672e31

Please sign in to comment.