test_scatter_gather.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include "testutil.hpp"
4 #include "testutil_unity.hpp"
5 
7 
9 {
10  void *scatter = test_context_socket (ZMQ_SCATTER);
11  void *gather = test_context_socket (ZMQ_GATHER);
12 
14  zmq_bind (scatter, "inproc://test-scatter-gather"));
15 
17  zmq_connect (gather, "inproc://test-scatter-gather"));
18 
19  // Should fail, multipart is not supported
21  zmq_send_const (scatter, "1", 1, ZMQ_SNDMORE));
22 
23  test_context_socket_close (scatter);
25 }
26 
28 {
29  void *scatter = test_context_socket (ZMQ_SCATTER);
30  void *gather = test_context_socket (ZMQ_GATHER);
31  void *gather2 = test_context_socket (ZMQ_GATHER);
32 
34  zmq_bind (scatter, "inproc://test-scatter-gather"));
35 
37  zmq_connect (gather, "inproc://test-scatter-gather"));
38 
40  zmq_connect (gather2, "inproc://test-scatter-gather"));
41 
42  send_string_expect_success (scatter, "1", 0);
43  send_string_expect_success (scatter, "2", 0);
44 
45  recv_string_expect_success (gather, "1", 0);
46  recv_string_expect_success (gather2, "2", 0);
47 
48  test_context_socket_close (scatter);
50  test_context_socket_close (gather2);
51 }
52 
53 int main ()
54 {
56 
57  UNITY_BEGIN ();
60  return UNITY_END ();
61 }
ZMQ_GATHER
#define ZMQ_GATHER
Definition: zmq_draft.h:18
main
int main()
Definition: test_scatter_gather.cpp:53
UNITY_END
return UNITY_END()
EINVAL
#define EINVAL
Definition: errno.hpp:25
RUN_TEST
#define RUN_TEST(func)
Definition: unity_internals.h:615
SETUP_TEARDOWN_TESTCONTEXT
#define SETUP_TEARDOWN_TESTCONTEXT
Definition: testutil_unity.hpp:172
zmq_connect
ZMQ_EXPORT int zmq_connect(void *s_, const char *addr_)
Definition: zmq.cpp:307
test_scatter_gather_multipart_fails
SETUP_TEARDOWN_TESTCONTEXT void test_scatter_gather_multipart_fails()
Definition: test_scatter_gather.cpp:8
testutil_unity.hpp
zmq_send_const
ZMQ_EXPORT int zmq_send_const(void *s_, const void *buf_, size_t len_, int flags_)
Definition: zmq.cpp:400
testutil.hpp
test_scatter_gather
void test_scatter_gather()
Definition: test_scatter_gather.cpp:27
zmq_bind
ZMQ_EXPORT int zmq_bind(void *s_, const char *addr_)
Definition: zmq.cpp:299
test_context_socket
void * test_context_socket(int type_)
Definition: testutil_unity.cpp:200
send_string_expect_success
void send_string_expect_success(void *socket_, const char *str_, int flags_)
Definition: testutil_unity.cpp:94
ZMQ_SCATTER
#define ZMQ_SCATTER
Definition: zmq_draft.h:19
recv_string_expect_success
void recv_string_expect_success(void *socket_, const char *str_, int flags_)
Definition: testutil_unity.cpp:101
setup_test_environment
void setup_test_environment(int timeout_seconds_)
Definition: testutil.cpp:201
UNITY_BEGIN
UNITY_BEGIN()
ZMQ_SNDMORE
#define ZMQ_SNDMORE
Definition: zmq.h:359
TEST_ASSERT_FAILURE_ERRNO
#define TEST_ASSERT_FAILURE_ERRNO(error_code, expr)
Definition: testutil_unity.hpp:95
test_context_socket_close
void * test_context_socket_close(void *socket_)
Definition: testutil_unity.cpp:208
TEST_ASSERT_SUCCESS_ERRNO
#define TEST_ASSERT_SUCCESS_ERRNO(expr)
Definition: proxy_thr.cpp:47


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59