lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <errno.h> |
| 2 | #include <limits.h> |
| 3 | #include <stdio.h> |
| 4 | #include <time.h> |
| 5 | |
| 6 | |
| 7 | static int |
| 8 | do_test (void) |
| 9 | { |
| 10 | int result = 0; |
| 11 | time_t t = time (NULL); |
| 12 | struct tm *tp = localtime (&t); |
| 13 | tp->tm_year = INT_MAX; |
| 14 | errno = 0; |
| 15 | char *s = asctime (tp); |
| 16 | if (s != NULL || errno != EOVERFLOW) |
| 17 | { |
| 18 | puts ("asctime did not fail correctly"); |
| 19 | result = 1; |
| 20 | } |
| 21 | char buf[1000]; |
| 22 | errno = 0; |
| 23 | s = asctime_r (tp, buf); |
| 24 | if (s != NULL || errno != EOVERFLOW) |
| 25 | { |
| 26 | puts ("asctime_r did not fail correctly"); |
| 27 | result = 1; |
| 28 | } |
| 29 | return result; |
| 30 | } |
| 31 | |
| 32 | #define TEST_FUNCTION do_test () |
| 33 | #include "../test-skeleton.c" |