6 #define ZERO "\xe2\x82\x80"
7 #define ONE "\xe2\x82\x81"
8 #define TWO "\xe2\x82\x82"
9 #define THREE "\xe2\x82\x83"
10 #define FOUR "\xe2\x82\x84"
11 #define FIVE "\xe2\x82\x85"
12 #define SIX "\xe2\x82\x86"
13 #define SEVEN "\xe2\x82\x87"
14 #define EIGHT "\xe2\x82\x88"
15 #define NINE "\xe2\x82\x89"
17 static struct printf_int_test
22 } printf_int_tests[] =
24 { 0, "%I'10d", " " ZERO },
25 { 1, "%I'10d", " " ONE },
26 { 2, "%I'10d", " " TWO },
27 { 3, "%I'10d", " " THREE },
28 { 4, "%I'10d", " " FOUR },
29 { 5, "%I'10d", " " FIVE },
30 { 6, "%I'10d", " " SIX },
31 { 7, "%I'10d", " " SEVEN },
32 { 8, "%I'10d", " " EIGHT },
33 { 9, "%I'10d", " " NINE },
34 { 11, "%I'10d", " " ONE ONE },
35 { 12, "%I'10d", " " ONE TWO },
36 { 123, "%I10d", " " ONE TWO THREE },
37 { 123, "%I'10d", " " ONE TWO THREE },
38 { 1234, "%I10d", ONE TWO THREE FOUR },
39 { 1234, "%I'10d", ONE "," TWO THREE FOUR },
40 { 12345, "%I'10d", ONE TWO "," THREE FOUR FIVE },
41 { 123456, "%I'10d", ONE TWO THREE "," FOUR FIVE SIX },
42 { 1234567, "%I'10d", ONE "," TWO THREE FOUR "," FIVE SIX SEVEN }
51 int printf_failures = 0;
53 if (setlocale (LC_ALL, "test7") == NULL)
55 puts ("cannot set locale `test7'");
59 /* First: printf tests. */
60 for (cnt = 0; cnt < sizeof (printf_int_tests) / sizeof (printf_int_tests[0]);
66 n = snprintf (buf, sizeof buf, printf_int_tests[cnt].format,
67 printf_int_tests[cnt].n);
69 if (n != strlen (printf_int_tests[cnt].expected)
70 || strcmp (buf, printf_int_tests[cnt].expected) != 0)
72 printf ("%3d: got \"%s\", expected \"%s\"\n",
73 cnt, buf, printf_int_tests[cnt].expected);
78 printf ("\n%d failures in printf tests\n", printf_failures);
80 return printf_failures != 0;