Remove ENOSYS math/ function stubs.
[glibc.git] / libio / bug-rewind.c
blob1734de285f30fff44535e8502b2b2d23991f1765
1 #include <stdio.h>
2 #include <wchar.h>
4 #define PASSED 0
5 #define FAILED 3
8 static int fd;
10 static void prepare (void);
11 #define PREPARE(argc, argv) prepare ()
14 #define TEST_FUNCTION do_test ()
15 static int do_test (void);
16 #include "../test-skeleton.c"
19 static void
20 prepare (void)
22 fd = create_temp_file ("wrewind.", NULL);
23 if (fd == -1)
24 exit (3);
28 static int
29 do_test (void)
31 FILE *fptr;
32 char arg1;
33 char arg2;
34 int ret1, ret2, result, num;
36 ret1 = 0;
37 ret2 = 0;
39 fptr = fdopen (fd, "w+");
40 if (fptr == NULL)
42 printf ("Unable to open file.\n");
43 return 1;
46 if (fwprintf (fptr, L"cderf") <= 0)
48 printf ("Unable to write to file with fwprintf().\n");
49 fclose (fptr);
50 return 2;
53 rewind (fptr);
54 ret1 = fwscanf (fptr, L"%c%c", &arg1, &arg2);
55 if (ret1 != 2)
57 printf ("first fwscanf returned %d, expected 2\n", ret1);
58 return 3;
61 rewind (fptr);
62 ret2 = fwscanf (fptr, L"%c%n%c", &arg1, &num, &arg2);
63 if (ret2 != 2)
65 printf ("second fwscanf returned %d, expected 2\n", ret2);
66 return 4;
69 if (arg2 != 'd')
71 result = FAILED;
72 printf ("rewind after first fwscanf failed\n");
74 else
76 printf ("Passed\n");
77 result = PASSED;
81 fclose (fptr);
82 return result;