Correct readahead syscall wrapper on powerpc32.
[glibc.git] / stdio-common / tstdiomisc.c
blobdb038fa2b0123c11c6bc2a923e56c1b0c4897d46
1 #include <float.h>
2 #include <math.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <wchar.h>
7 static int
8 t1 (void)
10 int n = -1;
11 sscanf ("abc ", "abc %n", &n);
12 printf ("t1: count=%d\n", n);
14 return n != 5;
17 static int
18 t2 (void)
20 int result = 0;
21 int n;
22 long N;
23 int retval;
24 #define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
25 VAR = -1; \
26 retval = sscanf (INPUT, FORMAT, &VAR); \
27 printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
28 INPUT, FORMAT, retval, (long int) VAR); \
29 result |= retval != EXP_RES || VAR != EXP_VAL
31 SCAN ("12345", "%ld", N, 1, 12345);
32 SCAN ("12345", "%llllld", N, 0, -1);
33 SCAN ("12345", "%LLLLLd", N, 0, -1);
34 SCAN ("test ", "%*s%n", n, 0, 4);
35 SCAN ("test ", "%2*s%n", n, 0, -1);
36 SCAN ("12 ", "%l2d", n, 0, -1);
37 SCAN ("12 ", "%2ld", N, 1, 12);
39 n = -1;
40 N = -1;
41 retval = sscanf ("1 1", "%d %Z", &n, &N);
42 printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \
43 retval, n, N); \
44 result |= retval != 1 || n != 1 || N != -1;
46 return result;
49 volatile double nanval;
52 static int
53 F (void)
55 char buf[20];
56 wchar_t wbuf[10];
57 int result;
59 nanval = NAN;
61 snprintf (buf, sizeof buf, "%f %F", nanval, nanval);
62 result = strcmp (buf, "nan NAN") != 0;
63 printf ("expected \"nan NAN\", got \"%s\"\n", buf);
65 snprintf (buf, sizeof buf, "%f %F", DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
66 result |= strcmp (buf, "inf INF") != 0;
67 printf ("expected \"inf INF\", got \"%s\"\n", buf);
69 swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F", nanval, nanval);
70 result |= wcscmp (wbuf, L"nan NAN") != 0;
71 printf ("expected L\"nan NAN\", got L\"%S\"\n", wbuf);
73 swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F",
74 DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
75 result |= wcscmp (wbuf, L"inf INF") != 0;
76 printf ("expected L\"inf INF\", got L\"%S\"\n", wbuf);
78 return result;
81 int
82 main (int argc, char *argv[])
84 int result = 0;
86 result |= t1 ();
87 result |= t2 ();
88 result |= F ();
90 result |= fflush (stdout) == EOF;
92 return result;