Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Test program for fsetpos on a wide character stream. */
2
3#include <assert.h>
4#include <stdio.h>
5#include <wchar.h>
6
7static void do_prepare (void);
8#define PREPARE(argc, argv) do_prepare ()
9static int do_test (void);
10#define TEST_FUNCTION do_test ()
11#include <test-skeleton.c>
12
13static const char pattern[] = "12345";
14static char *temp_file;
15
16static void
17do_prepare (void)
18{
19 int fd = create_temp_file ("bug-wsetpos.", &temp_file);
20 if (fd == -1)
21 {
22 printf ("cannot create temporary file: %m\n");
23 exit (1);
24 }
25 write (fd, pattern, sizeof (pattern));
26 close (fd);
27}
28
29static int
30do_test (void)
31{
32 FILE *fp = fopen (temp_file, "r");
33 fpos_t pos;
34 wchar_t c;
35
36 if (fp == NULL)
37 {
38 printf ("fdopen: %m\n");
39 return 1;
40 }
41
42 c = fgetwc (fp); assert (c == L'1');
43 c = fgetwc (fp); assert (c == L'2');
44
45 if (fgetpos (fp, &pos) == EOF)
46 {
47 printf ("fgetpos: %m\n");
48 return 1;
49 }
50
51 rewind (fp);
52 if (ferror (fp))
53 {
54 printf ("rewind: %m\n");
55 return 1;
56 }
57
58 c = fgetwc (fp); assert (c == L'1');
59
60 if (fsetpos (fp, &pos) == EOF)
61 {
62 printf ("fsetpos: %m\n");
63 return 1;
64 }
65
66 c = fgetwc (fp);
67 if (c != L'3')
68 {
69 puts ("fsetpos failed");
70 return 1;
71 }
72
73 puts ("Test succeeded.");
74 return 0;
75}
76

Warning: That file was not part of the compilation database. It may have many parsing errors.