mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
Problem: no tests for zmq_timer_* with NULL timers argument
Solution: added tests
This commit is contained in:
parent
8b263d5820
commit
d072d57e2e
@ -48,6 +48,59 @@ int sleep_and_execute(void *timers_)
|
||||
return zmq_timers_execute(timers_);
|
||||
}
|
||||
|
||||
void test_null_timer_pointers ()
|
||||
{
|
||||
void *timers = NULL;
|
||||
|
||||
int rc = zmq_timers_destroy (&timers);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
// TODO this currently triggers an access violation
|
||||
#if 0
|
||||
rc = zmq_timers_destroy (NULL);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
#endif
|
||||
|
||||
const size_t dummy_interval = 100;
|
||||
const int dummy_timer_id = 1;
|
||||
|
||||
rc = zmq_timers_add (timers, dummy_interval, &handler, NULL);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_add (&timers, dummy_interval, &handler, NULL);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_cancel (timers, dummy_timer_id);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_cancel (&timers, dummy_timer_id);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_set_interval (timers, dummy_timer_id, dummy_interval);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_set_interval (&timers, dummy_timer_id, dummy_interval);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_reset (timers, dummy_timer_id);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_reset (&timers, dummy_timer_id);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_timeout (timers);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_timeout (&timers);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_execute (timers);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
|
||||
rc = zmq_timers_execute (&timers);
|
||||
assert (rc == -1 && errno == EFAULT);
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
setup_test_environment ();
|
||||
@ -115,5 +168,7 @@ int main (void)
|
||||
rc = zmq_timers_destroy (&timers);
|
||||
assert (rc == 0);
|
||||
|
||||
test_null_timer_pointers ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user