Constify string parameters
[glibc.git] / stdio-common / bug16.c
blob1112c39d0519f794ca299acd2ad6ba4b15ec0802
1 #include <stdio.h>
2 #include <string.h>
4 struct
6 long double val;
7 const char str[4][7];
8 } tests[] =
10 { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
11 { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
12 { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
13 { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
16 static int
17 do_test (void)
19 char buf[100];
20 int ret = 0;
22 for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
24 snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);
26 size_t j;
27 for (j = 0; j < 4; ++j)
28 if (strcmp (buf, tests[i].str[j]) == 0)
29 break;
31 if (j == 4)
33 printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
34 i, buf, tests[i].str[0]);
35 ret = 1;
39 return ret;
42 #define TEST_FUNCTION do_test ()
43 #include "../test-skeleton.c"