* sysdeps/unix/sysv/linux/alpha/clone.S: Use HIDDEN_JUMPTARGET. ...
[glibc.git] / stdio-common / tst-sscanf.c
blob3ec5a28410d3781cb4872ac6efe395692f9791e2
1 /* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <locale.h>
24 const char *str_double[] =
26 "-.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
27 "0.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
28 "-1234567E0198765432E0912345678901987654321091234567890198765432109",
29 "-0.1000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01"
32 const double val_double[] =
34 -.10000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01,
35 0.10000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01,
36 -1234567E01, 98765432E09, 12345678901.0, 98765432109.0, 12345678901.0,
37 98765432109.0,
38 -0.1000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01
41 const char *str_long[] =
43 "-12345678987654321123456789987654321123456789987654321",
44 "-12345678987654321123456789987654321123456789987654321",
45 "-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321",
46 "-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321"
49 const char *fmt_long[] =
51 "%9ld%9ld%9ld%9ld%9ld%9ld",
52 "%I9ld%I9ld%I9ld%I9ld%I9ld%I9ld",
53 "%'11ld%'11ld%'11ld%'11ld%'11ld%'11ld",
54 "%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld"
57 const long int val_long[] =
59 -12345678, 987654321, 123456789, 987654321, 123456789, 987654321
62 int
63 main (void)
65 double d[6];
66 long l[6];
67 int i, j;
68 int tst_locale;
69 int result = 0;
71 tst_locale = 1;
72 if (tst_locale)
73 if (setlocale (LC_ALL, "en_US.ISO-8859-1") == NULL)
75 puts ("Failed to set en_US locale, skipping locale related tests");
76 tst_locale = 0;
79 for (i = 0; i < 4; ++i)
81 if (sscanf (str_double[i], "%11lf%11lf%11lf%11lf%11lf%11lf",
82 &d[0], &d[1], &d[2], &d[3], &d[4], &d[5]) != 6)
84 printf ("Double sscanf test %d wrong number of "
85 "assigned inputs\n", i);
86 result = 1;
88 else
89 for (j = 0; j < 6; ++j)
90 if (d[j] != val_double[6 * i + j])
92 printf ("Double sscanf test %d failed (%g instead of %g)\n",
93 i, d[j], val_double[6 * i + j]);
94 result = 1;
95 break;
99 for (i = 0; i < 4; ++i)
101 if (sscanf (str_long[i], fmt_long[i],
102 &l[0], &l[1], &l[2], &l[3], &l[4], &l[5]) != 6)
104 printf ("Integer sscanf test %d wrong number of "
105 "assigned inputs\n", i);
106 result = 1;
108 else
109 for (j = 0; j < 6; ++j)
110 if (l[j] != val_long[j])
112 printf ("Integer sscanf test %d failed (%ld instead %ld)\n",
113 i, l[j], val_long[j]);
114 result = 1;
115 break;
118 if (! tst_locale)
119 break;
122 return result;