Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
be33dce6
Commit
be33dce6
authored
Mar 14, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate tests/test_bind_after_connect_tcp.cpp to unity
parent
631de945
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
62 deletions
+38
-62
test_bind_after_connect_tcp.cpp
tests/test_bind_after_connect_tcp.cpp
+38
-62
No files found.
tests/test_bind_after_connect_tcp.cpp
View file @
be33dce6
...
...
@@ -28,70 +28,46 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unity.h>
void
setUp
()
{
setup_test_context
();
}
void
tearDown
()
{
teardown_test_context
();
}
void
test_x
()
{
void
*
sb
=
test_context_socket
(
ZMQ_DEALER
);
void
*
sc
=
test_context_socket
(
ZMQ_DEALER
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
sc
,
ENDPOINT_3
));
send_string_expect_success
(
sc
,
"foobar"
,
0
);
send_string_expect_success
(
sc
,
"baz"
,
0
);
send_string_expect_success
(
sc
,
"buzz"
,
0
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_bind
(
sb
,
ENDPOINT_3
));
recv_string_expect_success
(
sb
,
"foobar"
,
0
);
recv_string_expect_success
(
sb
,
"baz"
,
0
);
recv_string_expect_success
(
sb
,
"buzz"
,
0
);
test_context_socket_close
(
sc
);
test_context_socket_close
(
sb
);
}
int
main
(
void
)
{
setup_test_environment
();
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
sb
);
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
sc
);
int
rc
=
zmq_connect
(
sc
,
ENDPOINT_3
);
assert
(
rc
==
0
);
rc
=
zmq_send_const
(
sc
,
"foobar"
,
6
,
0
);
assert
(
rc
==
6
);
rc
=
zmq_send_const
(
sc
,
"baz"
,
3
,
0
);
assert
(
rc
==
3
);
rc
=
zmq_send_const
(
sc
,
"buzz"
,
4
,
0
);
assert
(
rc
==
4
);
rc
=
zmq_bind
(
sb
,
ENDPOINT_3
);
assert
(
rc
==
0
);
zmq_msg_t
msg
;
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_recv
(
&
msg
,
sb
,
0
);
assert
(
rc
==
6
);
void
*
data
=
zmq_msg_data
(
&
msg
);
assert
(
memcmp
(
"foobar"
,
data
,
6
)
==
0
);
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_recv
(
&
msg
,
sb
,
0
);
assert
(
rc
==
3
);
data
=
zmq_msg_data
(
&
msg
);
assert
(
memcmp
(
"baz"
,
data
,
3
)
==
0
);
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_msg_recv
(
&
msg
,
sb
,
0
);
assert
(
rc
==
4
);
data
=
zmq_msg_data
(
&
msg
);
assert
(
memcmp
(
"buzz"
,
data
,
4
)
==
0
);
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
sc
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
sb
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
return
0
;
UNITY_BEGIN
();
RUN_TEST
(
test_x
);
return
UNITY_END
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment