31
31
#include " testutil_unity.hpp"
32
32
33
33
#include < unity.h>
34
+ #include < limits.h>
34
35
35
36
void setUp ()
36
37
{
@@ -393,6 +394,42 @@ void call_poller_modify_fd_unregistered_fails (void *poller,
393
394
TEST_ASSERT_SUCCESS_ERRNO (close (plain_socket));
394
395
}
395
396
397
+ void call_poller_add_invalid_events_fails (void *poller, void *zeromq_socket)
398
+ {
399
+ TEST_ASSERT_FAILURE_ERRNO (
400
+ EINVAL, zmq_poller_add (poller, zeromq_socket, NULL , SHRT_MAX));
401
+ }
402
+
403
+ void call_poller_modify_invalid_events_fails (void *poller, void *zeromq_socket)
404
+ {
405
+ TEST_ASSERT_SUCCESS_ERRNO (zmq_poller_add (poller, zeromq_socket, NULL , 0 ));
406
+
407
+ TEST_ASSERT_FAILURE_ERRNO (
408
+ EINVAL, zmq_poller_modify (poller, zeromq_socket, SHRT_MAX));
409
+ }
410
+
411
+ void call_poller_add_fd_invalid_events_fails (void *poller,
412
+ void * /* zeromq_socket*/ )
413
+ {
414
+ fd_t plain_socket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
415
+ TEST_ASSERT_FAILURE_ERRNO (
416
+ EINVAL, zmq_poller_add_fd (poller, plain_socket, NULL , SHRT_MAX));
417
+
418
+ TEST_ASSERT_SUCCESS_ERRNO (close (plain_socket));
419
+ }
420
+
421
+ void call_poller_modify_fd_invalid_events_fails (void *poller,
422
+ void * /* zeromq_socket*/ )
423
+ {
424
+ fd_t plain_socket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
425
+ TEST_ASSERT_SUCCESS_ERRNO (
426
+ zmq_poller_add_fd (poller, plain_socket, NULL , 0 ));
427
+ TEST_ASSERT_FAILURE_ERRNO (
428
+ EINVAL, zmq_poller_modify_fd (poller, plain_socket, SHRT_MAX));
429
+
430
+ TEST_ASSERT_SUCCESS_ERRNO (close (plain_socket));
431
+ }
432
+
396
433
TEST_CASE_FUNC_PARAM (call_poller_add_twice_fails, test_with_empty_poller)
397
434
TEST_CASE_FUNC_PARAM (call_poller_remove_unregistered_fails,
398
435
test_with_empty_poller)
@@ -406,6 +443,15 @@ TEST_CASE_FUNC_PARAM (call_poller_remove_fd_unregistered_fails,
406
443
TEST_CASE_FUNC_PARAM (call_poller_modify_fd_unregistered_fails,
407
444
test_with_empty_poller)
408
445
446
+ TEST_CASE_FUNC_PARAM (call_poller_add_invalid_events_fails,
447
+ test_with_empty_poller)
448
+ TEST_CASE_FUNC_PARAM (call_poller_modify_invalid_events_fails,
449
+ test_with_empty_poller)
450
+ TEST_CASE_FUNC_PARAM (call_poller_add_fd_invalid_events_fails,
451
+ test_with_empty_poller)
452
+ TEST_CASE_FUNC_PARAM (call_poller_modify_fd_invalid_events_fails,
453
+ test_with_empty_poller)
454
+
409
455
void call_poller_wait_empty_with_timeout_fails (void *poller, void * /* socket*/ )
410
456
{
411
457
zmq_poller_event_t event;
@@ -618,6 +664,10 @@ int main (void)
618
664
RUN_TEST (test_call_poller_add_fd_twice_fails);
619
665
RUN_TEST (test_call_poller_remove_fd_unregistered_fails);
620
666
RUN_TEST (test_call_poller_modify_fd_unregistered_fails);
667
+ RUN_TEST (test_call_poller_add_invalid_events_fails);
668
+ RUN_TEST (test_call_poller_modify_invalid_events_fails);
669
+ RUN_TEST (test_call_poller_add_fd_invalid_events_fails);
670
+ RUN_TEST (test_call_poller_modify_fd_invalid_events_fails);
621
671
622
672
RUN_TEST (test_call_poller_wait_empty_with_timeout_fails);
623
673
RUN_TEST (test_call_poller_wait_empty_without_timeout_fails);
0 commit comments