12 FILE *fp
= open_wmemstream (&buf
, &size
);
15 puts ("open_wmemstream failed");
19 off64_t off
= ftello64 (fp
);
22 puts ("initial position wrong");
26 if (fseek (fp
, 32768, SEEK_SET
) != 0)
28 puts ("fseek failed");
32 if (fputws (L
"foo", fp
) == EOF
)
34 puts ("fputws failed");
38 if (fclose (fp
) == EOF
)
40 puts ("fclose failed");
44 if (size
!= 32768 + 3)
46 printf ("expected size %d, got %zu\n", 32768 + 3, size
);
50 for (int i
= 0; i
< 32768; ++i
)
53 printf ("wide character at offset %d is %#x\n",
54 i
, (unsigned int) buf
[i
]);
58 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
60 puts ("written string incorrect");
64 /* Mark the buffer. */
65 wmemset (buf
, L
'A', size
);
68 /* Try again, this time with write mode enabled before the seek. */
69 fp
= open_wmemstream (&buf
, &size
);
72 puts ("2nd open_wmemstream failed");
79 puts ("2nd initial position wrong");
83 if (fputws (L
"bar", fp
) == EOF
)
85 puts ("2nd fputws failed");
89 if (fseek (fp
, 32768, SEEK_SET
) != 0)
91 puts ("2nd fseek failed");
95 if (fputws (L
"foo", fp
) == EOF
)
97 puts ("3rd fputws failed");
101 if (fclose (fp
) == EOF
)
103 puts ("2nd fclose failed");
107 if (size
!= 32768 + 3)
109 printf ("2nd expected size %d, got %zu\n", 32768 + 3, size
);
113 if (wmemcmp (buf
, L
"bar", 3) != 0)
115 puts ("initial string incorrect in 2nd try");
119 for (int i
= 3; i
< 32768; ++i
)
122 printf ("wide character at offset %d is %#x in 2nd try\n",
123 i
, (unsigned int) buf
[i
]);
127 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
129 puts ("written string incorrect in 2nd try");
136 #define TEST_FUNCTION do_test ()
137 #include "../test-skeleton.c"