From d5967397b0f321a758fa94d2f0d1b9ed7adcb178 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Apr 2013 17:51:33 -0400 Subject: [PATCH] More unit tests for initializing common timeouts. Try with: misformed usecs in inputs, and with initializing common timeouts from other common timeouts. --- test/regress.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/regress.c b/test/regress.c index d157c067..01717955 100644 --- a/test/regress.c +++ b/test/regress.c @@ -735,19 +735,27 @@ test_common_timeout(void *ptr) struct timeval start; struct timeval tmp_100_ms = { 0, 100*1000 }; struct timeval tmp_200_ms = { 0, 200*1000 }; + struct timeval tmp_5_sec = { 5, 0 }; + struct timeval tmp_5M_usec = { 0, 5*1000*1000 }; - const struct timeval *ms_100, *ms_200; + const struct timeval *ms_100, *ms_200, *sec_5; ms_100 = event_base_init_common_timeout(base, &tmp_100_ms); ms_200 = event_base_init_common_timeout(base, &tmp_200_ms); + sec_5 = event_base_init_common_timeout(base, &tmp_5_sec); tt_assert(ms_100); tt_assert(ms_200); + tt_assert(sec_5); tt_ptr_op(event_base_init_common_timeout(base, &tmp_200_ms), ==, ms_200); + tt_ptr_op(event_base_init_common_timeout(base, ms_200), ==, ms_200); + tt_ptr_op(event_base_init_common_timeout(base, &tmp_5M_usec), ==, sec_5); tt_int_op(ms_100->tv_sec, ==, 0); tt_int_op(ms_200->tv_sec, ==, 0); + tt_int_op(sec_5->tv_sec, ==, 5); tt_int_op(ms_100->tv_usec, ==, 100000|0x50000000); tt_int_op(ms_200->tv_usec, ==, 200000|0x50100000); + tt_int_op(sec_5->tv_usec, ==, 0|0x50200000); memset(info, 0, sizeof(info));