Fix ldexp, scalbn, scalbln for sNaN input (bug 20225).
[glibc.git] / time / tst-ftime_l.c
blob6690efeb9c1c570b5ecebb3fa66ffceb3b721cdf
1 #include <locale.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <time.h>
6 #include <wchar.h>
9 static int
10 do_test (void)
12 locale_t l;
13 locale_t old;
14 struct tm tm;
15 char buf[1000];
16 wchar_t wbuf[1000];
17 int result = 0;
18 size_t n;
20 l = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL);
21 if (l == NULL)
23 puts ("newlocale failed");
24 exit (1);
27 memset (&tm, '\0', sizeof (tm));
29 tm.tm_year = 102;
30 tm.tm_mon = 2;
31 tm.tm_mday = 1;
33 if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
35 puts ("initial strftime failed");
36 exit (1);
38 if (strcmp (buf, " 1 MARCH 2002") != 0)
40 printf ("initial strftime: expected \"%s\", got \"%s\"\n",
41 " 1 MARCH 2002", buf);
42 result = 1;
44 else
45 printf ("got \"%s\"\n", buf);
47 /* Now using the extended locale model. */
48 if (strftime_l (buf, sizeof (buf), "%e %^B %Y", &tm, l) == 0)
50 puts ("strftime_l failed");
51 result = 1;
53 else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
55 printf ("strftime_l: expected \"%s\", got \"%s\"\n",
56 " 1 M\xc4RZ 2002", buf);
57 result = 1;
59 else
61 setlocale (LC_ALL, "de_DE.ISO-8859-1");
62 printf ("got \"%s\"\n", buf);
63 setlocale (LC_ALL, "C");
66 /* And the wide character version. */
67 if (wcsftime_l (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%e %^B %Y", &tm, l)
68 == 0)
70 puts ("wcsftime_l failed");
71 result = 1;
73 else if (wcscmp (wbuf, L" 1 M\x00c4RZ 2002") != 0)
75 printf ("wcsftime_l: expected \"%ls\", got \"%ls\"\n",
76 L" 1 M\x00c4RZ 2002", wbuf);
77 result = 1;
79 else
81 setlocale (LC_ALL, "de_DE.ISO-8859-1");
82 printf ("got \"%ls\"\n", wbuf);
83 setlocale (LC_ALL, "C");
86 old = uselocale (l);
88 n = strftime (buf, sizeof (buf), "%e %^B %Y", &tm);
90 /* Switch back. */
91 (void) uselocale (old);
93 if (n == 0)
95 puts ("strftime after first uselocale failed");
96 result = 1;
98 else if (strcmp (buf, " 1 M\xc4RZ 2002") != 0)
100 printf ("strftime in non-C locale: expected \"%s\", got \"%s\"\n",
101 " 1 M\xc4RZ 2002", buf);
102 result = 1;
104 else
106 setlocale (LC_ALL, "de_DE.ISO-8859-1");
107 printf ("got \"%s\"\n", buf);
108 setlocale (LC_ALL, "C");
111 if (strftime (buf, sizeof (buf), "%e %^B %Y", &tm) == 0)
113 puts ("strftime after second uselocale failed");
114 result = 1;
116 else if (strcmp (buf, " 1 MARCH 2002") != 0)
118 printf ("initial strftime: expected \"%s\", got \"%s\"\n",
119 " 1 MARCH 2002", buf);
120 result = 1;
122 else
123 printf ("got \"%s\"\n", buf);
125 return result;
128 #define TEST_FUNCTION do_test ()
129 #include "../test-skeleton.c"