diff options
author | Esteban Manchado Velázquez <emanchado@demiurgo.org> | 2012-02-20 16:57:30 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-08 21:16:45 -0500 |
commit | 8bb68011f082f12d50ddfbaee354448bfbb6e227 (patch) | |
tree | d0398eaf253ca4615a673603166c0dafed18f3d7 /src/test | |
parent | c0974018793f6260b16e473de64cb5717f9764d0 (diff) | |
download | tor-8bb68011f082f12d50ddfbaee354448bfbb6e227.tar.gz tor-8bb68011f082f12d50ddfbaee354448bfbb6e227.zip |
Add some unit tests for parse_iso_time
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index cc974842f1..714b3bdaf9 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -111,6 +111,36 @@ test_util_time(void) #endif + /* Test parse_iso_time */ + + t_res = 0; + i = parse_iso_time("", &t_res); + test_eq(-1, i); + t_res = 0; + i = parse_iso_time("2004-08-32 00:48:22", &t_res); + test_eq(-1, i); + t_res = 0; + i = parse_iso_time("1969-08-03 00:48:22", &t_res); + test_eq(-1, i); + + t_res = 0; + i = parse_iso_time("2004-08-04 00:48:22", &t_res); + test_eq(0,i); + test_eq(t_res, (time_t)1091580502UL); + t_res = 0; + i = parse_iso_time("2004-8-4 0:48:22", &t_res); + test_eq(0, i); + test_eq(t_res, (time_t)1091580502UL); + test_eq(-1, parse_iso_time("2004-08-zz 99-99x99 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-03-32 00:00:00 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-03-30 24:00:00 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-03-30 23:60:00 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-03-30 23:59:62 GMT", &t_res)); + test_eq(-1, parse_iso_time("1969-03-30 23:59:59 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-00-30 23:59:59 GMT", &t_res)); + test_eq(-1, parse_iso_time("2011-03-30 23:59", &t_res)); + + /* Test tor_gettimeofday */ end.tv_sec = 4; |