Clean whitespace in last patch.

This commit is contained in:
Nick Mathewson 2014-10-13 13:20:07 -04:00
parent f51418aabc
commit f1782d9c4c
2 changed files with 50 additions and 51 deletions

View File

@ -1670,7 +1670,7 @@ format_time_interval(char *out, size_t out_len, long interval)
{ {
/* We only report seconds if there's no hours. */ /* We only report seconds if there's no hours. */
long sec = 0, min = 0, hour = 0, day = 0; long sec = 0, min = 0, hour = 0, day = 0;
/* -LONG_MIN is LONG_MAX + 1, which causes signed overflow */ /* -LONG_MIN is LONG_MAX + 1, which causes signed overflow */
if (interval < -LONG_MAX) if (interval < -LONG_MAX)
interval = LONG_MAX; interval = LONG_MAX;

View File

@ -2080,7 +2080,7 @@ test_util_format_time_interval(void *arg)
char dbuf[DBUF_SIZE]; char dbuf[DBUF_SIZE];
#define T_ "%ld" #define T_ "%ld"
long sec, min, hour, day; long sec, min, hour, day;
/* we don't care about the exact spelling of the /* we don't care about the exact spelling of the
* second(s), minute(s), hour(s), day(s) labels */ * second(s), minute(s), hour(s), day(s) labels */
#define LABEL_SIZE 21 #define LABEL_SIZE 21
@ -2091,16 +2091,16 @@ test_util_format_time_interval(void *arg)
char label_d[LABEL_SIZE]; char label_d[LABEL_SIZE];
#define TL_ T_ " " L_ #define TL_ T_ " " L_
int r; int r;
(void)arg; (void)arg;
/* In these tests, we're not picky about /* In these tests, we're not picky about
* spelling or abbreviations */ * spelling or abbreviations */
/* seconds: 0, 1, 9, 10, 59 */ /* seconds: 0, 1, 9, 10, 59 */
/* ignore exact spelling of "second(s)"*/ /* ignore exact spelling of "second(s)"*/
format_time_interval(dbuf, sizeof(dbuf), 0); format_time_interval(dbuf, sizeof(dbuf), 0);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2108,30 +2108,30 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 0); tt_int_op(sec,==, 0);
format_time_interval(dbuf, sizeof(dbuf), 1); format_time_interval(dbuf, sizeof(dbuf), 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s); r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 1); tt_int_op(sec,==, 1);
format_time_interval(dbuf, sizeof(dbuf), 10); format_time_interval(dbuf, sizeof(dbuf), 10);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s); r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 10); tt_int_op(sec,==, 10);
format_time_interval(dbuf, sizeof(dbuf), 59); format_time_interval(dbuf, sizeof(dbuf), 59);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s); r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 59); tt_int_op(sec,==, 59);
/* negative seconds are reported as their absolute value */ /* negative seconds are reported as their absolute value */
format_time_interval(dbuf, sizeof(dbuf), -4); format_time_interval(dbuf, sizeof(dbuf), -4);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s); r = tor_sscanf(dbuf, TL_, &sec, label_s);
@ -2139,7 +2139,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 4); tt_int_op(sec,==, 4);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
format_time_interval(dbuf, sizeof(dbuf), -32); format_time_interval(dbuf, sizeof(dbuf), -32);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s); r = tor_sscanf(dbuf, TL_, &sec, label_s);
@ -2147,9 +2147,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 32); tt_int_op(sec,==, 32);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
/* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */ /* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */
/* ignore trailing "0 second(s)", if present */ /* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), 60); format_time_interval(dbuf, sizeof(dbuf), 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2170,7 +2170,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(sec,==, 1); tt_int_op(sec,==, 1);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1); format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2180,7 +2180,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 59); tt_int_op(sec,==, 59);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
/* ignore trailing "0 second(s)", if present */ /* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), 60*2); format_time_interval(dbuf, sizeof(dbuf), 60*2);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2188,7 +2188,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(min,==, 2); tt_int_op(min,==, 2);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* ignore exact spelling of "minute(s)," and "second(s)" */ /* ignore exact spelling of "minute(s)," and "second(s)" */
format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1); format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2199,7 +2199,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 1); tt_int_op(sec,==, 1);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1); format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2209,9 +2209,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 59); tt_int_op(sec,==, 59);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
/* negative minutes are reported as their absolute value */ /* negative minutes are reported as their absolute value */
/* ignore trailing "0 second(s)", if present */ /* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), -3*60); format_time_interval(dbuf, sizeof(dbuf), -3*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2219,7 +2219,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(min,==, 3); tt_int_op(min,==, 3);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* ignore exact spelling of "minute(s)," and "second(s)" */ /* ignore exact spelling of "minute(s)," and "second(s)" */
format_time_interval(dbuf, sizeof(dbuf), -96); format_time_interval(dbuf, sizeof(dbuf), -96);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2230,7 +2230,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 36); tt_int_op(sec,==, 36);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
format_time_interval(dbuf, sizeof(dbuf), -2815); format_time_interval(dbuf, sizeof(dbuf), -2815);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2240,10 +2240,10 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 55); tt_int_op(sec,==, 55);
tt_ci_char_op(label_s[0],==, 's'); tt_ci_char_op(label_s[0],==, 's');
/* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */ /* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */
/* always ignore trailing seconds, if present */ /* always ignore trailing seconds, if present */
/* ignore trailing "0 minute(s)" etc., if present */ /* ignore trailing "0 minute(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 60*60); format_time_interval(dbuf, sizeof(dbuf), 60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2251,14 +2251,14 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(hour,==, 1); tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1); format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &hour, label_h); r = tor_sscanf(dbuf, TL_, &hour, label_h);
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(hour,==, 1); tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
/* ignore exact spelling of "hour(s)," etc. */ /* ignore exact spelling of "hour(s)," etc. */
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60); format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2269,7 +2269,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 1); tt_int_op(min,==, 1);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2279,7 +2279,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59); tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2289,9 +2289,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59); tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* negative hours are reported as their absolute value */ /* negative hours are reported as their absolute value */
/* ignore exact spelling of "hour(s)," etc., if present */ /* ignore exact spelling of "hour(s)," etc., if present */
format_time_interval(dbuf, sizeof(dbuf), -2*60*60); format_time_interval(dbuf, sizeof(dbuf), -2*60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2299,7 +2299,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(hour,==, 2); tt_int_op(hour,==, 2);
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
format_time_interval(dbuf, sizeof(dbuf), -75804); format_time_interval(dbuf, sizeof(dbuf), -75804);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_,
@ -2309,10 +2309,10 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 3); tt_int_op(min,==, 3);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */ /* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */
/* always ignore trailing seconds, if present */ /* always ignore trailing seconds, if present */
/* ignore trailing "0 hours(s)" etc., if present */ /* ignore trailing "0 hours(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60); format_time_interval(dbuf, sizeof(dbuf), 24*60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2320,14 +2320,14 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(day,==, 1); tt_int_op(day,==, 1);
tt_ci_char_op(label_d[0],==, 'd'); tt_ci_char_op(label_d[0],==, 'd');
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &day, label_d); r = tor_sscanf(dbuf, TL_, &day, label_d);
tt_int_op(r,==, 2); tt_int_op(r,==, 2);
tt_int_op(day,==, 1); tt_int_op(day,==, 1);
tt_ci_char_op(label_d[0],==, 'd'); tt_ci_char_op(label_d[0],==, 'd');
/* ignore exact spelling of "days(s)," etc. */ /* ignore exact spelling of "days(s)," etc. */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2347,7 +2347,7 @@ test_util_format_time_interval(void *arg)
} }
tt_int_op(min,==, 1); tt_int_op(min,==, 1);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* ignore trailing "0 minutes(s)" etc., if present */ /* ignore trailing "0 minutes(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60); format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2358,9 +2358,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_d[0],==, 'd'); tt_ci_char_op(label_d[0],==, 'd');
tt_int_op(hour,==, 1); tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
/* negative days are reported as their absolute value */ /* negative days are reported as their absolute value */
format_time_interval(dbuf, sizeof(dbuf), -21936184); format_time_interval(dbuf, sizeof(dbuf), -21936184);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
@ -2372,9 +2372,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 23); tt_int_op(min,==, 23);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* periods > 1 year are reported in days (warn?) */ /* periods > 1 year are reported in days (warn?) */
/* ignore exact spelling of "days(s)," etc., if present */ /* ignore exact spelling of "days(s)," etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 758635154); format_time_interval(dbuf, sizeof(dbuf), 758635154);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2387,9 +2387,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59); tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* negative periods > 1 year are reported in days (warn?) */ /* negative periods > 1 year are reported in days (warn?) */
format_time_interval(dbuf, sizeof(dbuf), -1427014922); format_time_interval(dbuf, sizeof(dbuf), -1427014922);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_, r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
@ -2401,12 +2401,12 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h'); tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 2); tt_int_op(min,==, 2);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
#if SIZEOF_LONG == 4 || SIZEOF_LONG == 8 #if SIZEOF_LONG == 4 || SIZEOF_LONG == 8
/* We can try INT32_MIN/MAX */ /* We can try INT32_MIN/MAX */
/* Always ignore second(s) */ /* Always ignore second(s) */
/* INT32_MAX */ /* INT32_MAX */
format_time_interval(dbuf, sizeof(dbuf), 2147483647); format_time_interval(dbuf, sizeof(dbuf), 2147483647);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2420,7 +2420,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 14); tt_int_op(min,==, 14);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* and 7 seconds - ignored */ /* and 7 seconds - ignored */
/* INT32_MIN: check that we get the absolute value of interval, /* INT32_MIN: check that we get the absolute value of interval,
* which doesn't actually fit in int32_t. * which doesn't actually fit in int32_t.
* We expect INT32_MAX or INT32_MAX + 1 with 64 bit longs */ * We expect INT32_MAX or INT32_MAX + 1 with 64 bit longs */
@ -2443,7 +2443,7 @@ test_util_format_time_interval(void *arg)
/* We can try INT64_MIN/MAX */ /* We can try INT64_MIN/MAX */
/* Always ignore second(s) */ /* Always ignore second(s) */
/* INT64_MAX */ /* INT64_MAX */
format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L); format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1); tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@ -2457,7 +2457,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 30); tt_int_op(min,==, 30);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* and 7 seconds - ignored */ /* and 7 seconds - ignored */
/* INT64_MIN: check that we get the absolute value of interval, /* INT64_MIN: check that we get the absolute value of interval,
* which doesn't actually fit in int64_t. * which doesn't actually fit in int64_t.
* We expect INT64_MAX */ * We expect INT64_MAX */
@ -2474,11 +2474,10 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 30); tt_int_op(min,==, 30);
tt_ci_char_op(label_m[0],==, 'm'); tt_ci_char_op(label_m[0],==, 'm');
/* and 7 or 8 seconds - ignored */ /* and 7 or 8 seconds - ignored */
#endif #endif
done:
done:
; ;
} }