]>
Commit | Line | Data |
---|---|---|
84724245 RM |
1 | #include <stdlib.h> |
2 | #include <time.h> | |
3 | #include <string.h> | |
4 | #include <stdio.h> | |
5 | ||
6 | struct { | |
7 | const char * env; | |
8 | time_t expected; | |
9 | } tests[] = { | |
3e7dfc48 | 10 | {"MST", 832935315}, |
0742e501 UD |
11 | {"", 832910115}, |
12 | {":UTC", 832910115}, | |
13 | {"UTC", 832910115}, | |
14 | {"UTC0", 832910115} | |
84724245 RM |
15 | }; |
16 | ||
17 | ||
18 | int | |
5290baf0 | 19 | main (int argc, char ** argv) |
84724245 RM |
20 | { |
21 | int errors = 0; | |
22 | struct tm tm; | |
23 | time_t t; | |
ba1ffaa1 | 24 | unsigned int i; |
84724245 RM |
25 | |
26 | memset (&tm, 0, sizeof (tm)); | |
27 | tm.tm_isdst = 0; | |
28 | tm.tm_year = 96; /* years since 1900 */ | |
29 | tm.tm_mon = 4; | |
30 | tm.tm_mday = 24; | |
31 | tm.tm_hour = 3; | |
32 | tm.tm_min = 55; | |
33 | tm.tm_sec = 15; | |
34 | ||
35 | for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i) | |
36 | { | |
9a93ac00 | 37 | setenv ("TZ", tests[i].env, 1); |
5290baf0 | 38 | t = mktime (&tm); |
84724245 RM |
39 | if (t != tests[i].expected) |
40 | { | |
ba1ffaa1 | 41 | printf ("%s: flunked test %u (expected %lu, got %lu)\n", |
84724245 RM |
42 | argv[0], i, (long) tests[i].expected, (long) t); |
43 | ++errors; | |
44 | } | |
45 | } | |
46 | if (errors == 0) | |
47 | { | |
48 | puts ("No errors."); | |
bf4de8f3 | 49 | return EXIT_SUCCESS; |
84724245 RM |
50 | } |
51 | else | |
52 | { | |
53 | printf ("%d errors.\n", errors); | |
bf4de8f3 | 54 | return EXIT_FAILURE; |
84724245 RM |
55 | } |
56 | } |