Commit Graph

37 Commits

Author SHA1 Message Date
hfarooq
3f6fe441e4 allow generic sequence of poller events 2023-10-26 22:03:37 +00:00
Gudmundur Adalsteinsson
851e7bcb8b Tests require full 11 support 2021-07-13 22:54:26 +00:00
Alberto Invernizzi
eddeaf44ca fix CHECK_THROWS_AS usage
"Note that the exception type is extended with const& and you should not include it yourself."

according to https://github.com/catchorg/Catch2/blob/devel/docs/assertions.md#exceptions
2021-06-30 07:14:13 +02:00
Gudmundur Adalsteinsson
2af0c0105a Problem: Poller size function missing
Solution: Add it to poller_t
2020-10-10 21:22:16 +00:00
Gudmundur Adalsteinsson
76e6bacc80 Move string literal into variable 2020-05-16 13:22:52 +00:00
Simon Giesecke
b6c79eb0c8 Reformat all files with clang-format 2020-01-28 11:11:31 +01:00
Gudmundur Adalsteinsson
0ce8ef06d5 Clean up and test event flags implementation 2019-05-15 11:32:23 +00:00
Gudmundur Adalsteinsson
0458f7d16c Problem: Type-safety of poller_t and active_poller_t can be improved (#318)
Problem: Type-safety of poller_t and active_poller_t can be improved
2019-05-15 08:35:12 +02:00
Gudmundur Adalsteinsson
3d4be814e8 Problem: send/recv functions lack type-safety
Solution: Add functions taking buffers and enum class flags
2019-05-05 22:05:47 +00:00
Gudmundur Adalsteinsson
c2e595bc69 Problem: Compiler warning in tests
Solution: Fix some compiler warnings
2019-04-14 21:34:15 +00:00
Gudmundur Adalsteinsson
83b91c8b7e Problem: Missing swap functions
Solution: Implement for socket_t, context_t, message_t and poller_t
Additionally remove dependency on <functional> by refactoring poller_t
and remove unused <unordered_map> include.
2019-04-03 13:23:17 +00:00
Simon Giesecke
4043617afe Problem: test cases for error behaviour of (active_)poller_t failing with libzmq 4.3.x
Solution: adapt test cases to changed behaviour
2019-02-04 15:25:35 +01:00
Pawel Kurdybacha
ae15964907 Problem: Dependency on googletest framework
Currently cppzmq as relatively simple and header only library depends on rather
complex unit test framework googletest.
Current issues:
- Googletest requires downloading and building it every time on travis
as cache support is limited there
- Googletest build is signifficant with comparison to cppzmq unittests
total runtime

Solution: Port existing tests to Catch - header only C++ framework and
gain ~20% build speed up on travis.

Why Catch?
It is well know C++ header only testing framework. It works well, it is
being kept up to date and maintainers seem to pay attention to
community's comments and issues.
We can not use Catch2 currently as we still support pre-C++11 compilers.
2018-10-17 15:22:07 +01:00
Simon Giesecke
ab09f5da98 Problem: addition of new single-argument message_t introduces ambiguity when calling e.g. socket_t::send
Solution: make single-argument constructor explicit
2018-08-21 13:50:02 +02:00
Pawel Kurdybacha
ff3c221516 Problem: whitespace style too restrictive.
For header only library like cppzmq, whitespace style inherited from
libzmq is too restrictive.

Solution: relaxing whitespace before parens from always to in control
statements only, increased max column width from 80 to 85 and removing
requirement of whitespace after template keyword.
2018-05-12 17:28:28 +01:00
Pawel Kurdybacha
5031278f18 Problem: project files do not follow clang-format 2018-05-11 20:29:15 +01:00
Simon Giesecke
762b0131e8 Problem: no tests for poller_t
Solution: add tests
2018-05-11 12:31:17 +02:00
Simon Giesecke
882f5e844c Problem: extra abstraction layer type poller_t is in zmq.hpp
Solution: move to zmq_addon.hpp, rename to active_poller_t, and rename base_poller_t to poller_t
2018-05-11 11:33:53 +02:00
Simon Giesecke
89d9db7366 Problem: move poller tests are unspecific
Solution: remove redundant assertions (tested elsewhere), and add assertion behaviour of calling wait on moved-from poller
2018-05-11 11:02:59 +02:00
Simon Giesecke
bf47be0a0c Problem: poller_t adds an abstraction layer on zmq_poller_*
Solution: extract base_poller_t from poller_t, which provides a direct mapping of zmq_poller_* to C++ only
2018-05-11 11:02:27 +02:00
Pawel Kurdybacha
33025bf0e6 Problem: client/server socket types not defined.
Solution: Add ZMQ_CLIENT and ZMQ_SERVER to socket_type enum.
Update some of draft guarded unit tests to use them.
2018-05-11 06:41:53 +01:00
Pawel Kurdybacha
625a0ebb41 Unit tests for poller's move operations 2018-05-09 05:57:44 +01:00
Pawel Kurdybacha
559d373da3 Add back size method, add empty for completeness
As disscussed on #219 PR bringing back `size` method and adding `empty`
for completeness.
2018-05-09 05:44:11 +01:00
Pawel Kurdybacha
faf6671d38 Problem: poller can segfault when modified from registered handler. (#219)
* Problem: poller can segfault when modified from registred handler.

It is possible that a user would like to add/remove sockets from
handlers. As handlers and poll items might be removed while not
being processed yet - we have a segfault situation.
Provided unit test `remove_from_handler` demonstrates the problem.

Solution: Modify internal poll item data structure only after processing
of events is finished.

Please not that events processing path performance remains the same when there are
no modification (add/remove) to the poller (no rebuild) - main real use case.

As an effect of changes `size()` method has been removed as it does not
represent any meaningful information anymore. There are active and pending
(waiting for rebuild) poll items so two different sizes. User can
easily track on their side number of registered sockets if original size
information is needed.

`wait` method returns number of processed sockets now. It might be
useful information to a user for no extra cost.
2018-05-03 21:10:05 +01:00
Pawel Kurdybacha
94e0fb0bc3 Problem: deprecated poller's method in draft API
We have a deprecated method `add` in poller that contradicts purpose of a draft
API where it can change without deprecation period.

Solution: remove the method so we do not to maintain it anymore.
2018-04-26 19:50:14 +01:00
Pawel Kurdybacha
3fcd58d3f0 Problem: poller_t simple modify test case missing 2018-04-24 21:21:55 +01:00
Pawel Kurdybacha
85e05b0c88 Problem: poller_t does not support modify
Solution: Added `modify` method based on `zmq_poller_modify` and test cases
covering it.
Reduced code duplication in existing test cases by introducing
`client_server_setup` helper struct.
2018-04-24 21:16:01 +01:00
Pawel Kurdybacha
c55379d6e2 Problem: poller_t's deprecated add might throw std::bad_function_call
Issue is reproducible in deprecated add method with empty handler
followed by wait that kicks in (covered by provided unit test).

I would prefer we remove this method completely as maintaining something
that we consider `deprecated` is unnecessary in `draft` API.
2018-04-20 06:16:04 +01:00
Pawel Kurdybacha
810b87c021 Problem: poller_t invalid behaviour on invalid sockets
On adding invalid socket (e.g. after move) there was exception thrown
but leaving modified and unconsistent internal state.
Besides that there was no possibility to remove a socket that was moved
into.

Solutions: check for socket validity (added operator bool) and changed
internal unordered_map "handlers" to operator on zmq internal pointers.

Added two test cases covering the issues.
2018-04-18 07:00:41 +01:00
Pawel Kurdybacha
fdc145a09e Problem: Windows build broken because of multiple issues (#204)
* Problem: Windows build broken because of multiple issues

Windows issues:
* missing includes files
  Solution: added missing <memory> and <unordered_map>
  Here <map> was replaced with <unordered_map> as there is no need for
  sorted map.
* googletest fails because deprecation warning causing errors.
  Solution: D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING option added.
* googletest fails because by default, new Visual Studio projects
  link the C runtimes dynamically but Google Test links them statically.
  Solution: gtest_force_shared_crt=ON option added.

Besides that adding appveyor.yml configuration to add Windows build to
CI in order to prevent accidental Windows build breakage.
For now only Debug configuration as Release requires more time to figure
out.

* Problem: Windows build takes too long

Solution: disabling tests and perf tools

* Problem: Windows unit_tests executable not finding lizmq dll.

Solution: copy libzmq dll to build bin directory.

* Problem: Windows build fails because wrong test path provided
2018-04-17 09:29:47 +01:00
Pawel Kurdybacha
6caa5d19d3 Problem: message_t should be easier to construct
* Added overload constructor (c++11 only) taking iteratable object.
  It would be easier to use std::string, std::array etc to construct
  a message now. Making it a draft for now in case it is too greedy
  and needs to be more specialize.
* Added equal and not euqal operator to message_t as a recommended
  and expected way of comparing objects in C++.
* deprecated C style equal method as operator== should be used instead
  (point above).
* Added message_t test covering all available message_t's constructors
2018-04-14 12:13:44 +01:00
Pawel Kurdybacha
40c55018b2 Problem: create_destroy test not assigned properly 2018-04-13 17:38:51 +01:00
Pawel Kurdybacha
8353e8460f Problem: non consistent whitespace formatting
* Converted tabs to to 4 spaces to be consistend with the rest of the
code
* Stripped white spaces from the end of lines
2018-04-13 17:35:41 +01:00
Simon Giesecke
5b1ab44264 Problem: insufficient tests for poller_t, bad usability since caller of add must store function object
Solution: added tests, added size() method, added add deprecated overload with former signature, changed new add signature to accept handler by value
2018-04-13 16:24:46 +02:00
Pawel Kurdybacha
1975818171 Problem: poller's handler not aware of event type. (#200)
* Problem: Poller's handler not aware of event type.

It was possible to register a handler for more than one event types but
impossible to distinguish which event is being handled.
Now events are passed to a handler.

Besides that some other changes:
* new test covering changes in the poller
* modified existing tests to cover changes in the poller
* defined handler_t in poller_t scope for more convinient use
  and simpler code
* helper loopback binder to be re-used in tests

* Problem: CMake build fails on Windows

Issue #199

It seems that with GCC on Linux <array> is implicitly included
by one of stl includes already in zmq.hpp but it breaks on Windows
with Visual Studio.

Adding explicit include for array.

Can not verify right now but this change is a good practice
so creating a pull request.

* Poller: array include not between C++11 guards
2018-04-09 08:22:31 +01:00
Pawel Kurdybacha
18f8035ba8 Problem: poller_t does not have great test coverage
@sigiesec's recent commits with gtests and basics tests for zmq
types (thanks for that!) makes it too convinient to not add some more tests.

* Adding some simple tests for poller_t
* Stripped whitespaces from poller implementation.
2018-04-07 23:00:10 +01:00
Simon Giesecke
cc5f4050dc Problem: no build/tests with DRAFT
Solution: added initial test case
2018-04-03 18:41:44 +02:00