@@ -111,7 +111,7 @@ void test_join_twice_fails ()
111111 test_context_socket_close (dish);
112112}
113113
114- void test_radio_dish ()
114+ void test_radio_dish_tcp_poll ()
115115{
116116 size_t len = MAX_SOCKET_STRING;
117117 char my_endpoint[MAX_SOCKET_STRING];
@@ -176,6 +176,48 @@ void test_radio_dish ()
176176 test_context_socket_close (radio);
177177}
178178
179+ void test_dish_connect_fails ()
180+ {
181+ void *dish = test_context_socket (ZMQ_DISH);
182+
183+ // Connecting dish should fail
184+ TEST_ASSERT_FAILURE_ERRNO (ENOCOMPATPROTO,
185+ zmq_connect (dish, " udp://127.0.0.1:5556" ));
186+
187+ test_context_socket_close (dish);
188+ }
189+
190+ void test_radio_bind_fails ()
191+ {
192+ void *radio = test_context_socket (ZMQ_RADIO);
193+
194+ // Connecting dish should fail
195+ // Bind radio should fail
196+ TEST_ASSERT_FAILURE_ERRNO (ENOCOMPATPROTO,
197+ zmq_bind (radio, " udp://*:5556" ));
198+
199+ test_context_socket_close (radio);
200+ }
201+
202+ void test_radio_dish_udp ()
203+ {
204+ void *radio = test_context_socket (ZMQ_RADIO);
205+ void *dish = test_context_socket (ZMQ_DISH);
206+
207+ TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (dish, " udp://*:5556" ));
208+ TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (radio, " udp://127.0.0.1:5556" ));
209+
210+ msleep (SETTLE_TIME);
211+
212+ TEST_ASSERT_SUCCESS_ERRNO (zmq_join (dish, " TV" ));
213+
214+ msg_send_expect_success (radio, " TV" , " Friends" );
215+ msg_recv_cmp (dish, " TV" , " Friends" );
216+
217+ test_context_socket_close (dish);
218+ test_context_socket_close (radio);
219+ }
220+
179221int main (void )
180222{
181223 setup_test_environment ();
@@ -184,6 +226,10 @@ int main (void)
184226 RUN_TEST (test_leave_unjoined_fails);
185227 RUN_TEST (test_join_too_long_fails);
186228 RUN_TEST (test_join_twice_fails);
187- RUN_TEST (test_radio_dish);
229+ RUN_TEST (test_radio_bind_fails);
230+ RUN_TEST (test_dish_connect_fails);
231+ RUN_TEST (test_radio_dish_tcp_poll);
232+ RUN_TEST (test_radio_dish_udp);
233+
188234 return UNITY_END ();
189235}
0 commit comments