diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-01-11 12:10:14 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-01-11 12:10:14 -0500 |
commit | f729e1e984896a9d6852768a8e5528932f668ac3 (patch) | |
tree | f6e1aa68ec9e5f6875a06224333b96b8f7938b2e /src/test/test_util.c | |
parent | f37181620951d2e7a13f1363386563115d628761 (diff) | |
parent | b5af456685b502462385b5f1b7f22f4374822fe1 (diff) | |
download | tor-f729e1e984896a9d6852768a8e5528932f668ac3.tar.gz tor-f729e1e984896a9d6852768a8e5528932f668ac3.zip |
Merge branch 'feature3457-v4-nm-squashed'
Conflicts:
src/or/rendclient.c
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 389e0a08d6..4fc8b84d5b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -19,9 +19,10 @@ test_util_time(void) { struct timeval start, end; struct tm a_time; - char timestr[RFC1123_TIME_LEN+1]; + char timestr[128]; time_t t_res; int i; + struct timeval tv; start.tv_sec = 5; start.tv_usec = 5000; @@ -83,6 +84,24 @@ test_util_time(void) /* We might've timewarped a little. */ tt_int_op(tv_udiff(&start, &end), >=, -5000); + /* Now let's check some format_iso_time variants */ + tv.tv_sec = (time_t)1326296338; + tv.tv_usec = 3060; + format_iso_time(timestr, tv.tv_sec); + test_streq("2012-01-11 15:38:58", timestr); + /* The output of format_local_iso_time will vary by timezone, and setting + our timezone for testing purposes would be a nontrivial flaky pain. + Skip this test for now. + format_local_iso_time(timestr, tv.tv_sec); + test_streq("2012-01-11 10:38:58", timestr); + */ + format_iso_time_nospace(timestr, tv.tv_sec); + test_streq("2012-01-11T15:38:58", timestr); + test_eq(strlen(timestr), ISO_TIME_LEN); + format_iso_time_nospace_usec(timestr, &tv); + test_streq("2012-01-11T15:38:58.003060", timestr); + test_eq(strlen(timestr), ISO_TIME_USEC_LEN); + done: ; } |