diff options
author | Jeff Trawick <trawick@apache.org> | 2012-08-12 13:08:05 +0000 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2012-08-12 13:08:05 +0000 |
commit | 2590fc0619cbd78696adc697a828b0d529fcb752 (patch) | |
tree | 39d2eca2046dcd877c86706ebf40c95a42a8560a /test/testtime.c | |
parent | 0e91bc00c197cfbb945a56aa8bcd9edb400ce68d (diff) | |
download | apr-2590fc0619cbd78696adc697a828b0d529fcb752.tar.gz |
add testcase for PR 53175
(i.e., check all the apr_time_exp_t fields for a leap year date too)
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1372085 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testtime.c')
-rw-r--r-- | test/testtime.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/test/testtime.c b/test/testtime.c index 654c1f95c..d135c1d55 100644 --- a/test/testtime.c +++ b/test/testtime.c @@ -31,6 +31,8 @@ * Which happens to be when I wrote the new tests. */ static apr_time_t now = APR_INT64_C(1032030336186711); +/* 2012-08-11 16:00:55.151600 -14400 [224 Sat] DST */ +static apr_time_t leap_year_now = APR_INT64_C(1344715255151600); static char* print_time (apr_pool_t *pool, const apr_time_exp_t *xt) { @@ -84,30 +86,35 @@ static void test_gmtstr(abts_case *tc, void *data) static void test_exp_lt(abts_case *tc, void *data) { - apr_status_t rv; - apr_time_exp_t xt; - time_t posix_secs = (time_t)apr_time_sec(now); - struct tm *posix_exp = localtime(&posix_secs); + apr_time_t test_times[] = {now, leap_year_now, 0}; + int i; - rv = apr_time_exp_lt(&xt, now); - if (rv == APR_ENOTIMPL) { - ABTS_NOT_IMPL(tc, "apr_time_exp_lt"); - } - ABTS_TRUE(tc, rv == APR_SUCCESS); + for (i = 0; test_times[i] != 0; i++) { + apr_status_t rv; + apr_time_exp_t xt; + time_t posix_secs = (time_t)apr_time_sec(test_times[i]); + struct tm *posix_exp = localtime(&posix_secs); + + rv = apr_time_exp_lt(&xt, test_times[i]); + if (rv == APR_ENOTIMPL) { + ABTS_NOT_IMPL(tc, "apr_time_exp_lt"); + } + ABTS_TRUE(tc, rv == APR_SUCCESS); #define CHK_FIELD(f) \ - ABTS_ASSERT(tc, "Mismatch in " #f, posix_exp->f == xt.f) - - CHK_FIELD(tm_sec); - CHK_FIELD(tm_min); - CHK_FIELD(tm_hour); - CHK_FIELD(tm_mday); - CHK_FIELD(tm_mon); - CHK_FIELD(tm_year); - CHK_FIELD(tm_wday); - CHK_FIELD(tm_yday); - CHK_FIELD(tm_isdst); + ABTS_ASSERT(tc, "Mismatch in " #f, posix_exp->f == xt.f) + + CHK_FIELD(tm_sec); + CHK_FIELD(tm_min); + CHK_FIELD(tm_hour); + CHK_FIELD(tm_mday); + CHK_FIELD(tm_mon); + CHK_FIELD(tm_year); + CHK_FIELD(tm_wday); + CHK_FIELD(tm_yday); + CHK_FIELD(tm_isdst); #undef CHK_FIELD + } } static void test_exp_get_gmt(abts_case *tc, void *data) |