1 /* Test program for fsetpos on a wide character stream. */
7 #include <support/xunistd.h>
9 static void do_prepare (void);
10 #define PREPARE(argc, argv) do_prepare ()
11 static int do_test (void);
12 #define TEST_FUNCTION do_test ()
13 #include <test-skeleton.c>
15 static const char pattern
[] = "12345";
16 static char *temp_file
;
21 int fd
= create_temp_file ("bug-wsetpos.", &temp_file
);
24 printf ("cannot create temporary file: %m\n");
27 xwrite (fd
, pattern
, sizeof (pattern
));
34 FILE *fp
= fopen (temp_file
, "r");
40 printf ("fdopen: %m\n");
44 c
= fgetwc (fp
); assert (c
== L
'1');
45 c
= fgetwc (fp
); assert (c
== L
'2');
47 if (fgetpos (fp
, &pos
) == EOF
)
49 printf ("fgetpos: %m\n");
56 printf ("rewind: %m\n");
60 c
= fgetwc (fp
); assert (c
== L
'1');
62 if (fsetpos (fp
, &pos
) == EOF
)
64 printf ("fsetpos: %m\n");
71 puts ("fsetpos failed");
75 puts ("Test succeeded.");