Commit Graph

130 Commits

Author SHA1 Message Date
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
131d2ec487 Problem: googletest is also installed into install destination
Building and installing cppzmq brings googletest build artifacts to the
installation destination as well. For example someone building cppzmq
with:
```
cmake -DCMAKE_INSTALL_PREFIX=mydest .
cmake --build --target install
```
gets googletest headers and libraries in `mydest`.

Solution: remove googletest from install target
2018-04-29 12:57:32 +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
Simon Giesecke
4d0418750e Problem: no tests for move-assignment
Solution: added test cases
2018-04-13 11:35:00 -04:00
Simon Giesecke
438bad28e6 Problem: insufficient test cases for operator==
Solution: added test cases
2018-04-13 11:24:36 -04:00
Simon Giesecke
799c89cb09 Problem: several test cases mixed in message.constructors
Solution: split up into test cases for various ctors and equality operators
2018-04-13 11:20:07 -04:00
Pawel Kurdybacha
f518a648ef Problem: extended initializer lists only available in C++11 2018-04-14 14:06:32 +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
Simon Giesecke
83f854869a Problem: no tests for socket_t ctor accepting enum socket_type
Solution: added test case
2018-04-03 18:41:44 +02:00
Simon Giesecke
1616c0fad2 Problem: test file not correctly named
Solution: move and split example_add.cpp
2018-04-03 18:41:44 +02:00
Simon Giesecke
63f81e40d6 Problem: code coverage not working
Solution: build tests within cppzmq build, and add separate demo
2018-04-03 18:41:32 +02:00
Simon Giesecke
b737b9f1de Problem: no test cases
Solution: added a few initial test cases
2018-04-02 14:13:05 +02:00
Simon Giesecke
07b583a99a Problem: test not using cppzmq
Solution: add dependency on cppzmq
2018-03-29 18:46:04 +02:00
Simon Giesecke
968473cdba Problem: no test infrastructure
Solution: integrate googletest, with non-cppzmq test case for a start
2018-03-29 18:11:28 +02:00