diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-03-10 13:23:27 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-03-10 13:23:27 -0400 |
commit | 219007b655e7ce0b0dec03ab14ed5c7f2c8d2370 (patch) | |
tree | 3d4384c568dc09a6c816176714a189fca8348f0d | |
parent | 9592455cac96be901a4c9b9fcd08bebd32336084 (diff) | |
download | bfs-219007b655e7ce0b0dec03ab14ed5c7f2c8d2370.tar.xz |
tests/xtime: Don't waste time checking the system's timegm()
Just check our wrapper's error detection, like we do for xmktime().
-rw-r--r-- | tests/xtime.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/xtime.c b/tests/xtime.c index 3472bea..c890a1e 100644 --- a/tests/xtime.c +++ b/tests/xtime.c @@ -154,6 +154,14 @@ static void check_xtimegm(void) { .tm_isdst = -1, }; +#if BFS_HAS_TIMEGM + // Check that xtimegm(-1) isn't an error + for (time_t time = -10; time <= 10; ++time) { + if (bfs_check(gmtime_r(&time, &tm), "gmtime_r(%jd)", (intmax_t)time)) { + check_one_xtimegm(&tm); + } + } +#else // Check equivalence with mktime() for (tm.tm_year = 10; tm.tm_year <= 200; tm.tm_year += 10) for (tm.tm_mon = -3; tm.tm_mon <= 15; tm.tm_mon += 3) @@ -164,13 +172,12 @@ static void check_xtimegm(void) { check_one_xtimegm(&tm); } -#if !BFS_HAS_TIMEGM // Check integer overflow cases check_xtimegm_overflow(&(struct tm) { .tm_sec = INT_MAX, .tm_min = INT_MAX }); check_xtimegm_overflow(&(struct tm) { .tm_min = INT_MAX, .tm_hour = INT_MAX }); check_xtimegm_overflow(&(struct tm) { .tm_hour = INT_MAX, .tm_mday = INT_MAX }); check_xtimegm_overflow(&(struct tm) { .tm_mon = INT_MAX, .tm_year = INT_MAX }); -#endif +#endif // !BFS_HAS_TIMEGM } void check_xtime(void) { |