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
f3b268d8
Commit
f3b268d8
authored
Sep 01, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: no tests for error cases of zmq_socket_get_peer_state
Solution: added tests
parent
eeccbbd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
test_router_mandatory.cpp
tests/test_router_mandatory.cpp
+40
-0
No files found.
tests/test_router_mandatory.cpp
View file @
f3b268d8
...
...
@@ -177,6 +177,45 @@ void test_get_peer_state ()
#endif
}
void
test_get_peer_state_corner_cases
()
{
#ifdef ZMQ_BUILD_DRAFT_API
const
char
peer_identity
[]
=
"foo"
;
// call get_peer_state with NULL socket
int
rc
=
zmq_socket_get_peer_state
(
NULL
,
peer_identity
,
strlen
(
peer_identity
));
assert
(
rc
==
-
1
&&
errno
==
ENOTSOCK
);
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
dealer
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
dealer
);
void
*
router
=
zmq_socket
(
ctx
,
ZMQ_ROUTER
);
assert
(
router
);
// call get_peer_state with a non-ROUTER socket
rc
=
zmq_socket_get_peer_state
(
dealer
,
peer_identity
,
strlen
(
peer_identity
));
assert
(
rc
==
-
1
&&
errno
==
ENOTSUP
);
// call get_peer_state for an unknown identity
rc
=
zmq_socket_get_peer_state
(
router
,
peer_identity
,
strlen
(
peer_identity
));
assert
(
rc
==
-
1
&&
errno
==
EHOSTUNREACH
);
rc
=
zmq_close
(
router
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
dealer
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
#endif
}
void
test_basic
()
{
size_t
len
=
MAX_SOCKET_STRING
;
...
...
@@ -247,6 +286,7 @@ int main (void)
test_basic
();
test_get_peer_state
();
test_get_peer_state_corner_cases
();
return
0
;
}
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