1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.org>, 2000.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
24 #include <sys/types.h>
27 #define ZERO "\xe2\x82\x80"
28 #define ONE "\xe2\x82\x81"
29 #define TWO "\xe2\x82\x82"
30 #define THREE "\xe2\x82\x83"
31 #define FOUR "\xe2\x82\x84"
32 #define FIVE "\xe2\x82\x85"
33 #define SIX "\xe2\x82\x86"
34 #define SEVEN "\xe2\x82\x87"
35 #define EIGHT "\xe2\x82\x88"
36 #define NINE "\xe2\x82\x89"
38 static struct printf_int_test
43 } printf_int_tests[] =
45 { 0, "%I'10d", " " ZERO },
46 { 1, "%I'10d", " " ONE },
47 { 2, "%I'10d", " " TWO },
48 { 3, "%I'10d", " " THREE },
49 { 4, "%I'10d", " " FOUR },
50 { 5, "%I'10d", " " FIVE },
51 { 6, "%I'10d", " " SIX },
52 { 7, "%I'10d", " " SEVEN },
53 { 8, "%I'10d", " " EIGHT },
54 { 9, "%I'10d", " " NINE },
55 { 11, "%I'10d", " " ONE ONE },
56 { 12, "%I'10d", " " ONE TWO },
57 { 123, "%I10d", " " ONE TWO THREE },
58 { 123, "%I'10d", " " ONE TWO THREE },
59 { 1234, "%I10d", ONE TWO THREE FOUR },
60 { 1234, "%I'10d", ONE "," TWO THREE FOUR },
61 { 12345, "%I'10d", ONE TWO "," THREE FOUR FIVE },
62 { 123456, "%I'10d", ONE TWO THREE "," FOUR FIVE SIX },
63 { 1234567, "%I'10d", ONE "," TWO THREE FOUR "," FIVE SIX SEVEN }
75 if (setlocale (LC_ALL, "test7") == NULL)
77 puts ("cannot set locale `test7'");
81 /* First: printf tests. */
82 for (cnt = 0; cnt < sizeof (printf_int_tests) / sizeof (printf_int_tests[0]);
88 n = snprintf (buf, sizeof buf, printf_int_tests[cnt].format,
89 printf_int_tests[cnt].n);
91 if (n != strlen (printf_int_tests[cnt].expected)
92 || strcmp (buf, printf_int_tests[cnt].expected) != 0)
94 printf ("%3d: got \"%s\", expected \"%s\"\n",
95 cnt, buf, printf_int_tests[cnt].expected);
100 printf ("\n%d failures in printf tests\n", failures);
101 status = failures != 0;
103 /* ctype tests. This makes sure that the multibyte chracter digit
104 representations are not handle in this table. */
105 for (cnt = 0; cnt < 256; ++cnt)
106 if (cnt >= '0' && cnt <= '9')
110 printf ("isdigit ('%c') == 0\n", cnt);
118 printf ("isdigit (%d) != 0\n", cnt);
123 printf ("\n%d failures in ctype tests\n", failures);
124 status = failures != 0;
126 /* wctype tests. This makes sure the second set of digits is also
128 for (cnt = 0; cnt < 256; ++cnt)
129 if (cnt >= '0' && cnt <= '9')
131 if (! iswdigit (cnt))
133 printf ("iswdigit (L'%c') == 0\n", cnt);
141 printf ("iswdigit (%d) != 0\n", cnt);
146 for (cnt = 0x2070; cnt < 0x2090; ++cnt)
147 if (cnt >= 0x2080 && cnt <= 0x2089)
149 if (! iswdigit (cnt))
151 printf ("iswdigit (U%04X) == 0\n", cnt);
159 printf ("iswdigit (U%04X) != 0\n", cnt);
164 printf ("\n%d failures in wctype tests\n", failures);
165 status = failures != 0;