11 FILE *fp
= open_wmemstream (&buf
, &size
);
14 puts ("open_wmemstream failed");
18 off64_t off
= ftello64 (fp
);
21 puts ("initial position wrong");
25 if (fseek (fp
, 32768, SEEK_SET
) != 0)
27 puts ("fseek failed");
31 if (fputws (L
"foo", fp
) == EOF
)
33 puts ("fputws failed");
37 if (fclose (fp
) == EOF
)
39 puts ("fclose failed");
43 if (size
!= 32768 + 3)
45 printf ("expected size %d, got %zu\n", 32768 + 3, size
);
49 for (int i
= 0; i
< 32768; ++i
)
52 printf ("wide character at offset %d is %#x\n",
53 i
, (unsigned int) buf
[i
]);
57 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
59 puts ("written string incorrect");
63 /* Mark the buffer. */
64 wmemset (buf
, L
'A', size
);
67 /* Try again, this time with write mode enabled before the seek. */
68 fp
= open_wmemstream (&buf
, &size
);
71 puts ("2nd open_wmemstream failed");
78 puts ("2nd initial position wrong");
82 if (fputws (L
"bar", fp
) == EOF
)
84 puts ("2nd fputws failed");
88 if (fseek (fp
, 32768, SEEK_SET
) != 0)
90 puts ("2nd fseek failed");
94 if (fputws (L
"foo", fp
) == EOF
)
96 puts ("3rd fputws failed");
100 if (fclose (fp
) == EOF
)
102 puts ("2nd fclose failed");
106 if (size
!= 32768 + 3)
108 printf ("2nd expected size %d, got %zu\n", 32768 + 3, size
);
112 if (wmemcmp (buf
, L
"bar", 3) != 0)
114 puts ("initial string incorrect in 2nd try");
118 for (int i
= 3; i
< 32768; ++i
)
121 printf ("wide character at offset %d is %#x in 2nd try\n",
122 i
, (unsigned int) buf
[i
]);
126 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
128 puts ("written string incorrect in 2nd try");
135 #define TEST_FUNCTION do_test ()
136 #include "../test-skeleton.c"