summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-11-10 06:28:53 +0000
committerNick Mathewson <nickm@torproject.org>2003-11-10 06:28:53 +0000
commit3c4b4c8cac706ba17d33929ddcc0b0a306adc6b8 (patch)
treec6b1e2b400b464ffa5199bb2f3621d894442739e /src/or/test.c
parent3dddcf4306df2ecd364f9c45b576d709181bff7b (diff)
downloadtor-3c4b4c8cac706ba17d33929ddcc0b0a306adc6b8.tar.gz
tor-3c4b4c8cac706ba17d33929ddcc0b0a306adc6b8.zip
Check in a working cross-platform timegm
svn:r779
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 1d3c551b1a..bdc6f43fb2 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -422,6 +422,7 @@ test_crypto()
void
test_util() {
struct timeval start, end;
+ struct tm a_time;
start.tv_sec = 5;
start.tv_usec = 5000;
@@ -447,6 +448,20 @@ test_util() {
test_eq(0L, tv_udiff(&start, &end));
+ /* The test values here are confirmed to be correct on a platform
+ * with a working timgm. */
+ a_time.tm_year = 2003-1900;
+ a_time.tm_mon = 7;
+ a_time.tm_mday = 30;
+ a_time.tm_hour = 6;
+ a_time.tm_min = 14;
+ a_time.tm_sec = 55;
+ test_eq((time_t) 1062224095UL, tor_timegm(&a_time));
+ a_time.tm_year = 2004-1900; /* Try a leap year, after feb. */
+ test_eq((time_t) 1093846495UL, tor_timegm(&a_time));
+ a_time.tm_mon = 1; /* Try a leap year, in feb. */
+ a_time.tm_mday = 10;
+ test_eq((time_t) 1076393695UL, tor_timegm(&a_time));
}
void