Updated to fedora-glibc-20080524T2218
[glibc.git] / time / tst-strptime3.c
blob9a8c6485e76b0a6f259644c841aa89bea51282e0
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <time.h>
7 int
8 main (void)
10 int result = 0;
11 struct tm tm;
13 memset (&tm, 0xaa, sizeof (tm));
15 /* Test we don't crash on uninitialized struct tm.
16 Some fields might contain bogus values until everything
17 needed is initialized, but we shouldn't crash. */
18 if (strptime ("2007", "%Y", &tm) == NULL
19 || strptime ("12", "%d", &tm) == NULL
20 || strptime ("Feb", "%b", &tm) == NULL
21 || strptime ("13", "%M", &tm) == NULL
22 || strptime ("21", "%S", &tm) == NULL
23 || strptime ("16", "%H", &tm) == NULL)
25 puts ("strptimes failed");
26 result = 1;
29 if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16
30 || tm.tm_mday != 12 || tm.tm_mon != 1 || tm.tm_year != 107
31 || tm.tm_wday != 1 || tm.tm_yday != 42)
33 puts ("unexpected tm content");
34 result = 1;
37 if (strptime ("8", "%d", &tm) == NULL)
39 puts ("strptime failed");
40 result = 1;
43 if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16
44 || tm.tm_mday != 8 || tm.tm_mon != 1 || tm.tm_year != 107
45 || tm.tm_wday != 4 || tm.tm_yday != 38)
47 puts ("unexpected tm content");
48 result = 1;
51 if (result == 0)
52 puts ("all OK");
54 return 0;