Skip to content

Commit dc2764f

Browse files
committed
Problem: test_last_endpoint not using unity
Solution: migrate to unity
1 parent 1747cbd commit dc2764f

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ tests_test_immediate_LDADD = src/libzmq.la ${UNITY_LIBS}
493493
tests_test_immediate_CPPFLAGS = ${UNITY_CPPFLAGS}
494494

495495
tests_test_last_endpoint_SOURCES = tests/test_last_endpoint.cpp
496-
tests_test_last_endpoint_LDADD = src/libzmq.la
496+
tests_test_last_endpoint_LDADD = src/libzmq.la ${UNITY_LIBS}
497+
tests_test_last_endpoint_CPPFLAGS = ${UNITY_CPPFLAGS}
497498

498499
tests_test_term_endpoint_SOURCES = tests/test_term_endpoint.cpp
499500
tests_test_term_endpoint_LDADD = src/libzmq.la

tests/test_last_endpoint.cpp

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828
*/
2929

3030
#include "testutil.hpp"
31+
#include "testutil_unity.hpp"
32+
33+
#include <unity.h>
34+
35+
void setUp ()
36+
{
37+
setup_test_context ();
38+
}
39+
40+
void tearDown ()
41+
{
42+
teardown_test_context ();
43+
}
3144

3245
static void do_bind_and_verify (void *s, const char *endpoint)
3346
{
@@ -39,27 +52,24 @@ static void do_bind_and_verify (void *s, const char *endpoint)
3952
assert (rc == 0 && strcmp (reported, endpoint) == 0);
4053
}
4154

42-
int main (void)
55+
void test_last_endpoint ()
4356
{
44-
setup_test_environment ();
45-
// Create the infrastructure
46-
void *ctx = zmq_ctx_new ();
47-
assert (ctx);
48-
49-
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
50-
assert (sb);
57+
void *sb = test_context_socket (ZMQ_ROUTER);
5158
int val = 0;
52-
int rc = zmq_setsockopt (sb, ZMQ_LINGER, &val, sizeof (val));
53-
assert (rc == 0);
59+
TEST_ASSERT_SUCCESS_ERRNO (
60+
zmq_setsockopt (sb, ZMQ_LINGER, &val, sizeof (val)));
5461

5562
do_bind_and_verify (sb, ENDPOINT_1);
5663
do_bind_and_verify (sb, ENDPOINT_2);
5764

58-
rc = zmq_close (sb);
59-
assert (rc == 0);
65+
test_context_socket_close (sb);
66+
}
6067

61-
rc = zmq_ctx_term (ctx);
62-
assert (rc == 0);
68+
int main (void)
69+
{
70+
setup_test_environment ();
6371

64-
return 0;
72+
UNITY_BEGIN ();
73+
RUN_TEST (test_last_endpoint);
74+
return UNITY_END ();
6575
}

0 commit comments

Comments
 (0)