Commit a5ee4fb0 authored by Simon Giesecke's avatar Simon Giesecke

Problem: code duplication for multiple transports, multiple test cases combined in one

Solution: split test cases and remove code duplication
parent 06f5a6f2
......@@ -247,36 +247,47 @@ void test_reset_hwm ()
test_context_socket_close (pub_socket);
}
void test_tcp ()
void test_defaults_large (const char *bind_endpoint_)
{
// send 1000 msg on hwm 1000, receive 1000, on TCP transport
TEST_ASSERT_EQUAL_INT (1000,
test_defaults (1000, 1000, "tcp://127.0.0.1:*"));
// send 100 msg on hwm 100, receive 100
TEST_ASSERT_EQUAL_INT (100, test_defaults (100, 100, "tcp://127.0.0.1:*"));
// send 6000 msg on hwm 2000, drops above hwm, only receive hwm:
TEST_ASSERT_EQUAL_INT (6000,
test_blocking (2000, 6000, "tcp://127.0.0.1:*"));
// send 1000 msg on hwm 1000, receive 1000
TEST_ASSERT_EQUAL_INT (1000, test_defaults (1000, 1000, bind_endpoint_));
}
void test_inproc ()
void test_defaults_small (const char *bind_endpoint_)
{
TEST_ASSERT_EQUAL_INT (1000, test_defaults (1000, 1000, "inproc://a"));
TEST_ASSERT_EQUAL_INT (100, test_defaults (100, 100, "inproc://b"));
TEST_ASSERT_EQUAL_INT (6000, test_blocking (2000, 6000, "inproc://c"));
// send 1000 msg on hwm 100, receive 100
TEST_ASSERT_EQUAL_INT (100, test_defaults (100, 100, bind_endpoint_));
}
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
void test_ipc ()
void test_blocking (const char *bind_endpoint_)
{
TEST_ASSERT_EQUAL_INT (1000, test_defaults (1000, 1000, "ipc://*"));
TEST_ASSERT_EQUAL_INT (100, test_defaults (100, 100, "ipc://*"));
TEST_ASSERT_EQUAL_INT (6000, test_blocking (2000, 6000, "ipc://*"));
// send 6000 msg on hwm 2000, drops above hwm, only receive hwm:
TEST_ASSERT_EQUAL_INT (6000, test_blocking (2000, 6000, bind_endpoint_));
}
#define DEFINE_REGULAR_TEST_CASES(name, bind_endpoint) \
void test_defaults_large_##name () \
{ \
test_defaults_large (bind_endpoint); \
} \
\
void test_defaults_small_##name () \
{ \
test_defaults_small (bind_endpoint); \
} \
\
void test_blocking_##name () { test_blocking (bind_endpoint); }
#define RUN_REGULAR_TEST_CASES(name) \
RUN_TEST (test_defaults_large_##name); \
RUN_TEST (test_defaults_small_##name); \
RUN_TEST (test_blocking_##name)
DEFINE_REGULAR_TEST_CASES (tcp, "tcp://127.0.0.1:*")
DEFINE_REGULAR_TEST_CASES (inproc, "inproc://a")
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
DEFINE_REGULAR_TEST_CASES (ipc, "ipc://*")
#endif
int main ()
......@@ -285,12 +296,11 @@ int main ()
UNITY_BEGIN ();
// repeat the test for both TCP, INPROC and IPC transports:
RUN_REGULAR_TEST_CASES (tcp);
RUN_REGULAR_TEST_CASES (inproc);
RUN_TEST (test_tcp);
RUN_TEST (test_inproc);
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
RUN_TEST (test_ipc);
RUN_REGULAR_TEST_CASES (ipc);
#endif
RUN_TEST (test_reset_hwm);
return UNITY_END ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment