10 FILE *fp
= open_wmemstream (&buf
, &size
);
13 puts ("open_wmemstream failed");
17 off64_t off
= ftello64 (fp
);
20 puts ("initial position wrong");
24 if (fseek (fp
, 32768, SEEK_SET
) != 0)
26 puts ("fseek failed");
30 if (fputws (L
"foo", fp
) == EOF
)
32 puts ("fputws failed");
36 if (fclose (fp
) == EOF
)
38 puts ("fclose failed");
42 if (size
!= 32768 + 3)
44 printf ("expected size %d, got %zu\n", 32768 + 3, size
);
48 for (int i
= 0; i
< 32768; ++i
)
51 printf ("wide character at offset %d is %#x\n",
52 i
, (unsigned int) buf
[i
]);
56 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
58 puts ("written string incorrect");
62 /* Mark the buffer. */
63 wmemset (buf
, L
'A', size
);
66 /* Try again, this time with write mode enabled before the seek. */
67 fp
= open_wmemstream (&buf
, &size
);
70 puts ("2nd open_wmemstream failed");
77 puts ("2nd initial position wrong");
81 if (fputws (L
"bar", fp
) == EOF
)
83 puts ("2nd fputws failed");
87 if (fseek (fp
, 32768, SEEK_SET
) != 0)
89 puts ("2nd fseek failed");
93 if (fputws (L
"foo", fp
) == EOF
)
95 puts ("3rd fputws failed");
99 if (fclose (fp
) == EOF
)
101 puts ("2nd fclose failed");
105 if (size
!= 32768 + 3)
107 printf ("2nd expected size %d, got %zu\n", 32768 + 3, size
);
111 if (wmemcmp (buf
, L
"bar", 3) != 0)
113 puts ("initial string incorrect in 2nd try");
117 for (int i
= 3; i
< 32768; ++i
)
120 printf ("wide character at offset %d is %#x in 2nd try\n",
121 i
, (unsigned int) buf
[i
]);
125 if (wmemcmp (buf
+ 32768, L
"foo", 3) != 0)
127 puts ("written string incorrect in 2nd try");
134 #define TEST_FUNCTION do_test ()
135 #include "../test-skeleton.c"