diff options
author | fuankg <fuankg@13f79535-47bb-0310-9956-ffa450edef68> | 2013-05-11 18:22:01 +0000 |
---|---|---|
committer | fuankg <fuankg@13f79535-47bb-0310-9956-ffa450edef68> | 2013-05-11 18:22:01 +0000 |
commit | 9a75c4e8584bf1c273a35e7016d84b2a281f1246 (patch) | |
tree | 64846cbbd5bf8107ba7a58f5df8df14ccb487b3f | |
parent | 3a5fbe774b1ad135d4f4db1150fee64c1b42b69c (diff) | |
download | libapr-9a75c4e8584bf1c273a35e7016d84b2a281f1246.tar.gz |
Backport testcase for PR 53175 from trunk.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@1481387 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | test/testtime.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/test/testtime.c b/test/testtime.c index 1e3e87fac..be95c629f 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,38 @@ static void test_gmtstr(CuTest *tc) static void test_exp_lt(CuTest *tc) { - 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[] = {0, 0, 0}; + int i; - rv = apr_time_exp_lt(&xt, now); - if (rv == APR_ENOTIMPL) { - CuNotImpl(tc, "apr_time_exp_lt"); - } - CuAssertTrue(tc, rv == APR_SUCCESS); + test_times[0] = now; + test_times[1] = leap_year_now; + + 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) { + CuNotImpl(tc, "apr_time_exp_lt"); + } + CuAssertTrue(tc, rv == APR_SUCCESS); #define CHK_FIELD(f) \ - CuAssert(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); + CuAssert(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(CuTest *tc) |