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
49e1b8b7
Commit
49e1b8b7
authored
Aug 29, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: test case in main function
Solution: extracted test_basic function
parent
4691714d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
test_router_mandatory.cpp
tests/test_router_mandatory.cpp
+14
-7
No files found.
tests/test_router_mandatory.cpp
View file @
49e1b8b7
...
...
@@ -29,9 +29,8 @@
#include "testutil.hpp"
int
main
(
void
)
void
test_basic
(
)
{
setup_test_environment
();
size_t
len
=
MAX_SOCKET_STRING
;
char
my_endpoint
[
MAX_SOCKET_STRING
];
void
*
ctx
=
zmq_ctx_new
();
...
...
@@ -55,7 +54,8 @@ int main (void)
// Send a message to an unknown peer with mandatory routing
// This will fail
int
mandatory
=
1
;
rc
=
zmq_setsockopt
(
router
,
ZMQ_ROUTER_MANDATORY
,
&
mandatory
,
sizeof
(
mandatory
));
rc
=
zmq_setsockopt
(
router
,
ZMQ_ROUTER_MANDATORY
,
&
mandatory
,
sizeof
(
mandatory
));
assert
(
rc
==
0
);
rc
=
zmq_send
(
router
,
"UNKNOWN"
,
7
,
ZMQ_SNDMORE
);
assert
(
rc
==
-
1
&&
errno
==
EHOSTUNREACH
);
...
...
@@ -69,12 +69,12 @@ int main (void)
assert
(
rc
==
0
);
// Get message from dealer to know when connection is ready
char
buffer
[
255
];
char
buffer
[
255
];
rc
=
zmq_send
(
dealer
,
"Hello"
,
5
,
0
);
assert
(
rc
==
5
);
rc
=
zmq_recv
(
router
,
buffer
,
255
,
0
);
assert
(
rc
==
1
);
assert
(
buffer
[
0
]
==
'X'
);
assert
(
buffer
[
0
]
==
'X'
);
// Send a message to connected dealer now
// It should work
...
...
@@ -82,7 +82,7 @@ int main (void)
assert
(
rc
==
1
);
rc
=
zmq_send
(
router
,
"Hello"
,
5
,
0
);
assert
(
rc
==
5
);
rc
=
zmq_close
(
router
);
assert
(
rc
==
0
);
...
...
@@ -91,6 +91,13 @@ int main (void)
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
int
main
(
void
)
{
setup_test_environment
();
test_basic
();
return
0
;
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