summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-11 10:48:05 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-11 12:08:01 -0500
commitb5af456685b502462385b5f1b7f22f4374822fe1 (patch)
tree109aaf6977d92f21bb5a8bb93dfb2ddb8e033c94 /src/test/test_util.c
parentc5b58df77588fd1307d248e75d360eb27023033c (diff)
downloadtor-b5af456685b502462385b5f1b7f22f4374822fe1.tar.gz
tor-b5af456685b502462385b5f1b7f22f4374822fe1.zip
Use spaceless ISO8601 time format, not sec,usec.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 64bf52e7b1..d549e235b6 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:
;
}