msvcirt/tests: Build without -DWINE_NO_LONG_TYPES.
[wine.git] / dlls / msvcirt / tests / msvcirt.c
blob22c1efbb38e1d1605fb0d36021ddfbcfd536dadf
1 /*
2 * Copyright 2015-2016 Iván Matellanes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <fcntl.h>
20 #include <float.h>
21 #include <math.h>
22 #include <io.h>
23 #include <stdio.h>
24 #include <windef.h>
25 #include <winbase.h>
26 #include <sys/stat.h>
27 #include "wine/test.h"
29 typedef void (*vtable_ptr)(void);
30 typedef LONG streamoff;
31 typedef LONG streampos;
32 typedef int filedesc;
33 typedef void* (__cdecl *allocFunction)(LONG);
34 typedef void (__cdecl *freeFunction)(void*);
36 typedef enum {
37 IOSTATE_goodbit = 0x0,
38 IOSTATE_eofbit = 0x1,
39 IOSTATE_failbit = 0x2,
40 IOSTATE_badbit = 0x4
41 } ios_io_state;
43 typedef enum {
44 OPENMODE_in = 0x1,
45 OPENMODE_out = 0x2,
46 OPENMODE_ate = 0x4,
47 OPENMODE_app = 0x8,
48 OPENMODE_trunc = 0x10,
49 OPENMODE_nocreate = 0x20,
50 OPENMODE_noreplace = 0x40,
51 OPENMODE_binary = 0x80
52 } ios_open_mode;
54 typedef enum {
55 SEEKDIR_beg = 0,
56 SEEKDIR_cur = 1,
57 SEEKDIR_end = 2
58 } ios_seek_dir;
60 typedef enum {
61 FLAGS_skipws = 0x1,
62 FLAGS_left = 0x2,
63 FLAGS_right = 0x4,
64 FLAGS_internal = 0x8,
65 FLAGS_dec = 0x10,
66 FLAGS_oct = 0x20,
67 FLAGS_hex = 0x40,
68 FLAGS_showbase = 0x80,
69 FLAGS_showpoint = 0x100,
70 FLAGS_uppercase = 0x200,
71 FLAGS_showpos = 0x400,
72 FLAGS_scientific = 0x800,
73 FLAGS_fixed = 0x1000,
74 FLAGS_unitbuf = 0x2000,
75 FLAGS_stdio = 0x4000
76 } ios_flags;
78 const int filebuf_sh_none = 0x800;
79 const int filebuf_sh_read = 0xa00;
80 const int filebuf_sh_write = 0xc00;
81 const int filebuf_openprot = 420;
82 const int filebuf_binary = _O_BINARY;
83 const int filebuf_text = _O_TEXT;
85 /* class streambuf */
86 typedef struct {
87 const vtable_ptr *vtable;
88 int allocated;
89 int unbuffered;
90 int stored_char;
91 char *base;
92 char *ebuf;
93 char *pbase;
94 char *pptr;
95 char *epptr;
96 char *eback;
97 char *gptr;
98 char *egptr;
99 int do_lock;
100 CRITICAL_SECTION lock;
101 } streambuf;
103 /* class filebuf */
104 typedef struct {
105 streambuf base;
106 filedesc fd;
107 int close;
108 } filebuf;
110 /* class strstreambuf */
111 typedef struct {
112 streambuf base;
113 int dynamic;
114 int increase;
115 int unknown;
116 int constant;
117 allocFunction f_alloc;
118 freeFunction f_free;
119 } strstreambuf;
121 /* class stdiobuf */
122 typedef struct {
123 streambuf base;
124 FILE *file;
125 } stdiobuf;
127 /* class ios */
128 struct _ostream;
129 typedef struct {
130 const vtable_ptr *vtable;
131 streambuf *sb;
132 ios_io_state state;
133 int special[4];
134 int delbuf;
135 struct _ostream *tie;
136 ios_flags flags;
137 int precision;
138 char fill;
139 int width;
140 int do_lock;
141 CRITICAL_SECTION lock;
142 } ios;
144 /* class ostream */
145 typedef struct _ostream {
146 const int *vbtable;
147 int unknown;
148 ios base_ios; /* virtually inherited */
149 } ostream;
151 /* class istream */
152 typedef struct {
153 const int *vbtable;
154 int extract_delim;
155 int count;
156 ios base_ios; /* virtually inherited */
157 } istream;
159 /* class iostream */
160 typedef struct {
161 struct { /* istream */
162 const int *vbtable;
163 int extract_delim;
164 int count;
165 } base1;
166 struct { /* ostream */
167 const int *vbtable;
168 int unknown;
169 } base2;
170 ios base_ios; /* virtually inherited */
171 } iostream;
173 /* class exception */
174 typedef struct {
175 const void *vtable;
176 char *name;
177 int do_free;
178 } exception;
180 /* class logic_error */
181 typedef struct {
182 exception e;
183 } logic_error;
185 #undef __thiscall
186 #ifdef __i386__
187 #define __thiscall __stdcall
188 #else
189 #define __thiscall __cdecl
190 #endif
192 static void* (__cdecl *p_operator_new)(unsigned int);
193 static void (__cdecl *p_operator_delete)(void*);
195 /* streambuf */
196 static streambuf* (*__thiscall p_streambuf_reserve_ctor)(streambuf*, char*, int);
197 static streambuf* (*__thiscall p_streambuf_ctor)(streambuf*);
198 static void (*__thiscall p_streambuf_dtor)(streambuf*);
199 static int (*__thiscall p_streambuf_allocate)(streambuf*);
200 static void (*__thiscall p_streambuf_clrclock)(streambuf*);
201 static int (*__thiscall p_streambuf_doallocate)(streambuf*);
202 static void (*__thiscall p_streambuf_gbump)(streambuf*, int);
203 static int (*__thiscall p_streambuf_in_avail)(const streambuf*);
204 static void (*__thiscall p_streambuf_lock)(streambuf*);
205 static int (*__thiscall p_streambuf_out_waiting)(const streambuf*);
206 static int (*__thiscall p_streambuf_pbackfail)(streambuf*, int);
207 static void (*__thiscall p_streambuf_pbump)(streambuf*, int);
208 static int (*__thiscall p_streambuf_sbumpc)(streambuf*);
209 static void (*__thiscall p_streambuf_setb)(streambuf*, char*, char*, int);
210 static void (*__thiscall p_streambuf_setlock)(streambuf*);
211 static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int);
212 static int (*__thiscall p_streambuf_sgetc)(streambuf*);
213 static int (*__thiscall p_streambuf_snextc)(streambuf*);
214 static int (*__thiscall p_streambuf_sputc)(streambuf*, int);
215 static void (*__thiscall p_streambuf_stossc)(streambuf*);
216 static int (*__thiscall p_streambuf_sync)(streambuf*);
217 static void (*__thiscall p_streambuf_unlock)(streambuf*);
218 static int (*__thiscall p_streambuf_xsgetn)(streambuf*, char*, int);
219 static int (*__thiscall p_streambuf_xsputn)(streambuf*, const char*, int);
221 /* filebuf */
222 static filebuf* (*__thiscall p_filebuf_fd_ctor)(filebuf*, int);
223 static filebuf* (*__thiscall p_filebuf_fd_reserve_ctor)(filebuf*, int, char*, int);
224 static filebuf* (*__thiscall p_filebuf_ctor)(filebuf*);
225 static void (*__thiscall p_filebuf_dtor)(filebuf*);
226 static filebuf* (*__thiscall p_filebuf_attach)(filebuf*, filedesc);
227 static filebuf* (*__thiscall p_filebuf_open)(filebuf*, const char*, ios_open_mode, int);
228 static filebuf* (*__thiscall p_filebuf_close)(filebuf*);
229 static int (*__thiscall p_filebuf_setmode)(filebuf*, int);
230 static streambuf* (*__thiscall p_filebuf_setbuf)(filebuf*, char*, int);
231 static int (*__thiscall p_filebuf_sync)(filebuf*);
232 static int (*__thiscall p_filebuf_overflow)(filebuf*, int);
233 static int (*__thiscall p_filebuf_underflow)(filebuf*);
234 static streampos (*__thiscall p_filebuf_seekoff)(filebuf*, streamoff, ios_seek_dir, int);
235 static int (*__thiscall p_filebuf_is_open)(filebuf*);
237 /* strstreambuf */
238 static strstreambuf* (*__thiscall p_strstreambuf_dynamic_ctor)(strstreambuf*, int);
239 static strstreambuf* (*__thiscall p_strstreambuf_funcs_ctor)(strstreambuf*, allocFunction, freeFunction);
240 static strstreambuf* (*__thiscall p_strstreambuf_buffer_ctor)(strstreambuf*, char*, int, char*);
241 static strstreambuf* (*__thiscall p_strstreambuf_ubuffer_ctor)(strstreambuf*, unsigned char*, int, unsigned char*);
242 static strstreambuf* (*__thiscall p_strstreambuf_ctor)(strstreambuf*);
243 static void (*__thiscall p_strstreambuf_dtor)(strstreambuf*);
244 static int (*__thiscall p_strstreambuf_doallocate)(strstreambuf*);
245 static void (*__thiscall p_strstreambuf_freeze)(strstreambuf*, int);
246 static int (*__thiscall p_strstreambuf_overflow)(strstreambuf*, int);
247 static streampos (*__thiscall p_strstreambuf_seekoff)(strstreambuf*, streamoff, ios_seek_dir, int);
248 static streambuf* (*__thiscall p_strstreambuf_setbuf)(strstreambuf*, char*, int);
249 static int (*__thiscall p_strstreambuf_underflow)(strstreambuf*);
251 /* stdiobuf */
252 static stdiobuf* (*__thiscall p_stdiobuf_file_ctor)(stdiobuf*, FILE*);
253 static void (*__thiscall p_stdiobuf_dtor)(stdiobuf*);
254 static int (*__thiscall p_stdiobuf_overflow)(stdiobuf*, int);
255 static int (*__thiscall p_stdiobuf_pbackfail)(stdiobuf*, int);
256 static streampos (*__thiscall p_stdiobuf_seekoff)(stdiobuf*, streamoff, ios_seek_dir, int);
257 static int (*__thiscall p_stdiobuf_setrwbuf)(stdiobuf*, int, int);
258 static int (*__thiscall p_stdiobuf_sync)(stdiobuf*);
259 static int (*__thiscall p_stdiobuf_underflow)(stdiobuf*);
261 /* ios */
262 static ios* (*__thiscall p_ios_copy_ctor)(ios*, const ios*);
263 static ios* (*__thiscall p_ios_ctor)(ios*);
264 static ios* (*__thiscall p_ios_sb_ctor)(ios*, streambuf*);
265 static ios* (*__thiscall p_ios_assign)(ios*, const ios*);
266 static void (*__thiscall p_ios_init)(ios*, streambuf*);
267 static void (*__thiscall p_ios_dtor)(ios*);
268 static void (*__cdecl p_ios_clrlock)(ios*);
269 static void (*__cdecl p_ios_setlock)(ios*);
270 static void (*__cdecl p_ios_lock)(ios*);
271 static void (*__cdecl p_ios_unlock)(ios*);
272 static void (*__cdecl p_ios_lockbuf)(ios*);
273 static void (*__cdecl p_ios_unlockbuf)(ios*);
274 static CRITICAL_SECTION *p_ios_static_lock;
275 static void (*__cdecl p_ios_lockc)(void);
276 static void (*__cdecl p_ios_unlockc)(void);
277 static LONG (*__thiscall p_ios_flags_set)(ios*, LONG);
278 static LONG (*__thiscall p_ios_flags_get)(const ios*);
279 static LONG (*__thiscall p_ios_setf)(ios*, LONG);
280 static LONG (*__thiscall p_ios_setf_mask)(ios*, LONG, LONG);
281 static LONG (*__thiscall p_ios_unsetf)(ios*, LONG);
282 static int (*__thiscall p_ios_good)(const ios*);
283 static int (*__thiscall p_ios_bad)(const ios*);
284 static int (*__thiscall p_ios_eof)(const ios*);
285 static int (*__thiscall p_ios_fail)(const ios*);
286 static void (*__thiscall p_ios_clear)(ios*, int);
287 static LONG *p_ios_maxbit;
288 static LONG (*__cdecl p_ios_bitalloc)(void);
289 static int *p_ios_curindex;
290 static LONG *p_ios_statebuf;
291 static LONG* (*__thiscall p_ios_iword)(const ios*, int);
292 static void** (*__thiscall p_ios_pword)(const ios*, int);
293 static int (*__cdecl p_ios_xalloc)(void);
294 static void (*__cdecl p_ios_sync_with_stdio)(void);
295 static int *p_ios_sunk_with_stdio;
296 static int *p_ios_fLockcInit;
298 /* ostream */
299 static ostream* (*__thiscall p_ostream_copy_ctor)(ostream*, const ostream*, BOOL);
300 static ostream* (*__thiscall p_ostream_sb_ctor)(ostream*, streambuf*, BOOL);
301 static ostream* (*__thiscall p_ostream_ctor)(ostream*, BOOL);
302 static void (*__thiscall p_ostream_dtor)(ios*);
303 static ostream* (*__thiscall p_ostream_assign)(ostream*, const ostream*);
304 static ostream* (*__thiscall p_ostream_assign_sb)(ostream*, streambuf*);
305 static void (*__thiscall p_ostream_vbase_dtor)(ostream*);
306 static ostream* (*__thiscall p_ostream_flush)(ostream*);
307 static int (*__thiscall p_ostream_opfx)(ostream*);
308 static void (*__thiscall p_ostream_osfx)(ostream*);
309 static ostream* (*__thiscall p_ostream_put_char)(ostream*, char);
310 static ostream* (*__thiscall p_ostream_write_char)(ostream*, const char*, int);
311 static ostream* (*__thiscall p_ostream_seekp_offset)(ostream*, streamoff, ios_seek_dir);
312 static ostream* (*__thiscall p_ostream_seekp)(ostream*, streampos);
313 static streampos (*__thiscall p_ostream_tellp)(ostream*);
314 static ostream* (*__thiscall p_ostream_writepad)(ostream*, const char*, const char*);
315 static ostream* (*__thiscall p_ostream_print_char)(ostream*, char);
316 static ostream* (*__thiscall p_ostream_print_str)(ostream*, const char*);
317 static ostream* (*__thiscall p_ostream_print_int)(ostream*, int);
318 static ostream* (*__thiscall p_ostream_print_float)(ostream*, float);
319 static ostream* (*__thiscall p_ostream_print_double)(ostream*, double);
320 static ostream* (*__thiscall p_ostream_print_ptr)(ostream*, const void*);
321 static ostream* (*__thiscall p_ostream_print_streambuf)(ostream*, streambuf*);
323 /* ostream_withassign */
324 static ostream* (*__thiscall p_ostream_withassign_sb_ctor)(ostream*, streambuf*, BOOL);
325 static ostream* (*__thiscall p_ostream_withassign_copy_ctor)(ostream*, const ostream*, BOOL);
326 static ostream* (*__thiscall p_ostream_withassign_ctor)(ostream*, BOOL);
327 static void (*__thiscall p_ostream_withassign_dtor)(ios*);
328 static void (*__thiscall p_ostream_withassign_vbase_dtor)(ostream*);
329 static ostream* (*__thiscall p_ostream_withassign_assign_sb)(ostream*, streambuf*);
330 static ostream* (*__thiscall p_ostream_withassign_assign_os)(ostream*, const ostream*);
331 static ostream* (*__thiscall p_ostream_withassign_assign)(ostream*, const ostream*);
333 /* ostrstream */
334 static ostream* (*__thiscall p_ostrstream_copy_ctor)(ostream*, const ostream*, BOOL);
335 static ostream* (*__thiscall p_ostrstream_buffer_ctor)(ostream*, char*, int, int, BOOL);
336 static ostream* (*__thiscall p_ostrstream_ctor)(ostream*, BOOL);
337 static void (*__thiscall p_ostrstream_dtor)(ios*);
338 static void (*__thiscall p_ostrstream_vbase_dtor)(ostream*);
339 static ostream* (*__thiscall p_ostrstream_assign)(ostream*, const ostream*);
340 static int (*__thiscall p_ostrstream_pcount)(const ostream*);
342 /* ofstream */
343 static ostream* (*__thiscall p_ofstream_copy_ctor)(ostream*, const ostream*, BOOL);
344 static ostream* (*__thiscall p_ofstream_buffer_ctor)(ostream*, filedesc, char*, int, BOOL);
345 static ostream* (*__thiscall p_ofstream_fd_ctor)(ostream*, filedesc fd, BOOL virt_init);
346 static ostream* (*__thiscall p_ofstream_open_ctor)(ostream*, const char *name, ios_open_mode, int, BOOL);
347 static ostream* (*__thiscall p_ofstream_ctor)(ostream*, BOOL);
348 static void (*__thiscall p_ofstream_dtor)(ios*);
349 static void (*__thiscall p_ofstream_vbase_dtor)(ostream*);
350 static void (*__thiscall p_ofstream_attach)(ostream*, filedesc);
351 static void (*__thiscall p_ofstream_close)(ostream*);
352 static filedesc (*__thiscall p_ofstream_fd)(ostream*);
353 static int (*__thiscall p_ofstream_is_open)(const ostream*);
354 static void (*__thiscall p_ofstream_open)(ostream*, const char*, ios_open_mode, int);
355 static filebuf* (*__thiscall p_ofstream_rdbuf)(const ostream*);
356 static streambuf* (*__thiscall p_ofstream_setbuf)(ostream*, char*, int);
357 static int (*__thiscall p_ofstream_setmode)(ostream*, int);
359 /* istream */
360 static istream* (*__thiscall p_istream_copy_ctor)(istream*, const istream*, BOOL);
361 static istream* (*__thiscall p_istream_ctor)(istream*, BOOL);
362 static istream* (*__thiscall p_istream_sb_ctor)(istream*, streambuf*, BOOL);
363 static void (*__thiscall p_istream_dtor)(ios*);
364 static istream* (*__thiscall p_istream_assign_sb)(istream*, streambuf*);
365 static istream* (*__thiscall p_istream_assign)(istream*, const istream*);
366 static void (*__thiscall p_istream_vbase_dtor)(istream*);
367 static void (*__thiscall p_istream_eatwhite)(istream*);
368 static int (*__thiscall p_istream_ipfx)(istream*, int);
369 static istream* (*__thiscall p_istream_get_str_delim)(istream*, char*, int, int);
370 static istream* (*__thiscall p_istream_get_str)(istream*, char*, int, char);
371 static int (*__thiscall p_istream_get)(istream*);
372 static istream* (*__thiscall p_istream_get_char)(istream*, char*);
373 static istream* (*__thiscall p_istream_get_sb)(istream*, streambuf*, char);
374 static istream* (*__thiscall p_istream_getline)(istream*, char*, int, char);
375 static istream* (*__thiscall p_istream_ignore)(istream*, int, int);
376 static int (*__thiscall p_istream_peek)(istream*);
377 static istream* (*__thiscall p_istream_putback)(istream*, char);
378 static istream* (*__thiscall p_istream_read)(istream*, char*, int);
379 static istream* (*__thiscall p_istream_seekg)(istream*, streampos);
380 static istream* (*__thiscall p_istream_seekg_offset)(istream*, streamoff, ios_seek_dir);
381 static int (*__thiscall p_istream_sync)(istream*);
382 static streampos (*__thiscall p_istream_tellg)(istream*);
383 static int (*__thiscall p_istream_getint)(istream*, char*);
384 static int (*__thiscall p_istream_getdouble)(istream*, char*, int);
385 static istream* (*__thiscall p_istream_read_char)(istream*, char*);
386 static istream* (*__thiscall p_istream_read_str)(istream*, char*);
387 static istream* (*__thiscall p_istream_read_short)(istream*, short*);
388 static istream* (*__thiscall p_istream_read_unsigned_short)(istream*, unsigned short*);
389 static istream* (*__thiscall p_istream_read_int)(istream*, int*);
390 static istream* (*__thiscall p_istream_read_unsigned_int)(istream*, unsigned int*);
391 static istream* (*__thiscall p_istream_read_long)(istream*, LONG*);
392 static istream* (*__thiscall p_istream_read_unsigned_long)(istream*, ULONG*);
393 static istream* (*__thiscall p_istream_read_float)(istream*, float*);
394 static istream* (*__thiscall p_istream_read_double)(istream*, double*);
395 static istream* (*__thiscall p_istream_read_long_double)(istream*, double*);
396 static istream* (*__thiscall p_istream_read_streambuf)(istream*, streambuf*);
398 /* istream_withassign */
399 static istream* (*__thiscall p_istream_withassign_sb_ctor)(istream*, streambuf*, BOOL);
400 static istream* (*__thiscall p_istream_withassign_copy_ctor)(istream*, const istream*, BOOL);
401 static istream* (*__thiscall p_istream_withassign_ctor)(istream*, BOOL);
402 static void (*__thiscall p_istream_withassign_dtor)(ios*);
403 static void (*__thiscall p_istream_withassign_vbase_dtor)(istream*);
404 static istream* (*__thiscall p_istream_withassign_assign_sb)(istream*, streambuf*);
405 static istream* (*__thiscall p_istream_withassign_assign_is)(istream*, const istream*);
406 static istream* (*__thiscall p_istream_withassign_assign)(istream*, const istream*);
408 /* istrstream */
409 static istream* (*__thiscall p_istrstream_copy_ctor)(istream*, const istream*, BOOL);
410 static istream* (*__thiscall p_istrstream_str_ctor)(istream*, char*, BOOL);
411 static istream* (*__thiscall p_istrstream_buffer_ctor)(istream*, char*, int, BOOL);
412 static void (*__thiscall p_istrstream_dtor)(ios*);
413 static void (*__thiscall p_istrstream_vbase_dtor)(istream*);
414 static istream* (*__thiscall p_istrstream_assign)(istream*, const istream*);
416 /* iostream */
417 static iostream* (*__thiscall p_iostream_copy_ctor)(iostream*, const iostream*, BOOL);
418 static iostream* (*__thiscall p_iostream_sb_ctor)(iostream*, streambuf*, BOOL);
419 static iostream* (*__thiscall p_iostream_ctor)(iostream*, BOOL);
420 static void (*__thiscall p_iostream_dtor)(ios*);
421 static void (*__thiscall p_iostream_vbase_dtor)(iostream*);
422 static iostream* (*__thiscall p_iostream_assign_sb)(iostream*, streambuf*);
423 static iostream* (*__thiscall p_iostream_assign)(iostream*, const iostream*);
425 /* ifstream */
426 static istream* (*__thiscall p_ifstream_copy_ctor)(istream*, const istream*, BOOL);
427 static istream* (*__thiscall p_ifstream_buffer_ctor)(istream*, filedesc, char*, int, BOOL);
428 static istream* (*__thiscall p_ifstream_fd_ctor)(istream*, filedesc fd, BOOL virt_init);
429 static istream* (*__thiscall p_ifstream_open_ctor)(istream*, const char *name, ios_open_mode, int, BOOL);
430 static istream* (*__thiscall p_ifstream_ctor)(istream*, BOOL);
431 static void (*__thiscall p_ifstream_dtor)(ios*);
432 static void (*__thiscall p_ifstream_vbase_dtor)(istream*);
433 static void (*__thiscall p_ifstream_attach)(istream*, filedesc);
434 static void (*__thiscall p_ifstream_close)(istream*);
435 static filedesc (*__thiscall p_ifstream_fd)(istream*);
436 static int (*__thiscall p_ifstream_is_open)(const istream*);
437 static void (*__thiscall p_ifstream_open)(istream*, const char*, ios_open_mode, int);
438 static filebuf* (*__thiscall p_ifstream_rdbuf)(const istream*);
439 static streambuf* (*__thiscall p_ifstream_setbuf)(istream*, char*, int);
440 static int (*__thiscall p_ifstream_setmode)(istream*, int);
442 /* strstream */
443 static iostream* (*__thiscall p_strstream_copy_ctor)(iostream*, const iostream*, BOOL);
444 static iostream* (*__thiscall p_strstream_buffer_ctor)(iostream*, char*, int, int, BOOL);
445 static iostream* (*__thiscall p_strstream_ctor)(iostream*, BOOL);
446 static void (*__thiscall p_strstream_dtor)(ios*);
447 static void (*__thiscall p_strstream_vbase_dtor)(iostream*);
448 static iostream* (*__thiscall p_strstream_assign)(iostream*, const iostream*);
450 /* stdiostream */
451 static iostream* (*__thiscall p_stdiostream_copy_ctor)(iostream*, const iostream*, BOOL);
452 static iostream* (*__thiscall p_stdiostream_file_ctor)(iostream*, FILE*, BOOL);
453 static void (*__thiscall p_stdiostream_dtor)(ios*);
454 static void (*__thiscall p_stdiostream_vbase_dtor)(iostream*);
455 static iostream* (*__thiscall p_stdiostream_assign)(iostream*, const iostream*);
457 /* fstream */
458 static iostream* (*__thiscall p_fstream_copy_ctor)(iostream*, const iostream*, BOOL);
459 static iostream* (*__thiscall p_fstream_buffer_ctor)(iostream*, filedesc, char*, int, BOOL);
460 static iostream* (*__thiscall p_fstream_fd_ctor)(iostream*, filedesc fd, BOOL virt_init);
461 static iostream* (*__thiscall p_fstream_open_ctor)(iostream*, const char *name, ios_open_mode, int, BOOL);
462 static iostream* (*__thiscall p_fstream_ctor)(iostream*, BOOL);
463 static void (*__thiscall p_fstream_dtor)(ios*);
464 static void (*__thiscall p_fstream_vbase_dtor)(iostream*);
465 static void (*__thiscall p_fstream_attach)(iostream*, filedesc);
466 static void (*__thiscall p_fstream_close)(iostream*);
467 static filedesc (*__thiscall p_fstream_fd)(iostream*);
468 static int (*__thiscall p_fstream_is_open)(const iostream*);
469 static void (*__thiscall p_fstream_open)(iostream*, const char*, ios_open_mode, int);
470 static filebuf* (*__thiscall p_fstream_rdbuf)(const iostream*);
471 static streambuf* (*__thiscall p_fstream_setbuf)(iostream*, char*, int);
472 static int (*__thiscall p_fstream_setmode)(iostream*, int);
474 /* Iostream_init */
475 static void* (*__thiscall p_Iostream_init_ios_ctor)(void*, ios*, int);
477 /* exception */
478 static exception* (*__thiscall p_exception_ctor)(exception*, const char**);
479 static void (*__thiscall p_exception_dtor)(exception*);
480 static const char* (*__thiscall p_exception_what)(exception*);
482 static logic_error* (*__thiscall p_logic_error_ctor)(logic_error*, const char**);
483 static void (*__thiscall p_logic_error_dtor)(logic_error*);
485 /* locking */
486 static void (*__cdecl p__mtlock)(CRITICAL_SECTION *);
487 static void (*__cdecl p__mtunlock)(CRITICAL_SECTION *);
489 /* Predefined streams */
490 static istream *p_cin;
491 static ostream *p_cout, *p_cerr, *p_clog;
493 /* Emulate a __thiscall */
494 #ifdef __i386__
496 #include "pshpack1.h"
497 struct thiscall_thunk
499 BYTE pop_eax; /* popl %eax (ret addr) */
500 BYTE pop_edx; /* popl %edx (func) */
501 BYTE pop_ecx; /* popl %ecx (this) */
502 BYTE push_eax; /* pushl %eax */
503 WORD jmp_edx; /* jmp *%edx */
505 #include "poppack.h"
507 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
508 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, void *a );
509 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, void *a, void *b );
510 static void * (WINAPI *call_thiscall_func4)( void *func, void *this, void *a, void *b,
511 void *c );
512 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, void *a, void *b,
513 void *c, void *d );
514 static void * (WINAPI *call_thiscall_func2_ptr_dbl)( void *func, void *this, double a );
515 static void * (WINAPI *call_thiscall_func2_ptr_flt)( void *func, void *this, float a );
517 static void init_thiscall_thunk(void)
519 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
520 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
521 thunk->pop_eax = 0x58; /* popl %eax */
522 thunk->pop_edx = 0x5a; /* popl %edx */
523 thunk->pop_ecx = 0x59; /* popl %ecx */
524 thunk->push_eax = 0x50; /* pushl %eax */
525 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
526 call_thiscall_func1 = (void *)thunk;
527 call_thiscall_func2 = (void *)thunk;
528 call_thiscall_func3 = (void *)thunk;
529 call_thiscall_func4 = (void *)thunk;
530 call_thiscall_func5 = (void *)thunk;
531 call_thiscall_func2_ptr_dbl = (void *)thunk;
532 call_thiscall_func2_ptr_flt = (void *)thunk;
535 #define call_func1(func,_this) call_thiscall_func1(func,_this)
536 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(void*)(a))
537 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(void*)(a),(void*)(b))
538 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(void*)(a),(void*)(b), \
539 (void*)(c))
540 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(void*)(a),(void*)(b), \
541 (void*)(c), (void *)(d))
542 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
543 #define call_func2_ptr_flt(func,_this,a) call_thiscall_func2_ptr_flt(func,_this,a)
545 #else
547 #define init_thiscall_thunk()
548 #define call_func1(func,_this) func(_this)
549 #define call_func2(func,_this,a) func(_this,a)
550 #define call_func3(func,_this,a,b) func(_this,a,b)
551 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
552 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
553 #define call_func2_ptr_dbl call_func2
554 #define call_func2_ptr_flt call_func2
556 #endif /* __i386__ */
558 static HMODULE msvcrt, msvcirt;
559 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcirt,y)
560 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
561 static BOOL init(void)
563 msvcrt = LoadLibraryA("msvcrt.dll");
564 msvcirt = LoadLibraryA("msvcirt.dll");
565 if(!msvcirt) {
566 win_skip("msvcirt.dll not installed\n");
567 return FALSE;
570 if(sizeof(void*) == 8) { /* 64-bit initialization */
571 p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPEAX_K@Z");
572 p_operator_delete = (void*)GetProcAddress(msvcrt, "??3@YAXPEAX@Z");
574 SET(p_streambuf_reserve_ctor, "??0streambuf@@IEAA@PEADH@Z");
575 SET(p_streambuf_ctor, "??0streambuf@@IEAA@XZ");
576 SET(p_streambuf_dtor, "??1streambuf@@UEAA@XZ");
577 SET(p_streambuf_allocate, "?allocate@streambuf@@IEAAHXZ");
578 SET(p_streambuf_clrclock, "?clrlock@streambuf@@QEAAXXZ");
579 SET(p_streambuf_doallocate, "?doallocate@streambuf@@MEAAHXZ");
580 SET(p_streambuf_gbump, "?gbump@streambuf@@IEAAXH@Z");
581 SET(p_streambuf_in_avail, "?in_avail@streambuf@@QEBAHXZ");
582 SET(p_streambuf_lock, "?lock@streambuf@@QEAAXXZ");
583 SET(p_streambuf_out_waiting, "?out_waiting@streambuf@@QEBAHXZ");
584 SET(p_streambuf_pbackfail, "?pbackfail@streambuf@@UEAAHH@Z");
585 SET(p_streambuf_pbump, "?pbump@streambuf@@IEAAXH@Z");
586 SET(p_streambuf_sbumpc, "?sbumpc@streambuf@@QEAAHXZ");
587 SET(p_streambuf_setb, "?setb@streambuf@@IEAAXPEAD0H@Z");
588 SET(p_streambuf_setbuf, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z");
589 SET(p_streambuf_setlock, "?setlock@streambuf@@QEAAXXZ");
590 SET(p_streambuf_sgetc, "?sgetc@streambuf@@QEAAHXZ");
591 SET(p_streambuf_snextc, "?snextc@streambuf@@QEAAHXZ");
592 SET(p_streambuf_sputc, "?sputc@streambuf@@QEAAHH@Z");
593 SET(p_streambuf_stossc, "?stossc@streambuf@@QEAAXXZ");
594 SET(p_streambuf_sync, "?sync@streambuf@@UEAAHXZ");
595 SET(p_streambuf_unlock, "?unlock@streambuf@@QEAAXXZ");
596 SET(p_streambuf_xsgetn, "?xsgetn@streambuf@@UEAAHPEADH@Z");
597 SET(p_streambuf_xsputn, "?xsputn@streambuf@@UEAAHPEBDH@Z");
599 SET(p_filebuf_fd_ctor, "??0filebuf@@QEAA@H@Z");
600 SET(p_filebuf_fd_reserve_ctor, "??0filebuf@@QEAA@HPEADH@Z");
601 SET(p_filebuf_ctor, "??0filebuf@@QEAA@XZ");
602 SET(p_filebuf_dtor, "??1filebuf@@UEAA@XZ");
603 SET(p_filebuf_attach, "?attach@filebuf@@QEAAPEAV1@H@Z");
604 SET(p_filebuf_open, "?open@filebuf@@QEAAPEAV1@PEBDHH@Z");
605 SET(p_filebuf_close, "?close@filebuf@@QEAAPEAV1@XZ");
606 SET(p_filebuf_setmode, "?setmode@filebuf@@QEAAHH@Z");
607 SET(p_filebuf_setbuf, "?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z");
608 SET(p_filebuf_sync, "?sync@filebuf@@UEAAHXZ");
609 SET(p_filebuf_overflow, "?overflow@filebuf@@UEAAHH@Z");
610 SET(p_filebuf_underflow, "?underflow@filebuf@@UEAAHXZ");
611 SET(p_filebuf_seekoff, "?seekoff@filebuf@@UEAAJJW4seek_dir@ios@@H@Z");
612 SET(p_filebuf_is_open, "?is_open@filebuf@@QEBAHXZ");
614 SET(p_strstreambuf_dynamic_ctor, "??0strstreambuf@@QEAA@H@Z");
615 SET(p_strstreambuf_funcs_ctor, "??0strstreambuf@@QEAA@P6APEAXJ@ZP6AXPEAX@Z@Z");
616 SET(p_strstreambuf_buffer_ctor, "??0strstreambuf@@QEAA@PEADH0@Z");
617 SET(p_strstreambuf_ubuffer_ctor, "??0strstreambuf@@QEAA@PEAEH0@Z");
618 SET(p_strstreambuf_ctor, "??0strstreambuf@@QEAA@XZ");
619 SET(p_strstreambuf_dtor, "??1strstreambuf@@UEAA@XZ");
620 SET(p_strstreambuf_doallocate, "?doallocate@strstreambuf@@MEAAHXZ");
621 SET(p_strstreambuf_freeze, "?freeze@strstreambuf@@QEAAXH@Z");
622 SET(p_strstreambuf_overflow, "?overflow@strstreambuf@@UEAAHH@Z");
623 SET(p_strstreambuf_seekoff, "?seekoff@strstreambuf@@UEAAJJW4seek_dir@ios@@H@Z");
624 SET(p_strstreambuf_setbuf, "?setbuf@strstreambuf@@UEAAPEAVstreambuf@@PEADH@Z");
625 SET(p_strstreambuf_underflow, "?underflow@strstreambuf@@UEAAHXZ");
627 SET(p_stdiobuf_file_ctor, "??0stdiobuf@@QEAA@PEAU_iobuf@@@Z");
628 SET(p_stdiobuf_dtor, "??1stdiobuf@@UEAA@XZ");
629 SET(p_stdiobuf_overflow, "?overflow@stdiobuf@@UEAAHH@Z");
630 SET(p_stdiobuf_pbackfail, "?pbackfail@stdiobuf@@UEAAHH@Z");
631 SET(p_stdiobuf_seekoff, "?seekoff@stdiobuf@@UEAAJJW4seek_dir@ios@@H@Z");
632 SET(p_stdiobuf_setrwbuf, "?setrwbuf@stdiobuf@@QEAAHHH@Z");
633 SET(p_stdiobuf_sync, "?sync@stdiobuf@@UEAAHXZ");
634 SET(p_stdiobuf_underflow, "?underflow@stdiobuf@@UEAAHXZ");
636 SET(p_ios_copy_ctor, "??0ios@@IEAA@AEBV0@@Z");
637 SET(p_ios_ctor, "??0ios@@IEAA@XZ");
638 SET(p_ios_sb_ctor, "??0ios@@QEAA@PEAVstreambuf@@@Z");
639 SET(p_ios_assign, "??4ios@@IEAAAEAV0@AEBV0@@Z");
640 SET(p_ios_init, "?init@ios@@IEAAXPEAVstreambuf@@@Z");
641 SET(p_ios_dtor, "??1ios@@UEAA@XZ");
642 SET(p_ios_clrlock, "?clrlock@ios@@QEAAXXZ");
643 SET(p_ios_setlock, "?setlock@ios@@QEAAXXZ");
644 SET(p_ios_lock, "?lock@ios@@QEAAXXZ");
645 SET(p_ios_unlock, "?unlock@ios@@QEAAXXZ");
646 SET(p_ios_lockbuf, "?lockbuf@ios@@QEAAXXZ");
647 SET(p_ios_unlockbuf, "?unlockbuf@ios@@QEAAXXZ");
648 SET(p_ios_flags_set, "?flags@ios@@QEAAJJ@Z");
649 SET(p_ios_flags_get, "?flags@ios@@QEBAJXZ");
650 SET(p_ios_setf, "?setf@ios@@QEAAJJ@Z");
651 SET(p_ios_setf_mask, "?setf@ios@@QEAAJJJ@Z");
652 SET(p_ios_unsetf, "?unsetf@ios@@QEAAJJ@Z");
653 SET(p_ios_good, "?good@ios@@QEBAHXZ");
654 SET(p_ios_bad, "?bad@ios@@QEBAHXZ");
655 SET(p_ios_eof, "?eof@ios@@QEBAHXZ");
656 SET(p_ios_fail, "?fail@ios@@QEBAHXZ");
657 SET(p_ios_clear, "?clear@ios@@QEAAXH@Z");
658 SET(p_ios_iword, "?iword@ios@@QEBAAEAJH@Z");
659 SET(p_ios_pword, "?pword@ios@@QEBAAEAPEAXH@Z");
661 SET(p_ostream_copy_ctor, "??0ostream@@IEAA@AEBV0@@Z");
662 SET(p_ostream_sb_ctor, "??0ostream@@QEAA@PEAVstreambuf@@@Z");
663 SET(p_ostream_ctor, "??0ostream@@IEAA@XZ");
664 SET(p_ostream_dtor, "??1ostream@@UEAA@XZ");
665 SET(p_ostream_assign, "??4ostream@@IEAAAEAV0@AEBV0@@Z");
666 SET(p_ostream_assign_sb, "??4ostream@@IEAAAEAV0@PEAVstreambuf@@@Z");
667 SET(p_ostream_vbase_dtor, "??_Dostream@@QEAAXXZ");
668 SET(p_ostream_flush, "?flush@ostream@@QEAAAEAV1@XZ");
669 SET(p_ostream_opfx, "?opfx@ostream@@QEAAHXZ");
670 SET(p_ostream_osfx, "?osfx@ostream@@QEAAXXZ");
671 SET(p_ostream_put_char, "?put@ostream@@QEAAAEAV1@D@Z");
672 SET(p_ostream_write_char, "?write@ostream@@QEAAAEAV1@PEBDH@Z");
673 SET(p_ostream_seekp_offset, "?seekp@ostream@@QEAAAEAV1@JW4seek_dir@ios@@@Z");
674 SET(p_ostream_seekp, "?seekp@ostream@@QEAAAEAV1@J@Z");
675 SET(p_ostream_tellp, "?tellp@ostream@@QEAAJXZ");
676 SET(p_ostream_writepad, "?writepad@ostream@@AEAAAEAV1@PEBD0@Z");
677 SET(p_ostream_print_char, "??6ostream@@QEAAAEAV0@D@Z");
678 SET(p_ostream_print_str, "??6ostream@@QEAAAEAV0@PEBD@Z");
679 SET(p_ostream_print_int, "??6ostream@@QEAAAEAV0@H@Z");
680 SET(p_ostream_print_float, "??6ostream@@QEAAAEAV0@M@Z");
681 SET(p_ostream_print_double, "??6ostream@@QEAAAEAV0@N@Z");
682 SET(p_ostream_print_ptr, "??6ostream@@QEAAAEAV0@PEBX@Z");
683 SET(p_ostream_print_streambuf, "??6ostream@@QEAAAEAV0@PEAVstreambuf@@@Z");
685 SET(p_ostream_withassign_sb_ctor, "??0ostream_withassign@@QEAA@PEAVstreambuf@@@Z");
686 SET(p_ostream_withassign_copy_ctor, "??0ostream_withassign@@QEAA@AEBV0@@Z");
687 SET(p_ostream_withassign_ctor, "??0ostream_withassign@@QEAA@XZ");
688 SET(p_ostream_withassign_dtor, "??1ostream_withassign@@UEAA@XZ");
689 SET(p_ostream_withassign_vbase_dtor, "??_Dostream_withassign@@QEAAXXZ");
690 SET(p_ostream_withassign_assign_sb, "??4ostream_withassign@@QEAAAEAVostream@@PEAVstreambuf@@@Z");
691 SET(p_ostream_withassign_assign_os, "??4ostream_withassign@@QEAAAEAVostream@@AEBV1@@Z");
692 SET(p_ostream_withassign_assign, "??4ostream_withassign@@QEAAAEAV0@AEBV0@@Z");
694 SET(p_ostrstream_copy_ctor, "??0ostrstream@@QEAA@AEBV0@@Z");
695 SET(p_ostrstream_buffer_ctor, "??0ostrstream@@QEAA@PEADHH@Z");
696 SET(p_ostrstream_ctor, "??0ostrstream@@QEAA@XZ");
697 SET(p_ostrstream_dtor, "??1ostrstream@@UEAA@XZ");
698 SET(p_ostrstream_vbase_dtor, "??_Dostrstream@@QEAAXXZ");
699 SET(p_ostrstream_assign, "??4ostrstream@@QEAAAEAV0@AEBV0@@Z");
700 SET(p_ostrstream_pcount, "?pcount@ostrstream@@QEBAHXZ");
702 SET(p_ofstream_copy_ctor, "??0ofstream@@QEAA@AEBV0@@Z");
703 SET(p_ofstream_buffer_ctor, "??0ofstream@@QEAA@HPEADH@Z");
704 SET(p_ofstream_fd_ctor, "??0ofstream@@QEAA@H@Z");
705 SET(p_ofstream_open_ctor, "??0ofstream@@QEAA@PEBDHH@Z");
706 SET(p_ofstream_ctor, "??0ofstream@@QEAA@XZ");
707 SET(p_ofstream_dtor, "??1ofstream@@UEAA@XZ");
708 SET(p_ofstream_vbase_dtor, "??_Dofstream@@QEAAXXZ");
709 SET(p_ofstream_attach, "?attach@ofstream@@QEAAXH@Z");
710 SET(p_ofstream_close, "?close@ofstream@@QEAAXXZ");
711 SET(p_ofstream_fd, "?fd@ofstream@@QEBAHXZ");
712 SET(p_ofstream_is_open, "?is_open@ofstream@@QEBAHXZ");
713 SET(p_ofstream_open, "?open@ofstream@@QEAAXPEBDHH@Z");
714 SET(p_ofstream_rdbuf, "?rdbuf@ofstream@@QEBAPEAVfilebuf@@XZ");
715 SET(p_ofstream_setbuf, "?setbuf@ofstream@@QEAAPEAVstreambuf@@PEADH@Z");
716 SET(p_ofstream_setmode, "?setmode@ofstream@@QEAAHH@Z");
718 SET(p_istream_copy_ctor, "??0istream@@IEAA@AEBV0@@Z");
719 SET(p_istream_ctor, "??0istream@@IEAA@XZ");
720 SET(p_istream_sb_ctor, "??0istream@@QEAA@PEAVstreambuf@@@Z");
721 SET(p_istream_dtor, "??1istream@@UEAA@XZ");
722 SET(p_istream_assign_sb, "??4istream@@IEAAAEAV0@PEAVstreambuf@@@Z");
723 SET(p_istream_assign, "??4istream@@IEAAAEAV0@AEBV0@@Z");
724 SET(p_istream_vbase_dtor, "??_Distream@@QEAAXXZ");
725 SET(p_istream_eatwhite, "?eatwhite@istream@@QEAAXXZ");
726 SET(p_istream_ipfx, "?ipfx@istream@@QEAAHH@Z");
727 SET(p_istream_get_str_delim, "?get@istream@@IEAAAEAV1@PEADHH@Z");
728 SET(p_istream_get_str, "?get@istream@@QEAAAEAV1@PEADHD@Z");
729 SET(p_istream_get, "?get@istream@@QEAAHXZ");
730 SET(p_istream_get_char, "?get@istream@@QEAAAEAV1@AEAD@Z");
731 SET(p_istream_get_sb, "?get@istream@@QEAAAEAV1@AEAVstreambuf@@D@Z");
732 SET(p_istream_getline, "?getline@istream@@QEAAAEAV1@PEADHD@Z");
733 SET(p_istream_ignore, "?ignore@istream@@QEAAAEAV1@HH@Z");
734 SET(p_istream_peek, "?peek@istream@@QEAAHXZ");
735 SET(p_istream_putback, "?putback@istream@@QEAAAEAV1@D@Z");
736 SET(p_istream_read, "?read@istream@@QEAAAEAV1@PEADH@Z");
737 SET(p_istream_seekg, "?seekg@istream@@QEAAAEAV1@J@Z");
738 SET(p_istream_seekg_offset, "?seekg@istream@@QEAAAEAV1@JW4seek_dir@ios@@@Z");
739 SET(p_istream_sync, "?sync@istream@@QEAAHXZ");
740 SET(p_istream_tellg, "?tellg@istream@@QEAAJXZ");
741 SET(p_istream_getint, "?getint@istream@@AEAAHPEAD@Z");
742 SET(p_istream_getdouble, "?getdouble@istream@@AEAAHPEADH@Z");
743 SET(p_istream_read_char, "??5istream@@QEAAAEAV0@AEAD@Z");
744 SET(p_istream_read_str, "??5istream@@QEAAAEAV0@PEAD@Z");
745 SET(p_istream_read_short, "??5istream@@QEAAAEAV0@AEAF@Z");
746 SET(p_istream_read_unsigned_short, "??5istream@@QEAAAEAV0@AEAG@Z");
747 SET(p_istream_read_int, "??5istream@@QEAAAEAV0@AEAH@Z");
748 SET(p_istream_read_unsigned_int, "??5istream@@QEAAAEAV0@AEAI@Z");
749 SET(p_istream_read_long, "??5istream@@QEAAAEAV0@AEAJ@Z");
750 SET(p_istream_read_unsigned_long, "??5istream@@QEAAAEAV0@AEAK@Z");
751 SET(p_istream_read_float, "??5istream@@QEAAAEAV0@AEAM@Z");
752 SET(p_istream_read_double, "??5istream@@QEAAAEAV0@AEAN@Z");
753 SET(p_istream_read_long_double, "??5istream@@QEAAAEAV0@AEAO@Z");
754 SET(p_istream_read_streambuf, "??5istream@@QEAAAEAV0@PEAVstreambuf@@@Z");
756 SET(p_istream_withassign_sb_ctor, "??0istream_withassign@@QEAA@PEAVstreambuf@@@Z");
757 SET(p_istream_withassign_copy_ctor, "??0istream_withassign@@QEAA@AEBV0@@Z");
758 SET(p_istream_withassign_ctor, "??0istream_withassign@@QEAA@XZ");
759 SET(p_istream_withassign_dtor, "??1ostream_withassign@@UEAA@XZ");
760 SET(p_istream_withassign_vbase_dtor, "??_Distream_withassign@@QEAAXXZ");
761 SET(p_istream_withassign_assign_sb, "??4istream_withassign@@QEAAAEAVistream@@PEAVstreambuf@@@Z");
762 SET(p_istream_withassign_assign_is, "??4istream_withassign@@QEAAAEAVistream@@AEBV1@@Z");
763 SET(p_istream_withassign_assign, "??4istream_withassign@@QEAAAEAV0@AEBV0@@Z");
765 SET(p_istrstream_copy_ctor, "??0istrstream@@QEAA@AEBV0@@Z");
766 SET(p_istrstream_str_ctor, "??0istrstream@@QEAA@PEAD@Z");
767 SET(p_istrstream_buffer_ctor, "??0istrstream@@QEAA@PEADH@Z");
768 SET(p_istrstream_dtor, "??1istrstream@@UEAA@XZ");
769 SET(p_istrstream_vbase_dtor, "??_Distrstream@@QEAAXXZ");
770 SET(p_istrstream_assign, "??4istrstream@@QEAAAEAV0@AEBV0@@Z");
772 SET(p_iostream_copy_ctor, "??0iostream@@IEAA@AEBV0@@Z");
773 SET(p_iostream_sb_ctor, "??0iostream@@QEAA@PEAVstreambuf@@@Z");
774 SET(p_iostream_ctor, "??0iostream@@IEAA@XZ");
775 SET(p_iostream_dtor, "??1iostream@@UEAA@XZ");
776 SET(p_iostream_vbase_dtor, "??_Diostream@@QEAAXXZ");
777 SET(p_iostream_assign_sb, "??4iostream@@IEAAAEAV0@PEAVstreambuf@@@Z");
778 SET(p_iostream_assign, "??4iostream@@IEAAAEAV0@AEAV0@@Z");
780 SET(p_ifstream_copy_ctor, "??0ifstream@@QEAA@AEBV0@@Z");
781 SET(p_ifstream_buffer_ctor, "??0ifstream@@QEAA@HPEADH@Z");
782 SET(p_ifstream_fd_ctor, "??0ifstream@@QEAA@H@Z");
783 SET(p_ifstream_open_ctor, "??0ifstream@@QEAA@PEBDHH@Z");
784 SET(p_ifstream_ctor, "??0ifstream@@QEAA@XZ");
785 SET(p_ifstream_dtor, "??1ifstream@@UEAA@XZ");
786 SET(p_ifstream_vbase_dtor, "??_Difstream@@QEAAXXZ");
787 SET(p_ifstream_attach, "?attach@ifstream@@QEAAXH@Z");
788 SET(p_ifstream_close, "?close@ifstream@@QEAAXXZ");
789 SET(p_ifstream_fd, "?fd@ifstream@@QEBAHXZ");
790 SET(p_ifstream_is_open, "?is_open@ifstream@@QEBAHXZ");
791 SET(p_ifstream_open, "?open@ifstream@@QEAAXPEBDHH@Z");
792 SET(p_ifstream_rdbuf, "?rdbuf@ifstream@@QEBAPEAVfilebuf@@XZ");
793 SET(p_ifstream_setbuf, "?setbuf@ifstream@@QEAAPEAVstreambuf@@PEADH@Z");
794 SET(p_ifstream_setmode, "?setmode@ifstream@@QEAAHH@Z");
796 SET(p_strstream_copy_ctor, "??0strstream@@QEAA@AEBV0@@Z");
797 SET(p_strstream_buffer_ctor, "??0strstream@@QEAA@PEADHH@Z");
798 SET(p_strstream_ctor, "??0strstream@@QEAA@XZ");
799 SET(p_strstream_dtor, "??1strstream@@UEAA@XZ");
800 SET(p_strstream_vbase_dtor, "??_Dstrstream@@QEAAXXZ");
801 SET(p_strstream_assign, "??4strstream@@QEAAAEAV0@AEAV0@@Z");
803 SET(p_stdiostream_copy_ctor, "??0stdiostream@@QEAA@AEBV0@@Z");
804 SET(p_stdiostream_file_ctor, "??0stdiostream@@QEAA@PEAU_iobuf@@@Z");
805 SET(p_stdiostream_dtor, "??1stdiostream@@UEAA@XZ");
806 SET(p_stdiostream_vbase_dtor, "??_Dstdiostream@@QEAAXXZ");
807 SET(p_stdiostream_assign, "??4stdiostream@@QEAAAEAV0@AEAV0@@Z");
809 SET(p_fstream_copy_ctor, "??0fstream@@QEAA@AEBV0@@Z");
810 SET(p_fstream_buffer_ctor, "??0fstream@@QEAA@HPEADH@Z");
811 SET(p_fstream_fd_ctor, "??0fstream@@QEAA@H@Z");
812 SET(p_fstream_open_ctor, "??0fstream@@QEAA@PEBDHH@Z");
813 SET(p_fstream_ctor, "??0fstream@@QEAA@XZ");
814 SET(p_fstream_dtor, "??1fstream@@UEAA@XZ");
815 SET(p_fstream_vbase_dtor, "??_Dfstream@@QEAAXXZ");
816 SET(p_fstream_attach, "?attach@fstream@@QEAAXH@Z");
817 SET(p_fstream_close, "?close@fstream@@QEAAXXZ");
818 SET(p_fstream_fd, "?fd@fstream@@QEBAHXZ");
819 SET(p_fstream_is_open, "?is_open@fstream@@QEBAHXZ");
820 SET(p_fstream_open, "?open@fstream@@QEAAXPEBDHH@Z");
821 SET(p_fstream_rdbuf, "?rdbuf@fstream@@QEBAPEAVfilebuf@@XZ");
822 SET(p_fstream_setbuf, "?setbuf@fstream@@QEAAPEAVstreambuf@@PEADH@Z");
823 SET(p_fstream_setmode, "?setmode@fstream@@QEAAHH@Z");
825 SET(p_Iostream_init_ios_ctor, "??0Iostream_init@@QEAA@AEAVios@@H@Z");
827 SET(p_exception_ctor, "??0exception@@QEAA@AEBQEBD@Z");
828 SET(p_exception_dtor, "??1exception@@UEAA@XZ");
829 SET(p_exception_what, "?what@exception@@UEBAPEBDXZ");
831 SET(p_logic_error_ctor, "??0logic_error@@QEAA@AEBQEBD@Z");
832 SET(p_logic_error_dtor, "??1logic_error@@UEAA@XZ");
833 } else {
834 p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
835 p_operator_delete = (void*)GetProcAddress(msvcrt, "??3@YAXPAX@Z");
837 SET(p_streambuf_reserve_ctor, "??0streambuf@@IAE@PADH@Z");
838 SET(p_streambuf_ctor, "??0streambuf@@IAE@XZ");
839 SET(p_streambuf_dtor, "??1streambuf@@UAE@XZ");
840 SET(p_streambuf_allocate, "?allocate@streambuf@@IAEHXZ");
841 SET(p_streambuf_clrclock, "?clrlock@streambuf@@QAEXXZ");
842 SET(p_streambuf_doallocate, "?doallocate@streambuf@@MAEHXZ");
843 SET(p_streambuf_gbump, "?gbump@streambuf@@IAEXH@Z");
844 SET(p_streambuf_in_avail, "?in_avail@streambuf@@QBEHXZ");
845 SET(p_streambuf_lock, "?lock@streambuf@@QAEXXZ");
846 SET(p_streambuf_out_waiting, "?out_waiting@streambuf@@QBEHXZ");
847 SET(p_streambuf_pbackfail, "?pbackfail@streambuf@@UAEHH@Z");
848 SET(p_streambuf_pbump, "?pbump@streambuf@@IAEXH@Z");
849 SET(p_streambuf_sbumpc, "?sbumpc@streambuf@@QAEHXZ");
850 SET(p_streambuf_setb, "?setb@streambuf@@IAEXPAD0H@Z");
851 SET(p_streambuf_setbuf, "?setbuf@streambuf@@UAEPAV1@PADH@Z");
852 SET(p_streambuf_setlock, "?setlock@streambuf@@QAEXXZ");
853 SET(p_streambuf_sgetc, "?sgetc@streambuf@@QAEHXZ");
854 SET(p_streambuf_snextc, "?snextc@streambuf@@QAEHXZ");
855 SET(p_streambuf_sputc, "?sputc@streambuf@@QAEHH@Z");
856 SET(p_streambuf_stossc, "?stossc@streambuf@@QAEXXZ");
857 SET(p_streambuf_sync, "?sync@streambuf@@UAEHXZ");
858 SET(p_streambuf_unlock, "?unlock@streambuf@@QAEXXZ");
859 SET(p_streambuf_xsgetn, "?xsgetn@streambuf@@UAEHPADH@Z");
860 SET(p_streambuf_xsputn, "?xsputn@streambuf@@UAEHPBDH@Z");
862 SET(p_filebuf_fd_ctor, "??0filebuf@@QAE@H@Z");
863 SET(p_filebuf_fd_reserve_ctor, "??0filebuf@@QAE@HPADH@Z");
864 SET(p_filebuf_ctor, "??0filebuf@@QAE@XZ");
865 SET(p_filebuf_dtor, "??1filebuf@@UAE@XZ");
866 SET(p_filebuf_attach, "?attach@filebuf@@QAEPAV1@H@Z");
867 SET(p_filebuf_open, "?open@filebuf@@QAEPAV1@PBDHH@Z");
868 SET(p_filebuf_close, "?close@filebuf@@QAEPAV1@XZ");
869 SET(p_filebuf_setmode, "?setmode@filebuf@@QAEHH@Z");
870 SET(p_filebuf_setbuf, "?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z");
871 SET(p_filebuf_sync, "?sync@filebuf@@UAEHXZ");
872 SET(p_filebuf_overflow, "?overflow@filebuf@@UAEHH@Z");
873 SET(p_filebuf_underflow, "?underflow@filebuf@@UAEHXZ");
874 SET(p_filebuf_seekoff, "?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z");
875 SET(p_filebuf_is_open, "?is_open@filebuf@@QBEHXZ");
877 SET(p_strstreambuf_dynamic_ctor, "??0strstreambuf@@QAE@H@Z");
878 SET(p_strstreambuf_funcs_ctor, "??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z");
879 SET(p_strstreambuf_buffer_ctor, "??0strstreambuf@@QAE@PADH0@Z");
880 SET(p_strstreambuf_ubuffer_ctor, "??0strstreambuf@@QAE@PAEH0@Z");
881 SET(p_strstreambuf_ctor, "??0strstreambuf@@QAE@XZ");
882 SET(p_strstreambuf_dtor, "??1strstreambuf@@UAE@XZ");
883 SET(p_strstreambuf_doallocate, "?doallocate@strstreambuf@@MAEHXZ");
884 SET(p_strstreambuf_freeze, "?freeze@strstreambuf@@QAEXH@Z");
885 SET(p_strstreambuf_overflow, "?overflow@strstreambuf@@UAEHH@Z");
886 SET(p_strstreambuf_seekoff, "?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z");
887 SET(p_strstreambuf_setbuf, "?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z");
888 SET(p_strstreambuf_underflow, "?underflow@strstreambuf@@UAEHXZ");
890 SET(p_stdiobuf_file_ctor, "??0stdiobuf@@QAE@PAU_iobuf@@@Z");
891 SET(p_stdiobuf_dtor, "??1stdiobuf@@UAE@XZ");
892 SET(p_stdiobuf_overflow, "?overflow@stdiobuf@@UAEHH@Z");
893 SET(p_stdiobuf_pbackfail, "?pbackfail@stdiobuf@@UAEHH@Z");
894 SET(p_stdiobuf_seekoff, "?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z");
895 SET(p_stdiobuf_setrwbuf, "?setrwbuf@stdiobuf@@QAEHHH@Z");
896 SET(p_stdiobuf_sync, "?sync@stdiobuf@@UAEHXZ");
897 SET(p_stdiobuf_underflow, "?underflow@stdiobuf@@UAEHXZ");
899 SET(p_ios_copy_ctor, "??0ios@@IAE@ABV0@@Z");
900 SET(p_ios_ctor, "??0ios@@IAE@XZ");
901 SET(p_ios_sb_ctor, "??0ios@@QAE@PAVstreambuf@@@Z");
902 SET(p_ios_assign, "??4ios@@IAEAAV0@ABV0@@Z");
903 SET(p_ios_init, "?init@ios@@IAEXPAVstreambuf@@@Z");
904 SET(p_ios_dtor, "??1ios@@UAE@XZ");
905 SET(p_ios_clrlock, "?clrlock@ios@@QAAXXZ");
906 SET(p_ios_setlock, "?setlock@ios@@QAAXXZ");
907 SET(p_ios_lock, "?lock@ios@@QAAXXZ");
908 SET(p_ios_unlock, "?unlock@ios@@QAAXXZ");
909 SET(p_ios_lockbuf, "?lockbuf@ios@@QAAXXZ");
910 SET(p_ios_unlockbuf, "?unlockbuf@ios@@QAAXXZ");
911 SET(p_ios_flags_set, "?flags@ios@@QAEJJ@Z");
912 SET(p_ios_flags_get, "?flags@ios@@QBEJXZ");
913 SET(p_ios_setf, "?setf@ios@@QAEJJ@Z");
914 SET(p_ios_setf_mask, "?setf@ios@@QAEJJJ@Z");
915 SET(p_ios_unsetf, "?unsetf@ios@@QAEJJ@Z");
916 SET(p_ios_good, "?good@ios@@QBEHXZ");
917 SET(p_ios_bad, "?bad@ios@@QBEHXZ");
918 SET(p_ios_eof, "?eof@ios@@QBEHXZ");
919 SET(p_ios_fail, "?fail@ios@@QBEHXZ");
920 SET(p_ios_clear, "?clear@ios@@QAEXH@Z");
921 SET(p_ios_iword, "?iword@ios@@QBEAAJH@Z");
922 SET(p_ios_pword, "?pword@ios@@QBEAAPAXH@Z");
924 SET(p_ostream_copy_ctor, "??0ostream@@IAE@ABV0@@Z");
925 SET(p_ostream_sb_ctor, "??0ostream@@QAE@PAVstreambuf@@@Z");
926 SET(p_ostream_ctor, "??0ostream@@IAE@XZ");
927 SET(p_ostream_dtor, "??1ostream@@UAE@XZ");
928 SET(p_ostream_assign, "??4ostream@@IAEAAV0@ABV0@@Z");
929 SET(p_ostream_assign_sb, "??4ostream@@IAEAAV0@PAVstreambuf@@@Z");
930 SET(p_ostream_vbase_dtor, "??_Dostream@@QAEXXZ");
931 SET(p_ostream_flush, "?flush@ostream@@QAEAAV1@XZ");
932 SET(p_ostream_opfx, "?opfx@ostream@@QAEHXZ");
933 SET(p_ostream_osfx, "?osfx@ostream@@QAEXXZ");
934 SET(p_ostream_put_char, "?put@ostream@@QAEAAV1@D@Z");
935 SET(p_ostream_write_char, "?write@ostream@@QAEAAV1@PBDH@Z");
936 SET(p_ostream_seekp_offset, "?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z");
937 SET(p_ostream_seekp, "?seekp@ostream@@QAEAAV1@J@Z");
938 SET(p_ostream_tellp, "?tellp@ostream@@QAEJXZ");
939 SET(p_ostream_writepad, "?writepad@ostream@@AAEAAV1@PBD0@Z");
940 SET(p_ostream_print_char, "??6ostream@@QAEAAV0@D@Z");
941 SET(p_ostream_print_str, "??6ostream@@QAEAAV0@PBD@Z");
942 SET(p_ostream_print_int, "??6ostream@@QAEAAV0@H@Z");
943 SET(p_ostream_print_float, "??6ostream@@QAEAAV0@M@Z");
944 SET(p_ostream_print_double, "??6ostream@@QAEAAV0@N@Z");
945 SET(p_ostream_print_ptr, "??6ostream@@QAEAAV0@PBX@Z");
946 SET(p_ostream_print_streambuf, "??6ostream@@QAEAAV0@PAVstreambuf@@@Z");
948 SET(p_ostream_withassign_sb_ctor, "??0ostream_withassign@@QAE@PAVstreambuf@@@Z");
949 SET(p_ostream_withassign_copy_ctor, "??0ostream_withassign@@QAE@ABV0@@Z");
950 SET(p_ostream_withassign_ctor, "??0ostream_withassign@@QAE@XZ");
951 SET(p_ostream_withassign_dtor, "??1ostream_withassign@@UAE@XZ");
952 SET(p_ostream_withassign_vbase_dtor, "??_Dostream_withassign@@QAEXXZ");
953 SET(p_ostream_withassign_assign_sb, "??4ostream_withassign@@QAEAAVostream@@PAVstreambuf@@@Z");
954 SET(p_ostream_withassign_assign_os, "??4ostream_withassign@@QAEAAVostream@@ABV1@@Z");
955 SET(p_ostream_withassign_assign, "??4ostream_withassign@@QAEAAV0@ABV0@@Z");
957 SET(p_ostrstream_copy_ctor, "??0ostrstream@@QAE@ABV0@@Z");
958 SET(p_ostrstream_buffer_ctor, "??0ostrstream@@QAE@PADHH@Z");
959 SET(p_ostrstream_ctor, "??0ostrstream@@QAE@XZ");
960 SET(p_ostrstream_dtor, "??1ostrstream@@UAE@XZ");
961 SET(p_ostrstream_vbase_dtor, "??_Dostrstream@@QAEXXZ");
962 SET(p_ostrstream_assign, "??4ostrstream@@QAEAAV0@ABV0@@Z");
963 SET(p_ostrstream_pcount, "?pcount@ostrstream@@QBEHXZ");
965 SET(p_ofstream_copy_ctor, "??0ofstream@@QAE@ABV0@@Z");
966 SET(p_ofstream_fd_ctor, "??0ofstream@@QAE@H@Z");
967 SET(p_ofstream_buffer_ctor, "??0ofstream@@QAE@HPADH@Z");
968 SET(p_ofstream_open_ctor, "??0ofstream@@QAE@PBDHH@Z");
969 SET(p_ofstream_ctor, "??0ofstream@@QAE@XZ");
970 SET(p_ofstream_dtor, "??1ofstream@@UAE@XZ");
971 SET(p_ofstream_vbase_dtor, "??_Dofstream@@QAEXXZ");
972 SET(p_ofstream_attach, "?attach@ofstream@@QAEXH@Z");
973 SET(p_ofstream_close, "?close@ofstream@@QAEXXZ");
974 SET(p_ofstream_fd, "?fd@ofstream@@QBEHXZ");
975 SET(p_ofstream_is_open, "?is_open@ofstream@@QBEHXZ");
976 SET(p_ofstream_open, "?open@ofstream@@QAEXPBDHH@Z");
977 SET(p_ofstream_rdbuf, "?rdbuf@ofstream@@QBEPAVfilebuf@@XZ");
978 SET(p_ofstream_setbuf, "?setbuf@ofstream@@QAEPAVstreambuf@@PADH@Z");
979 SET(p_ofstream_setmode, "?setmode@ofstream@@QAEHH@Z");
981 SET(p_istream_copy_ctor, "??0istream@@IAE@ABV0@@Z");
982 SET(p_istream_ctor, "??0istream@@IAE@XZ");
983 SET(p_istream_sb_ctor, "??0istream@@QAE@PAVstreambuf@@@Z");
984 SET(p_istream_dtor, "??1istream@@UAE@XZ");
985 SET(p_istream_assign_sb, "??4istream@@IAEAAV0@PAVstreambuf@@@Z");
986 SET(p_istream_assign, "??4istream@@IAEAAV0@ABV0@@Z");
987 SET(p_istream_vbase_dtor, "??_Distream@@QAEXXZ");
988 SET(p_istream_eatwhite, "?eatwhite@istream@@QAEXXZ");
989 SET(p_istream_ipfx, "?ipfx@istream@@QAEHH@Z");
990 SET(p_istream_get_str_delim, "?get@istream@@IAEAAV1@PADHH@Z");
991 SET(p_istream_get_str, "?get@istream@@QAEAAV1@PADHD@Z");
992 SET(p_istream_get, "?get@istream@@QAEHXZ");
993 SET(p_istream_get_char, "?get@istream@@QAEAAV1@AAD@Z");
994 SET(p_istream_get_sb, "?get@istream@@QAEAAV1@AAVstreambuf@@D@Z");
995 SET(p_istream_getline, "?getline@istream@@QAEAAV1@PADHD@Z");
996 SET(p_istream_ignore, "?ignore@istream@@QAEAAV1@HH@Z");
997 SET(p_istream_peek, "?peek@istream@@QAEHXZ");
998 SET(p_istream_putback, "?putback@istream@@QAEAAV1@D@Z");
999 SET(p_istream_read, "?read@istream@@QAEAAV1@PADH@Z");
1000 SET(p_istream_seekg, "?seekg@istream@@QAEAAV1@J@Z");
1001 SET(p_istream_seekg_offset, "?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z");
1002 SET(p_istream_sync, "?sync@istream@@QAEHXZ");
1003 SET(p_istream_tellg, "?tellg@istream@@QAEJXZ");
1004 SET(p_istream_getint, "?getint@istream@@AAEHPAD@Z");
1005 SET(p_istream_getdouble, "?getdouble@istream@@AAEHPADH@Z");
1006 SET(p_istream_read_char, "??5istream@@QAEAAV0@AAD@Z");
1007 SET(p_istream_read_str, "??5istream@@QAEAAV0@PAD@Z");
1008 SET(p_istream_read_short, "??5istream@@QAEAAV0@AAF@Z");
1009 SET(p_istream_read_unsigned_short, "??5istream@@QAEAAV0@AAG@Z");
1010 SET(p_istream_read_int, "??5istream@@QAEAAV0@AAH@Z");
1011 SET(p_istream_read_unsigned_int, "??5istream@@QAEAAV0@AAI@Z");
1012 SET(p_istream_read_long, "??5istream@@QAEAAV0@AAJ@Z");
1013 SET(p_istream_read_unsigned_long, "??5istream@@QAEAAV0@AAK@Z");
1014 SET(p_istream_read_float, "??5istream@@QAEAAV0@AAM@Z");
1015 SET(p_istream_read_double, "??5istream@@QAEAAV0@AAN@Z");
1016 SET(p_istream_read_long_double, "??5istream@@QAEAAV0@AAO@Z");
1017 SET(p_istream_read_streambuf, "??5istream@@QAEAAV0@PAVstreambuf@@@Z");
1019 SET(p_istream_withassign_sb_ctor, "??0istream_withassign@@QAE@PAVstreambuf@@@Z");
1020 SET(p_istream_withassign_copy_ctor, "??0istream_withassign@@QAE@ABV0@@Z");
1021 SET(p_istream_withassign_ctor, "??0istream_withassign@@QAE@XZ");
1022 SET(p_istream_withassign_dtor, "??1istream_withassign@@UAE@XZ");
1023 SET(p_istream_withassign_vbase_dtor, "??_Distream_withassign@@QAEXXZ");
1024 SET(p_istream_withassign_assign_sb, "??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z");
1025 SET(p_istream_withassign_assign_is, "??4istream_withassign@@QAEAAVistream@@ABV1@@Z");
1026 SET(p_istream_withassign_assign, "??4istream_withassign@@QAEAAV0@ABV0@@Z");
1028 SET(p_istrstream_copy_ctor, "??0istrstream@@QAE@ABV0@@Z");
1029 SET(p_istrstream_str_ctor, "??0istrstream@@QAE@PAD@Z");
1030 SET(p_istrstream_buffer_ctor, "??0istrstream@@QAE@PADH@Z");
1031 SET(p_istrstream_dtor, "??1istrstream@@UAE@XZ");
1032 SET(p_istrstream_vbase_dtor, "??_Distrstream@@QAEXXZ");
1033 SET(p_istrstream_assign, "??4istrstream@@QAEAAV0@ABV0@@Z");
1035 SET(p_iostream_copy_ctor, "??0iostream@@IAE@ABV0@@Z");
1036 SET(p_iostream_sb_ctor, "??0iostream@@QAE@PAVstreambuf@@@Z");
1037 SET(p_iostream_ctor, "??0iostream@@IAE@XZ");
1038 SET(p_iostream_dtor, "??1iostream@@UAE@XZ");
1039 SET(p_iostream_vbase_dtor, "??_Diostream@@QAEXXZ");
1040 SET(p_iostream_assign_sb, "??4iostream@@IAEAAV0@PAVstreambuf@@@Z");
1041 SET(p_iostream_assign, "??4iostream@@IAEAAV0@AAV0@@Z");
1043 SET(p_ifstream_copy_ctor, "??0ifstream@@QAE@ABV0@@Z");
1044 SET(p_ifstream_fd_ctor, "??0ifstream@@QAE@H@Z");
1045 SET(p_ifstream_buffer_ctor, "??0ifstream@@QAE@HPADH@Z");
1046 SET(p_ifstream_open_ctor, "??0ifstream@@QAE@PBDHH@Z");
1047 SET(p_ifstream_ctor, "??0ifstream@@QAE@XZ");
1048 SET(p_ifstream_dtor, "??1ifstream@@UAE@XZ");
1049 SET(p_ifstream_vbase_dtor, "??_Difstream@@QAEXXZ");
1050 SET(p_ifstream_attach, "?attach@ifstream@@QAEXH@Z");
1051 SET(p_ifstream_close, "?close@ifstream@@QAEXXZ");
1052 SET(p_ifstream_fd, "?fd@ifstream@@QBEHXZ");
1053 SET(p_ifstream_is_open, "?is_open@ifstream@@QBEHXZ");
1054 SET(p_ifstream_open, "?open@ifstream@@QAEXPBDHH@Z");
1055 SET(p_ifstream_rdbuf, "?rdbuf@ifstream@@QBEPAVfilebuf@@XZ");
1056 SET(p_ifstream_setbuf, "?setbuf@ifstream@@QAEPAVstreambuf@@PADH@Z");
1057 SET(p_ifstream_setmode, "?setmode@ifstream@@QAEHH@Z");
1059 SET(p_strstream_copy_ctor, "??0strstream@@QAE@ABV0@@Z");
1060 SET(p_strstream_buffer_ctor, "??0strstream@@QAE@PADHH@Z");
1061 SET(p_strstream_ctor, "??0strstream@@QAE@XZ");
1062 SET(p_strstream_dtor, "??1strstream@@UAE@XZ");
1063 SET(p_strstream_vbase_dtor, "??_Dstrstream@@QAEXXZ");
1064 SET(p_strstream_assign, "??4strstream@@QAEAAV0@AAV0@@Z");
1066 SET(p_stdiostream_copy_ctor, "??0stdiostream@@QAE@ABV0@@Z");
1067 SET(p_stdiostream_file_ctor, "??0stdiostream@@QAE@PAU_iobuf@@@Z");
1068 SET(p_stdiostream_dtor, "??1stdiostream@@UAE@XZ");
1069 SET(p_stdiostream_vbase_dtor, "??_Dstdiostream@@QAEXXZ");
1070 SET(p_stdiostream_assign, "??4stdiostream@@QAEAAV0@AAV0@@Z");
1072 SET(p_fstream_copy_ctor, "??0fstream@@QAE@ABV0@@Z");
1073 SET(p_fstream_fd_ctor, "??0fstream@@QAE@H@Z");
1074 SET(p_fstream_buffer_ctor, "??0fstream@@QAE@HPADH@Z");
1075 SET(p_fstream_open_ctor, "??0fstream@@QAE@PBDHH@Z");
1076 SET(p_fstream_ctor, "??0fstream@@QAE@XZ");
1077 SET(p_fstream_dtor, "??1fstream@@UAE@XZ");
1078 SET(p_fstream_vbase_dtor, "??_Dfstream@@QAEXXZ");
1079 SET(p_fstream_attach, "?attach@fstream@@QAEXH@Z");
1080 SET(p_fstream_close, "?close@fstream@@QAEXXZ");
1081 SET(p_fstream_fd, "?fd@fstream@@QBEHXZ");
1082 SET(p_fstream_is_open, "?is_open@fstream@@QBEHXZ");
1083 SET(p_fstream_open, "?open@fstream@@QAEXPBDHH@Z");
1084 SET(p_fstream_rdbuf, "?rdbuf@fstream@@QBEPAVfilebuf@@XZ");
1085 SET(p_fstream_setbuf, "?setbuf@fstream@@QAEPAVstreambuf@@PADH@Z");
1086 SET(p_fstream_setmode, "?setmode@fstream@@QAEHH@Z");
1088 SET(p_Iostream_init_ios_ctor, "??0Iostream_init@@QAE@AAVios@@H@Z");
1090 SET(p_exception_ctor, "??0exception@@QAE@ABQBD@Z");
1091 SET(p_exception_dtor, "??1exception@@UAE@XZ");
1092 SET(p_exception_what, "?what@exception@@UBEPBDXZ");
1094 SET(p_logic_error_ctor, "??0logic_error@@QAE@ABQBD@Z");
1095 SET(p_logic_error_dtor, "??1logic_error@@UAE@XZ");
1097 SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
1098 SET(p_ios_lockc, "?lockc@ios@@KAXXZ");
1099 SET(p_ios_unlockc, "?unlockc@ios@@KAXXZ");
1100 SET(p_ios_maxbit, "?x_maxbit@ios@@0JA");
1101 SET(p_ios_bitalloc, "?bitalloc@ios@@SAJXZ");
1102 SET(p_ios_curindex, "?x_curindex@ios@@0HA");
1103 SET(p_ios_statebuf, "?x_statebuf@ios@@0PAJA");
1104 SET(p_ios_xalloc, "?xalloc@ios@@SAHXZ");
1105 SET(p_ios_sync_with_stdio, "?sync_with_stdio@ios@@SAXXZ");
1106 SET(p_ios_sunk_with_stdio, "?sunk_with_stdio@ios@@0HA");
1107 SET(p_ios_fLockcInit, "?fLockcInit@ios@@0HA");
1108 SET(p_cin, "?cin@@3Vistream_withassign@@A");
1109 SET(p_cout, "?cout@@3Vostream_withassign@@A");
1110 SET(p_cerr, "?cerr@@3Vostream_withassign@@A");
1111 SET(p_clog, "?clog@@3Vostream_withassign@@A");
1113 SET(p__mtlock, "_mtlock");
1114 SET(p__mtunlock, "_mtunlock");
1116 init_thiscall_thunk();
1117 return TRUE;
1120 static int overflow_count, underflow_count;
1121 static streambuf *test_this;
1122 static char test_get_buffer[24];
1123 static int buffer_pos, get_end;
1125 #ifdef __i386__
1126 static int __thiscall test_streambuf_overflow(int ch)
1127 #else
1128 static int __thiscall test_streambuf_overflow(streambuf *this, int ch)
1129 #endif
1131 overflow_count++;
1132 if (ch == 'L') /* simulate a failure */
1133 return EOF;
1134 if (!test_this->unbuffered)
1135 test_this->pptr = test_this->pbase + 5;
1136 return (unsigned char)ch;
1139 #ifdef __i386__
1140 static int __thiscall test_streambuf_underflow(void)
1141 #else
1142 static int __thiscall test_streambuf_underflow(streambuf *this)
1143 #endif
1145 underflow_count++;
1146 if (test_this->unbuffered) {
1147 return (buffer_pos < 23) ? (unsigned char)test_get_buffer[buffer_pos++] : EOF;
1148 } else if (test_this->gptr < test_this->egptr) {
1149 return (unsigned char)*test_this->gptr;
1150 } else {
1151 return get_end ? EOF : (unsigned char)*(test_this->gptr = test_this->eback);
1155 struct streambuf_lock_arg
1157 streambuf *sb;
1158 HANDLE lock[4];
1159 HANDLE test[4];
1162 static DWORD WINAPI lock_streambuf(void *arg)
1164 struct streambuf_lock_arg *lock_arg = arg;
1165 call_func1(p_streambuf_lock, lock_arg->sb);
1166 SetEvent(lock_arg->lock[0]);
1167 WaitForSingleObject(lock_arg->test[0], INFINITE);
1168 call_func1(p_streambuf_lock, lock_arg->sb);
1169 SetEvent(lock_arg->lock[1]);
1170 WaitForSingleObject(lock_arg->test[1], INFINITE);
1171 call_func1(p_streambuf_lock, lock_arg->sb);
1172 SetEvent(lock_arg->lock[2]);
1173 WaitForSingleObject(lock_arg->test[2], INFINITE);
1174 call_func1(p_streambuf_unlock, lock_arg->sb);
1175 SetEvent(lock_arg->lock[3]);
1176 WaitForSingleObject(lock_arg->test[3], INFINITE);
1177 call_func1(p_streambuf_unlock, lock_arg->sb);
1178 return 0;
1181 static void test_streambuf(void)
1183 streambuf sb, sb2, sb3, *psb;
1184 vtable_ptr test_streambuf_vtbl[11];
1185 struct streambuf_lock_arg lock_arg;
1186 HANDLE thread;
1187 char reserve[16];
1188 int ret, i;
1189 BOOL locked;
1191 memset(&sb, 0xab, sizeof(streambuf));
1192 memset(&sb2, 0xab, sizeof(streambuf));
1193 memset(&sb3, 0xab, sizeof(streambuf));
1195 /* constructors */
1196 call_func1(p_streambuf_ctor, &sb);
1197 ok(sb.allocated == 0, "wrong allocate value, expected 0 got %d\n", sb.allocated);
1198 ok(sb.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb.unbuffered);
1199 ok(sb.base == NULL, "wrong base pointer, expected %p got %p\n", NULL, sb.base);
1200 ok(sb.ebuf == NULL, "wrong ebuf pointer, expected %p got %p\n", NULL, sb.ebuf);
1201 ok(sb.lock.LockCount == -1, "wrong critical section state, expected -1 got %lu\n", sb.lock.LockCount);
1202 call_func3(p_streambuf_reserve_ctor, &sb2, reserve, 16);
1203 ok(sb2.allocated == 0, "wrong allocate value, expected 0 got %d\n", sb2.allocated);
1204 ok(sb2.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb2.unbuffered);
1205 ok(sb2.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb2.base);
1206 ok(sb2.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb2.ebuf);
1207 ok(sb.lock.LockCount == -1, "wrong critical section state, expected -1 got %lu\n", sb.lock.LockCount);
1208 call_func1(p_streambuf_ctor, &sb3);
1209 ok(sb3.allocated == 0, "wrong allocate value, expected 0 got %d\n", sb3.allocated);
1210 ok(sb3.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb3.unbuffered);
1211 ok(sb3.base == NULL, "wrong base pointer, expected %p got %p\n", NULL, sb3.base);
1212 ok(sb3.ebuf == NULL, "wrong ebuf pointer, expected %p got %p\n", NULL, sb3.ebuf);
1214 memcpy(test_streambuf_vtbl, sb.vtable, sizeof(test_streambuf_vtbl));
1215 test_streambuf_vtbl[7] = (vtable_ptr)&test_streambuf_overflow;
1216 test_streambuf_vtbl[8] = (vtable_ptr)&test_streambuf_underflow;
1217 sb2.vtable = test_streambuf_vtbl;
1218 sb3.vtable = test_streambuf_vtbl;
1219 overflow_count = underflow_count = 0;
1220 strcpy(test_get_buffer, "CompuGlobalHyperMegaNet");
1221 buffer_pos = get_end = 0;
1223 /* setlock */
1224 ok(sb.do_lock == -1, "expected do_lock value -1, got %d\n", sb.do_lock);
1225 call_func1(p_streambuf_setlock, &sb);
1226 ok(sb.do_lock == -2, "expected do_lock value -2, got %d\n", sb.do_lock);
1227 call_func1(p_streambuf_setlock, &sb);
1228 ok(sb.do_lock == -3, "expected do_lock value -3, got %d\n", sb.do_lock);
1229 sb.do_lock = 3;
1230 call_func1(p_streambuf_setlock, &sb);
1231 ok(sb.do_lock == 2, "expected do_lock value 2, got %d\n", sb.do_lock);
1233 /* clrlock */
1234 sb.do_lock = -2;
1235 call_func1(p_streambuf_clrclock, &sb);
1236 ok(sb.do_lock == -1, "expected do_lock value -1, got %d\n", sb.do_lock);
1237 call_func1(p_streambuf_clrclock, &sb);
1238 ok(sb.do_lock == 0, "expected do_lock value 0, got %d\n", sb.do_lock);
1239 call_func1(p_streambuf_clrclock, &sb);
1240 ok(sb.do_lock == 1, "expected do_lock value 1, got %d\n", sb.do_lock);
1241 call_func1(p_streambuf_clrclock, &sb);
1242 ok(sb.do_lock == 1, "expected do_lock value 1, got %d\n", sb.do_lock);
1244 /* lock/unlock */
1245 lock_arg.sb = &sb;
1246 for (i = 0; i < 4; i++) {
1247 lock_arg.lock[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
1248 ok(lock_arg.lock[i] != NULL, "CreateEventW failed\n");
1249 lock_arg.test[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
1250 ok(lock_arg.test[i] != NULL, "CreateEventW failed\n");
1253 sb.do_lock = 0;
1254 thread = CreateThread(NULL, 0, lock_streambuf, (void*)&lock_arg, 0, NULL);
1255 ok(thread != NULL, "CreateThread failed\n");
1256 WaitForSingleObject(lock_arg.lock[0], INFINITE);
1257 locked = TryEnterCriticalSection(&sb.lock);
1258 ok(locked != 0, "could not lock the streambuf\n");
1259 LeaveCriticalSection(&sb.lock);
1261 sb.do_lock = 1;
1262 SetEvent(lock_arg.test[0]);
1263 WaitForSingleObject(lock_arg.lock[1], INFINITE);
1264 locked = TryEnterCriticalSection(&sb.lock);
1265 ok(locked != 0, "could not lock the streambuf\n");
1266 LeaveCriticalSection(&sb.lock);
1268 sb.do_lock = -1;
1269 SetEvent(lock_arg.test[1]);
1270 WaitForSingleObject(lock_arg.lock[2], INFINITE);
1271 locked = TryEnterCriticalSection(&sb.lock);
1272 ok(locked == 0, "the streambuf was not locked before\n");
1274 sb.do_lock = 0;
1275 SetEvent(lock_arg.test[2]);
1276 WaitForSingleObject(lock_arg.lock[3], INFINITE);
1277 locked = TryEnterCriticalSection(&sb.lock);
1278 ok(locked == 0, "the streambuf was not locked before\n");
1279 sb.do_lock = -1;
1281 /* setb */
1282 sb.unbuffered = 1;
1283 call_func4(p_streambuf_setb, &sb, reserve, reserve+16, 0);
1284 ok(sb.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", sb.unbuffered);
1285 ok(sb.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb.base);
1286 ok(sb.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb.ebuf);
1287 call_func4(p_streambuf_setb, &sb, reserve, reserve+16, 4);
1288 ok(sb.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", sb.unbuffered);
1289 ok(sb.allocated == 4, "wrong allocate value, expected 4 got %d\n", sb.allocated);
1290 sb.allocated = 0;
1291 sb.unbuffered = 0;
1292 call_func4(p_streambuf_setb, &sb, NULL, NULL, 3);
1293 ok(sb.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb.unbuffered);
1294 ok(sb.allocated == 3, "wrong allocate value, expected 3 got %d\n", sb.allocated);
1296 /* setbuf */
1297 sb.unbuffered = 0;
1298 psb = call_func3(p_streambuf_setbuf, &sb, NULL, 5);
1299 ok(psb == &sb, "wrong return value, expected %p got %p\n", &sb, psb);
1300 ok(sb.allocated == 3, "wrong allocate value, expected 3 got %d\n", sb.allocated);
1301 ok(sb.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", sb.unbuffered);
1302 ok(sb.base == NULL, "wrong base pointer, expected %p got %p\n", NULL, sb.base);
1303 ok(sb.ebuf == NULL, "wrong ebuf pointer, expected %p got %p\n", NULL, sb.ebuf);
1304 psb = call_func3(p_streambuf_setbuf, &sb, reserve, 0);
1305 ok(psb == &sb, "wrong return value, expected %p got %p\n", &sb, psb);
1306 ok(sb.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", sb.unbuffered);
1307 ok(sb.base == NULL, "wrong base pointer, expected %p got %p\n", NULL, sb.base);
1308 ok(sb.ebuf == NULL, "wrong ebuf pointer, expected %p got %p\n", NULL, sb.ebuf);
1309 psb = call_func3(p_streambuf_setbuf, &sb, reserve, 16);
1310 ok(psb == &sb, "wrong return value, expected %p got %p\n", &sb, psb);
1311 ok(sb.allocated == 3, "wrong allocate value, expected 3 got %d\n", sb.allocated);
1312 ok(sb.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb.unbuffered);
1313 ok(sb.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb.base);
1314 ok(sb.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb.ebuf);
1315 psb = call_func3(p_streambuf_setbuf, &sb, NULL, 8);
1316 ok(psb == NULL, "wrong return value, expected %p got %p\n", NULL, psb);
1317 ok(sb.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", sb.unbuffered);
1318 ok(sb.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb.base);
1319 ok(sb.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb.ebuf);
1321 /* allocate */
1322 ret = (int) call_func1(p_streambuf_allocate, &sb);
1323 ok(ret == 0, "wrong return value, expected 0 got %d\n", ret);
1324 sb.base = NULL;
1325 ret = (int) call_func1(p_streambuf_allocate, &sb);
1326 ok(ret == 1, "wrong return value, expected 1 got %d\n", ret);
1327 ok(sb.allocated == 1, "wrong allocate value, expected 1 got %d\n", sb.allocated);
1328 ok(sb.ebuf - sb.base == 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb.ebuf, sb.base);
1330 /* doallocate */
1331 ret = (int) call_func1(p_streambuf_doallocate, &sb2);
1332 ok(ret == 1, "doallocate failed, got %d\n", ret);
1333 ok(sb2.allocated == 1, "wrong allocate value, expected 1 got %d\n", sb2.allocated);
1334 ok(sb2.ebuf - sb2.base == 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb2.ebuf, sb2.base);
1335 ret = (int) call_func1(p_streambuf_doallocate, &sb3);
1336 ok(ret == 1, "doallocate failed, got %d\n", ret);
1337 ok(sb3.allocated == 1, "wrong allocate value, expected 1 got %d\n", sb3.allocated);
1338 ok(sb3.ebuf - sb3.base == 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb3.ebuf, sb3.base);
1340 /* sb: buffered, space available */
1341 sb.eback = sb.gptr = sb.base;
1342 sb.egptr = sb.base + 256;
1343 sb.pbase = sb.pptr = sb.base + 256;
1344 sb.epptr = sb.base + 512;
1345 /* sb2: buffered, no space available */
1346 sb2.eback = sb2.base;
1347 sb2.gptr = sb2.egptr = sb2.base + 256;
1348 sb2.pbase = sb2.base + 256;
1349 sb2.pptr = sb2.epptr = sb2.base + 512;
1350 /* sb3: unbuffered */
1351 sb3.unbuffered = 1;
1353 /* gbump */
1354 call_func2(p_streambuf_gbump, &sb, 10);
1355 ok(sb.gptr == sb.eback + 10, "advance get pointer failed, expected %p got %p\n", sb.eback + 10, sb.gptr);
1356 call_func2(p_streambuf_gbump, &sb, -15);
1357 ok(sb.gptr == sb.eback - 5, "advance get pointer failed, expected %p got %p\n", sb.eback - 5, sb.gptr);
1358 sb.gptr = sb.eback;
1360 /* pbump */
1361 call_func2(p_streambuf_pbump, &sb, -2);
1362 ok(sb.pptr == sb.pbase - 2, "advance put pointer failed, expected %p got %p\n", sb.pbase - 2, sb.pptr);
1363 call_func2(p_streambuf_pbump, &sb, 20);
1364 ok(sb.pptr == sb.pbase + 18, "advance put pointer failed, expected %p got %p\n", sb.pbase + 18, sb.pptr);
1365 sb.pptr = sb.pbase;
1367 /* sync */
1368 ret = (int) call_func1(p_streambuf_sync, &sb);
1369 ok(ret == EOF, "sync failed, expected EOF got %d\n", ret);
1370 sb.gptr = sb.egptr;
1371 ret = (int) call_func1(p_streambuf_sync, &sb);
1372 ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
1373 sb.gptr = sb.egptr + 1;
1374 ret = (int) call_func1(p_streambuf_sync, &sb);
1375 ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
1376 sb.gptr = sb.eback;
1377 ret = (int) call_func1(p_streambuf_sync, &sb2);
1378 ok(ret == EOF, "sync failed, expected EOF got %d\n", ret);
1379 sb2.pptr = sb2.pbase;
1380 ret = (int) call_func1(p_streambuf_sync, &sb2);
1381 ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
1382 sb2.pptr = sb2.pbase - 1;
1383 ret = (int) call_func1(p_streambuf_sync, &sb2);
1384 ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
1385 sb2.pptr = sb2.epptr;
1386 ret = (int) call_func1(p_streambuf_sync, &sb3);
1387 ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
1389 /* sgetc */
1390 strcpy(sb2.eback, "WorstTestEver");
1391 test_this = &sb2;
1392 ret = (int) call_func1(p_streambuf_sgetc, &sb2);
1393 ok(ret == 'W', "expected 'W' got '%c'\n", ret);
1394 ok(underflow_count == 1, "expected call to underflow\n");
1395 ok(sb2.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb2.stored_char);
1396 sb2.gptr++;
1397 ret = (int) call_func1(p_streambuf_sgetc, &sb2);
1398 ok(ret == 'o', "expected 'o' got '%c'\n", ret);
1399 ok(underflow_count == 2, "expected call to underflow\n");
1400 ok(sb2.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb2.stored_char);
1401 sb2.gptr = sb2.egptr;
1402 test_this = &sb3;
1403 ret = (int) call_func1(p_streambuf_sgetc, &sb3);
1404 ok(ret == 'C', "expected 'C' got '%c'\n", ret);
1405 ok(underflow_count == 3, "expected call to underflow\n");
1406 ok(sb3.stored_char == 'C', "wrong stored character, expected 'C' got %c\n", sb3.stored_char);
1407 sb3.stored_char = 'b';
1408 ret = (int) call_func1(p_streambuf_sgetc, &sb3);
1409 ok(ret == 'b', "expected 'b' got '%c'\n", ret);
1410 ok(underflow_count == 3, "no call to underflow expected\n");
1411 ok(sb3.stored_char == 'b', "wrong stored character, expected 'b' got %c\n", sb3.stored_char);
1413 /* sputc */
1414 *sb.pbase = 'a';
1415 ret = (int) call_func2(p_streambuf_sputc, &sb, 'c');
1416 ok(ret == 'c', "wrong return value, expected 'c' got %d\n", ret);
1417 ok(overflow_count == 0, "no call to overflow expected\n");
1418 ok(*sb.pbase == 'c', "expected 'c' in the put area, got %c\n", *sb.pbase);
1419 ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
1420 sb.pptr--;
1421 ret = (int) call_func2(p_streambuf_sputc, &sb, 150);
1422 ok(ret == 150, "wrong return value, expected 150 got %d\n", ret);
1423 ok(overflow_count == 0, "no call to overflow expected\n");
1424 ok((signed char)*sb.pbase == -106, "expected -106 in the put area, got %d\n", *sb.pbase);
1425 ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
1426 sb.pptr--;
1427 ret = (int) call_func2(p_streambuf_sputc, &sb, -50);
1428 ok(ret == 206, "wrong return value, expected 206 got %d\n", ret);
1429 ok(overflow_count == 0, "no call to overflow expected\n");
1430 ok((signed char)*sb.pbase == -50, "expected -50 in the put area, got %d\n", *sb.pbase);
1431 ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
1432 test_this = &sb2;
1433 ret = (int) call_func2(p_streambuf_sputc, &sb2, 'c');
1434 ok(ret == 'c', "wrong return value, expected 'c' got %d\n", ret);
1435 ok(overflow_count == 1, "expected call to overflow\n");
1436 ok(sb2.pptr == sb2.pbase + 5, "wrong put pointer, expected %p got %p\n", sb2.pbase + 5, sb2.pptr);
1437 test_this = &sb3;
1438 ret = (int) call_func2(p_streambuf_sputc, &sb3, 'c');
1439 ok(ret == 'c', "wrong return value, expected 'c' got %d\n", ret);
1440 ok(overflow_count == 2, "expected call to overflow\n");
1441 sb3.pbase = sb3.pptr = sb3.base;
1442 sb3.epptr = sb3.ebuf;
1443 ret = (int) call_func2(p_streambuf_sputc, &sb3, 'c');
1444 ok(ret == 'c', "wrong return value, expected 'c' got %d\n", ret);
1445 ok(overflow_count == 2, "no call to overflow expected\n");
1446 ok(*sb3.pbase == 'c', "expected 'c' in the put area, got %c\n", *sb3.pbase);
1447 sb3.pbase = sb3.pptr = sb3.epptr = NULL;
1449 /* xsgetn */
1450 sb2.gptr = sb2.egptr = sb2.eback + 13;
1451 test_this = &sb2;
1452 ret = (int) call_func3(p_streambuf_xsgetn, &sb2, reserve, 5);
1453 ok(ret == 5, "wrong return value, expected 5 got %d\n", ret);
1454 ok(!strncmp(reserve, "Worst", 5), "expected 'Worst' got %s\n", reserve);
1455 ok(sb2.gptr == sb2.eback + 5, "wrong get pointer, expected %p got %p\n", sb2.eback + 5, sb2.gptr);
1456 ok(underflow_count == 4, "expected call to underflow\n");
1457 ret = (int) call_func3(p_streambuf_xsgetn, &sb2, reserve, 4);
1458 ok(ret == 4, "wrong return value, expected 4 got %d\n", ret);
1459 ok(!strncmp(reserve, "Test", 4), "expected 'Test' got %s\n", reserve);
1460 ok(sb2.gptr == sb2.eback + 9, "wrong get pointer, expected %p got %p\n", sb2.eback + 9, sb2.gptr);
1461 ok(underflow_count == 5, "expected call to underflow\n");
1462 get_end = 1;
1463 ret = (int) call_func3(p_streambuf_xsgetn, &sb2, reserve, 16);
1464 ok(ret == 4, "wrong return value, expected 4 got %d\n", ret);
1465 ok(!strncmp(reserve, "Ever", 4), "expected 'Ever' got %s\n", reserve);
1466 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1467 ok(underflow_count == 7, "expected 2 calls to underflow, got %d\n", underflow_count - 5);
1468 test_this = &sb3;
1469 ret = (int) call_func3(p_streambuf_xsgetn, &sb3, reserve, 11);
1470 ok(ret == 11, "wrong return value, expected 11 got %d\n", ret);
1471 ok(!strncmp(reserve, "bompuGlobal", 11), "expected 'bompuGlobal' got %s\n", reserve);
1472 ok(sb3.stored_char == 'H', "wrong stored character, expected 'H' got %c\n", sb3.stored_char);
1473 ok(underflow_count == 18, "expected 11 calls to underflow, got %d\n", underflow_count - 7);
1474 ret = (int) call_func3(p_streambuf_xsgetn, &sb3, reserve, 16);
1475 ok(ret == 12, "wrong return value, expected 12 got %d\n", ret);
1476 ok(!strncmp(reserve, "HyperMegaNet", 12), "expected 'HyperMegaNet' got %s\n", reserve);
1477 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1478 ok(underflow_count == 30, "expected 12 calls to underflow, got %d\n", underflow_count - 18);
1479 ret = (int) call_func3(p_streambuf_xsgetn, &sb3, reserve, 3);
1480 ok(ret == 0, "wrong return value, expected 0 got %d\n", ret);
1481 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1482 ok(underflow_count == 31, "expected call to underflow\n");
1483 buffer_pos = 0;
1484 ret = (int) call_func3(p_streambuf_xsgetn, &sb3, reserve, 5);
1485 ok(ret == 5, "wrong return value, expected 5 got %d\n", ret);
1486 ok(!strncmp(reserve, "Compu", 5), "expected 'Compu' got %s\n", reserve);
1487 ok(sb3.stored_char == 'G', "wrong stored character, expected 'G' got %c\n", sb3.stored_char);
1488 ok(underflow_count == 37, "expected 6 calls to underflow, got %d\n", underflow_count - 31);
1490 /* xsputn */
1491 ret = (int) call_func3(p_streambuf_xsputn, &sb, "Test\0ing", 8);
1492 ok(ret == 8, "wrong return value, expected 8 got %d\n", ret);
1493 ok(sb.pptr == sb.pbase + 9, "wrong put pointer, expected %p got %p\n", sb.pbase + 9, sb.pptr);
1494 test_this = &sb2;
1495 sb2.pptr = sb2.epptr - 7;
1496 ret = (int) call_func3(p_streambuf_xsputn, &sb2, "Testing", 7);
1497 ok(ret == 7, "wrong return value, expected 7 got %d\n", ret);
1498 ok(sb2.pptr == sb2.epptr, "wrong put pointer, expected %p got %p\n", sb2.epptr, sb2.pptr);
1499 ok(overflow_count == 2, "no call to overflow expected\n");
1500 sb2.pptr = sb2.epptr - 5;
1501 sb2.pbase[5] = 'a';
1502 ret = (int) call_func3(p_streambuf_xsputn, &sb2, "Testing", 7);
1503 ok(ret == 7, "wrong return value, expected 7 got %d\n", ret);
1504 ok(sb2.pbase[5] == 'g', "expected 'g' got %c\n", sb2.pbase[5]);
1505 ok(sb2.pptr == sb2.pbase + 6, "wrong put pointer, expected %p got %p\n", sb2.pbase + 6, sb2.pptr);
1506 ok(overflow_count == 3, "expected call to overflow\n");
1507 sb2.pptr = sb2.epptr - 4;
1508 ret = (int) call_func3(p_streambuf_xsputn, &sb2, "TestLing", 8);
1509 ok(ret == 4, "wrong return value, expected 4 got %d\n", ret);
1510 ok(sb2.pptr == sb2.epptr, "wrong put pointer, expected %p got %p\n", sb2.epptr, sb2.pptr);
1511 ok(overflow_count == 4, "expected call to overflow\n");
1512 test_this = &sb3;
1513 ret = (int) call_func3(p_streambuf_xsputn, &sb3, "Testing", 7);
1514 ok(ret == 7, "wrong return value, expected 7 got %d\n", ret);
1515 ok(sb3.stored_char == 'G', "wrong stored character, expected 'G' got %c\n", sb3.stored_char);
1516 ok(overflow_count == 11, "expected 7 calls to overflow, got %d\n", overflow_count - 4);
1517 ret = (int) call_func3(p_streambuf_xsputn, &sb3, "TeLephone", 9);
1518 ok(ret == 2, "wrong return value, expected 2 got %d\n", ret);
1519 ok(sb3.stored_char == 'G', "wrong stored character, expected 'G' got %c\n", sb3.stored_char);
1520 ok(overflow_count == 14, "expected 3 calls to overflow, got %d\n", overflow_count - 11);
1522 /* snextc */
1523 strcpy(sb.eback, "Test");
1524 ret = (int) call_func1(p_streambuf_snextc, &sb);
1525 ok(ret == 'e', "expected 'e' got '%c'\n", ret);
1526 ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
1527 *sb.gptr-- = -50;
1528 ret = (int) call_func1(p_streambuf_snextc, &sb);
1529 ok(ret == 206, "expected 206 got %d\n", ret);
1530 ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
1531 test_this = &sb2;
1532 ret = (int) call_func1(p_streambuf_snextc, &sb2);
1533 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1534 ok(sb2.gptr == sb2.egptr + 1, "wrong get pointer, expected %p got %p\n", sb2.egptr + 1, sb2.gptr);
1535 ok(underflow_count == 39, "expected 2 calls to underflow, got %d\n", underflow_count - 37);
1536 sb2.gptr = sb2.egptr - 1;
1537 ret = (int) call_func1(p_streambuf_snextc, &sb2);
1538 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1539 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1540 ok(underflow_count == 40, "expected call to underflow\n");
1541 get_end = 0;
1542 ret = (int) call_func1(p_streambuf_snextc, &sb2);
1543 ok(ret == 'o', "expected 'o' got '%c'\n", ret);
1544 ok(sb2.gptr == sb2.eback + 1, "wrong get pointer, expected %p got %p\n", sb2.eback + 1, sb2.gptr);
1545 ok(underflow_count == 41, "expected call to underflow\n");
1546 sb2.gptr = sb2.egptr - 1;
1547 ret = (int) call_func1(p_streambuf_snextc, &sb2);
1548 ok(ret == 'W', "expected 'W' got '%c'\n", ret);
1549 ok(sb2.gptr == sb2.eback, "wrong get pointer, expected %p got %p\n", sb2.eback, sb2.gptr);
1550 ok(underflow_count == 42, "expected call to underflow\n");
1551 sb2.gptr = sb2.egptr;
1552 test_this = &sb3;
1553 ret = (int) call_func1(p_streambuf_snextc, &sb3);
1554 ok(ret == 'l', "expected 'l' got '%c'\n", ret);
1555 ok(sb3.stored_char == 'l', "wrong stored character, expected 'l' got %c\n", sb3.stored_char);
1556 ok(underflow_count == 43, "expected call to underflow\n");
1557 buffer_pos = 22;
1558 ret = (int) call_func1(p_streambuf_snextc, &sb3);
1559 ok(ret == 't', "expected 't' got '%c'\n", ret);
1560 ok(sb3.stored_char == 't', "wrong stored character, expected 't' got %c\n", sb3.stored_char);
1561 ok(underflow_count == 44, "expected call to underflow\n");
1562 ret = (int) call_func1(p_streambuf_snextc, &sb3);
1563 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1564 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1565 ok(underflow_count == 45, "expected call to underflow\n");
1566 buffer_pos = 0;
1567 ret = (int) call_func1(p_streambuf_snextc, &sb3);
1568 ok(ret == 'o', "expected 'o' got '%c'\n", ret);
1569 ok(sb3.stored_char == 'o', "wrong stored character, expected 'o' got %c\n", sb3.stored_char);
1570 ok(underflow_count == 47, "expected 2 calls to underflow, got %d\n", underflow_count - 45);
1571 sb3.stored_char = EOF;
1572 ret = (int) call_func1(p_streambuf_snextc, &sb3);
1573 ok(ret == 'p', "expected 'p' got '%c'\n", ret);
1574 ok(sb3.stored_char == 'p', "wrong stored character, expected 'p' got %c\n", sb3.stored_char);
1575 ok(underflow_count == 49, "expected 2 calls to underflow, got %d\n", underflow_count - 47);
1577 /* sbumpc */
1578 sb.gptr = sb.eback;
1579 ret = (int) call_func1(p_streambuf_sbumpc, &sb);
1580 ok(ret == 'T', "expected 'T' got '%c'\n", ret);
1581 ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
1582 ret = (int) call_func1(p_streambuf_sbumpc, &sb);
1583 ok(ret == 206, "expected 206 got %d\n", ret);
1584 ok(sb.gptr == sb.eback + 2, "wrong get pointer, expected %p got %p\n", sb.eback + 2, sb.gptr);
1585 test_this = &sb2;
1586 ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
1587 ok(ret == 'W', "expected 'W' got '%c'\n", ret);
1588 ok(sb2.gptr == sb2.eback + 1, "wrong get pointer, expected %p got %p\n", sb2.eback + 1, sb2.gptr);
1589 ok(underflow_count == 50, "expected call to underflow\n");
1590 sb2.gptr = sb2.egptr - 1;
1591 *sb2.gptr = 't';
1592 ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
1593 ok(ret == 't', "expected 't' got '%c'\n", ret);
1594 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1595 ok(underflow_count == 50, "no call to underflow expected\n");
1596 get_end = 1;
1597 ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
1598 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1599 ok(sb2.gptr == sb2.egptr + 1, "wrong get pointer, expected %p got %p\n", sb2.egptr + 1, sb2.gptr);
1600 ok(underflow_count == 51, "expected call to underflow\n");
1601 sb2.gptr = sb2.egptr;
1602 test_this = &sb3;
1603 ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
1604 ok(ret == 'p', "expected 'p' got '%c'\n", ret);
1605 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1606 ok(underflow_count == 51, "no call to underflow expected\n");
1607 ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
1608 ok(ret == 'u', "expected 'u' got '%c'\n", ret);
1609 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1610 ok(underflow_count == 52, "expected call to underflow\n");
1611 buffer_pos = 23;
1612 ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
1613 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1614 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1615 ok(underflow_count == 53, "expected call to underflow\n");
1616 buffer_pos = 0;
1617 ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
1618 ok(ret == 'C', "expected 'C' got '%c'\n", ret);
1619 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1620 ok(underflow_count == 54, "expected call to underflow\n");
1622 /* stossc */
1623 call_func1(p_streambuf_stossc, &sb);
1624 ok(sb.gptr == sb.eback + 3, "wrong get pointer, expected %p got %p\n", sb.eback + 3, sb.gptr);
1625 test_this = &sb2;
1626 call_func1(p_streambuf_stossc, &sb2);
1627 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1628 ok(underflow_count == 55, "expected call to underflow\n");
1629 get_end = 0;
1630 call_func1(p_streambuf_stossc, &sb2);
1631 ok(sb2.gptr == sb2.eback + 1, "wrong get pointer, expected %p got %p\n", sb2.eback + 1, sb2.gptr);
1632 ok(underflow_count == 56, "expected call to underflow\n");
1633 sb2.gptr = sb2.egptr - 1;
1634 call_func1(p_streambuf_stossc, &sb2);
1635 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1636 ok(underflow_count == 56, "no call to underflow expected\n");
1637 test_this = &sb3;
1638 call_func1(p_streambuf_stossc, &sb3);
1639 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1640 ok(underflow_count == 57, "expected call to underflow\n");
1641 sb3.stored_char = 'a';
1642 call_func1(p_streambuf_stossc, &sb3);
1643 ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
1644 ok(underflow_count == 57, "no call to underflow expected\n");
1646 /* pbackfail */
1647 ret = (int) call_func2(p_streambuf_pbackfail, &sb, 'A');
1648 ok(ret == 'A', "expected 'A' got '%c'\n", ret);
1649 ok(sb.gptr == sb.eback + 2, "wrong get pointer, expected %p got %p\n", sb.eback + 2, sb.gptr);
1650 ok(*sb.gptr == 'A', "expected 'A' in the get area, got %c\n", *sb.gptr);
1651 ret = (int) call_func2(p_streambuf_pbackfail, &sb, EOF);
1652 ok(ret == (char)EOF, "expected EOF got %d\n", ret);
1653 ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
1654 ok((signed char)*sb.gptr == EOF, "expected EOF in the get area, got %c\n", *sb.gptr);
1655 sb.gptr = sb.eback;
1656 ret = (int) call_func2(p_streambuf_pbackfail, &sb, 'Z');
1657 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1658 ok(sb.gptr == sb.eback, "wrong get pointer, expected %p got %p\n", sb.eback, sb.gptr);
1659 ok(*sb.gptr == 'T', "expected 'T' in the get area, got %c\n", *sb.gptr);
1660 ret = (int) call_func2(p_streambuf_pbackfail, &sb, EOF);
1661 ok(ret == EOF, "expected EOF got '%c'\n", ret);
1662 ok(sb.gptr == sb.eback, "wrong get pointer, expected %p got %p\n", sb.eback, sb.gptr);
1663 ok(*sb.gptr == 'T', "expected 'T' in the get area, got %c\n", *sb.gptr);
1664 sb2.gptr = sb2.egptr + 1;
1665 ret = (int) call_func2(p_streambuf_pbackfail, &sb2, 'X');
1666 ok(ret == 'X', "expected 'X' got '%c'\n", ret);
1667 ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
1668 ok(*sb2.gptr == 'X', "expected 'X' in the get area, got %c\n", *sb2.gptr);
1670 /* out_waiting */
1671 ret = (int) call_func1(p_streambuf_out_waiting, &sb);
1672 ok(ret == 9, "expected 9 got %d\n", ret);
1673 sb.pptr = sb.pbase;
1674 ret = (int) call_func1(p_streambuf_out_waiting, &sb);
1675 ok(ret == 0, "expected 0 got %d\n", ret);
1676 sb.pptr = sb.pbase - 1;
1677 ret = (int) call_func1(p_streambuf_out_waiting, &sb);
1678 ok(ret == 0, "expected 0 got %d\n", ret);
1679 sb.pptr = NULL;
1680 ret = (int) call_func1(p_streambuf_out_waiting, &sb);
1681 ok(ret == 0, "expected 0 got %d\n", ret);
1682 sb.pptr = sb.epptr;
1683 sb.pbase = NULL;
1684 ret = (int) call_func1(p_streambuf_out_waiting, &sb);
1685 ok(ret == (int)(sb.pptr - sb.pbase), "expected %d got %d\n", (int)(sb.pptr - sb.pbase), ret);
1687 /* in_avail */
1688 ret = (int) call_func1(p_streambuf_in_avail, &sb);
1689 ok(ret == 256, "expected 256 got %d\n", ret);
1690 sb.gptr = sb.egptr;
1691 ret = (int) call_func1(p_streambuf_in_avail, &sb);
1692 ok(ret == 0, "expected 0 got %d\n", ret);
1693 sb.gptr = sb.egptr + 1;
1694 ret = (int) call_func1(p_streambuf_in_avail, &sb);
1695 ok(ret == 0, "expected 0 got %d\n", ret);
1696 sb.egptr = NULL;
1697 ret = (int) call_func1(p_streambuf_in_avail, &sb);
1698 ok(ret == 0, "expected 0 got %d\n", ret);
1700 SetEvent(lock_arg.test[3]);
1701 WaitForSingleObject(thread, INFINITE);
1703 call_func1(p_streambuf_dtor, &sb);
1704 call_func1(p_streambuf_dtor, &sb2);
1705 call_func1(p_streambuf_dtor, &sb3);
1706 for (i = 0; i < 4; i++) {
1707 CloseHandle(lock_arg.lock[i]);
1708 CloseHandle(lock_arg.test[i]);
1710 CloseHandle(thread);
1713 struct filebuf_lock_arg
1715 filebuf *fb1, *fb2, *fb3;
1716 HANDLE lock;
1717 HANDLE test;
1720 static DWORD WINAPI lock_filebuf(void *arg)
1722 struct filebuf_lock_arg *lock_arg = arg;
1723 call_func1(p_streambuf_lock, &lock_arg->fb1->base);
1724 call_func1(p_streambuf_lock, &lock_arg->fb2->base);
1725 call_func1(p_streambuf_lock, &lock_arg->fb3->base);
1726 SetEvent(lock_arg->lock);
1727 WaitForSingleObject(lock_arg->test, INFINITE);
1728 call_func1(p_streambuf_unlock, &lock_arg->fb1->base);
1729 call_func1(p_streambuf_unlock, &lock_arg->fb2->base);
1730 call_func1(p_streambuf_unlock, &lock_arg->fb3->base);
1731 return 0;
1734 static void test_filebuf(void)
1736 filebuf fb1, fb2, fb3, *pret;
1737 struct filebuf_lock_arg lock_arg;
1738 HANDLE thread;
1739 const char filename1[] = "test1";
1740 const char filename2[] = "test2";
1741 const char filename3[] = "test3";
1742 char read_buffer[16];
1743 int ret;
1745 memset(&fb1, 0xab, sizeof(filebuf));
1746 memset(&fb2, 0xab, sizeof(filebuf));
1747 memset(&fb3, 0xab, sizeof(filebuf));
1749 /* constructors */
1750 call_func2(p_filebuf_fd_ctor, &fb1, 1);
1751 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1752 ok(fb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fb1.base.unbuffered);
1753 ok(fb1.fd == 1, "wrong fd, expected 1 got %d\n", fb1.fd);
1754 ok(fb1.close == 0, "wrong value, expected 0 got %d\n", fb1.close);
1755 call_func4(p_filebuf_fd_reserve_ctor, &fb2, 4, NULL, 0);
1756 ok(fb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb2.base.allocated);
1757 ok(fb2.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb2.base.unbuffered);
1758 ok(fb2.fd == 4, "wrong fd, expected 4 got %d\n", fb2.fd);
1759 ok(fb2.close == 0, "wrong value, expected 0 got %d\n", fb2.close);
1760 call_func1(p_filebuf_ctor, &fb3);
1761 ok(fb3.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb3.base.allocated);
1762 ok(fb3.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fb3.base.unbuffered);
1763 ok(fb3.fd == -1, "wrong fd, expected -1 got %d\n", fb3.fd);
1764 ok(fb3.close == 0, "wrong value, expected 0 got %d\n", fb3.close);
1766 lock_arg.fb1 = &fb1;
1767 lock_arg.fb2 = &fb2;
1768 lock_arg.fb3 = &fb3;
1769 lock_arg.lock = CreateEventW(NULL, FALSE, FALSE, NULL);
1770 ok(lock_arg.lock != NULL, "CreateEventW failed\n");
1771 lock_arg.test = CreateEventW(NULL, FALSE, FALSE, NULL);
1772 ok(lock_arg.test != NULL, "CreateEventW failed\n");
1773 thread = CreateThread(NULL, 0, lock_filebuf, (void*)&lock_arg, 0, NULL);
1774 ok(thread != NULL, "CreateThread failed\n");
1775 WaitForSingleObject(lock_arg.lock, INFINITE);
1777 /* setbuf */
1778 fb1.base.do_lock = 0;
1779 fb1.fd = -1; /* closed */
1780 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1781 ok(fb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fb1.base.unbuffered);
1782 ok(fb1.fd == -1, "wrong fd, expected -1 got %d\n", fb1.fd);
1783 fb1.base.unbuffered = 1;
1784 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer, 16);
1785 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1786 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1787 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1788 ok(fb1.base.base == read_buffer, "wrong buffer, expected %p got %p\n", read_buffer, fb1.base.base);
1789 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1790 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1791 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer + 8, 8);
1792 ok(pret == &fb1, "wrong return, expected %p got %p\n", NULL, pret);
1793 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1794 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1795 ok(fb1.base.base == read_buffer + 8, "wrong buffer, expected %p got %p\n", read_buffer + 8, fb1.base.base);
1796 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1797 fb1.base.unbuffered = 0;
1798 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, NULL, 0);
1799 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1800 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1801 ok(fb1.base.base == read_buffer + 8, "wrong buffer, expected %p got %p\n", read_buffer + 8, fb1.base.base);
1802 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1803 ok((int) call_func1(p_streambuf_doallocate, &fb1.base) == 1, "failed to allocate buffer\n");
1804 ok(fb1.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", fb1.base.allocated);
1805 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1806 ok(fb1.base.base != NULL, "wrong buffer, expected not NULL got %p\n", fb1.base.base);
1807 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer + 2, 14);
1808 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1809 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1810 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1811 ok(fb1.base.base == read_buffer + 2, "wrong buffer, expected %p got %p\n", read_buffer + 2, fb1.base.base);
1812 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1813 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1814 fb1.fd = 1; /* opened */
1815 fb1.base.unbuffered = 1;
1816 fb1.base.base = fb1.base.ebuf = NULL;
1817 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer, 16);
1818 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1819 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1820 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1821 ok(fb1.base.base == read_buffer, "wrong buffer, expected %p got %p\n", read_buffer, fb1.base.base);
1822 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1823 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer + 8, 8);
1824 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1825 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1826 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1827 ok(fb1.base.base == read_buffer, "wrong buffer, expected %p got %p\n", read_buffer, fb1.base.base);
1828 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1829 fb1.base.unbuffered = 0;
1830 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, NULL, 0);
1831 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1832 ok(fb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fb1.base.unbuffered);
1833 ok(fb1.base.base == read_buffer, "wrong buffer, expected %p got %p\n", read_buffer, fb1.base.base);
1834 ok(fb1.base.pbase == NULL, "wrong put area, expected %p got %p\n", NULL, fb1.base.pbase);
1835 fb1.base.unbuffered = 1;
1836 fb1.base.pbase = fb1.base.pptr = fb1.base.base;
1837 fb1.base.epptr = fb1.base.ebuf;
1838 fb1.base.do_lock = -1;
1839 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer, 16);
1840 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1841 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1842 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1843 ok(fb1.base.base == read_buffer, "wrong buffer, expected %p got %p\n", read_buffer, fb1.base.base);
1844 ok(fb1.base.pbase == read_buffer, "wrong put area, expected %p got %p\n", read_buffer, fb1.base.pbase);
1845 fb1.base.base = fb1.base.ebuf = NULL;
1846 fb1.base.do_lock = 0;
1847 fb1.base.unbuffered = 0;
1848 pret = (filebuf*) call_func3(p_filebuf_setbuf, &fb1, read_buffer, 0);
1849 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1850 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1851 ok(fb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fb1.base.unbuffered);
1852 ok(fb1.base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, fb1.base.base);
1853 ok(fb1.base.pbase == read_buffer, "wrong put area, expected %p got %p\n", read_buffer, fb1.base.pbase);
1854 fb1.base.pbase = fb1.base.pptr = fb1.base.epptr = NULL;
1855 fb1.base.unbuffered = 0;
1856 fb1.base.do_lock = -1;
1858 /* attach */
1859 pret = call_func2(p_filebuf_attach, &fb1, 2);
1860 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1861 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1862 ok(fb1.fd == 1, "wrong fd, expected 1 got %d\n", fb1.fd);
1863 fb2.fd = -1;
1864 fb2.base.do_lock = 0;
1865 pret = call_func2(p_filebuf_attach, &fb2, 3);
1866 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
1867 ok(fb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb2.base.allocated);
1868 ok(fb2.fd == 3, "wrong fd, expected 3 got %d\n", fb2.fd);
1869 fb2.base.do_lock = -1;
1870 fb3.base.do_lock = 0;
1871 pret = call_func2(p_filebuf_attach, &fb3, 2);
1872 ok(pret == &fb3, "wrong return, expected %p got %p\n", &fb3, pret);
1873 ok(fb3.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", fb3.base.allocated);
1874 ok(fb3.fd == 2, "wrong fd, expected 2 got %d\n", fb3.fd);
1875 fb3.base.do_lock = -1;
1877 /* open modes */
1878 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out, filebuf_openprot);
1879 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1880 fb1.fd = -1;
1881 pret = call_func4(p_filebuf_open, &fb1, filename1,
1882 OPENMODE_ate|OPENMODE_nocreate|OPENMODE_noreplace|OPENMODE_binary, filebuf_openprot);
1883 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1884 ok(fb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", fb1.base.allocated);
1885 fb1.base.do_lock = 0;
1886 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out, filebuf_openprot);
1887 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1888 ok(fb1.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", fb1.base.allocated);
1889 ok(_write(fb1.fd, "testing", 7) == 7, "_write failed\n");
1890 pret = call_func1(p_filebuf_close, &fb1);
1891 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1892 ok(fb1.fd == -1, "wrong fd, expected -1 got %d\n", fb1.fd);
1893 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out, filebuf_openprot);
1894 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1895 ok(_read(fb1.fd, read_buffer, 1) == -1, "file should not be open for reading\n");
1896 pret = call_func1(p_filebuf_close, &fb1);
1897 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1898 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_app, filebuf_openprot);
1899 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1900 ok(_read(fb1.fd, read_buffer, 1) == -1, "file should not be open for reading\n");
1901 ok(_write(fb1.fd, "testing", 7) == 7, "_write failed\n");
1902 ok(_lseek(fb1.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
1903 ok(_write(fb1.fd, "append", 6) == 6, "_write failed\n");
1904 pret = call_func1(p_filebuf_close, &fb1);
1905 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1906 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out|OPENMODE_ate, filebuf_openprot);
1907 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1908 ok(_read(fb1.fd, read_buffer, 1) == -1, "file should not be open for reading\n");
1909 ok(_lseek(fb1.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
1910 ok(_write(fb1.fd, "ate", 3) == 3, "_write failed\n");
1911 pret = call_func1(p_filebuf_close, &fb1);
1912 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1913 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_in, filebuf_openprot);
1914 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1915 ok(_read(fb1.fd, read_buffer, 13) == 13, "read failed\n");
1916 read_buffer[13] = 0;
1917 ok(!strncmp(read_buffer, "atetingappend", 13), "wrong contents, expected 'atetingappend' got '%s'\n", read_buffer);
1918 pret = call_func1(p_filebuf_close, &fb1);
1919 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1920 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_in|OPENMODE_trunc, filebuf_openprot);
1921 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1922 ok(_read(fb1.fd, read_buffer, 1) == 0, "read failed\n");
1923 ok(_write(fb1.fd, "file1", 5) == 5, "_write failed\n");
1924 pret = call_func1(p_filebuf_close, &fb1);
1925 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1926 pret = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_in|OPENMODE_app, filebuf_openprot);
1927 ok(pret == &fb1, "wrong return, expected %p got %p\n", &fb1, pret);
1928 ok(_write(fb1.fd, "app", 3) == 3, "_write failed\n");
1929 ok(_read(fb1.fd, read_buffer, 1) == 0, "read failed\n");
1930 ok(_lseek(fb1.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
1931 ok(_read(fb1.fd, read_buffer, 8) == 8, "read failed\n");
1932 read_buffer[8] = 0;
1933 ok(!strncmp(read_buffer, "file1app", 8), "wrong contents, expected 'file1app' got '%s'\n", read_buffer);
1934 fb1.base.do_lock = -1;
1936 fb2.fd = -1;
1937 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_out|OPENMODE_nocreate, filebuf_openprot);
1938 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1939 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in|OPENMODE_nocreate, filebuf_openprot);
1940 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1941 fb2.base.do_lock = 0;
1942 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in, filebuf_openprot);
1943 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
1944 ok(_read(fb1.fd, read_buffer, 1) == 0, "read failed\n");
1945 pret = call_func1(p_filebuf_close, &fb2);
1946 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
1947 fb2.base.do_lock = -1;
1948 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in|OPENMODE_noreplace, filebuf_openprot);
1949 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1950 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_trunc|OPENMODE_noreplace, filebuf_openprot);
1951 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1952 pret = call_func4(p_filebuf_open, &fb2, filename3, OPENMODE_out|OPENMODE_nocreate|OPENMODE_noreplace, filebuf_openprot);
1953 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1955 /* open protection*/
1956 fb3.fd = -1;
1957 fb3.base.do_lock = 0;
1958 pret = call_func4(p_filebuf_open, &fb3, filename3, OPENMODE_in|OPENMODE_out, filebuf_openprot);
1959 ok(pret == &fb3, "wrong return, expected %p got %p\n", &fb3, pret);
1960 ok(_write(fb3.fd, "You wouldn't\nget this from\nany other guy", 40) == 40, "_write failed\n");
1961 fb2.base.do_lock = 0;
1962 pret = call_func4(p_filebuf_open, &fb2, filename3, OPENMODE_in|OPENMODE_out, filebuf_openprot);
1963 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
1964 pret = call_func1(p_filebuf_close, &fb2);
1965 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
1966 fb2.base.do_lock = -1;
1967 pret = call_func1(p_filebuf_close, &fb3);
1968 ok(pret == &fb3, "wrong return, expected %p got %p\n", &fb3, pret);
1969 pret = call_func4(p_filebuf_open, &fb3, filename3, OPENMODE_in, filebuf_sh_none);
1970 ok(pret == &fb3, "wrong return, expected %p got %p\n", &fb3, pret);
1971 pret = call_func4(p_filebuf_open, &fb2, filename3, OPENMODE_in, filebuf_openprot);
1972 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
1973 fb3.base.do_lock = -1;
1975 /* setmode */
1976 fb1.base.do_lock = 0;
1977 fb1.base.pbase = fb1.base.pptr = fb1.base.base;
1978 fb1.base.epptr = fb1.base.ebuf;
1979 ret = (int) call_func2(p_filebuf_setmode, &fb1, filebuf_binary);
1980 ok(ret == filebuf_text, "wrong return, expected %d got %d\n", filebuf_text, ret);
1981 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
1982 ret = (int) call_func2(p_filebuf_setmode, &fb1, filebuf_binary);
1983 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
1984 fb1.base.do_lock = -1;
1985 ret = (int) call_func2(p_filebuf_setmode, &fb1, 0x9000);
1986 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
1987 fb2.base.do_lock = 0;
1988 ret = (int) call_func2(p_filebuf_setmode, &fb2, filebuf_text);
1989 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
1990 fb2.base.do_lock = -1;
1992 /* sync */
1993 ret = (int) call_func1(p_filebuf_sync, &fb1);
1994 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
1995 fb1.base.eback = fb1.base.gptr = fb1.base.base;
1996 fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
1997 fb1.base.epptr = fb1.base.ebuf;
1998 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "We're no strangers to love\n", 27);
1999 ok(ret == 27, "wrong return, expected 27 got %d\n", ret);
2000 ret = (int) call_func1(p_filebuf_sync, &fb1);
2001 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
2002 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2003 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2004 fb1.base.eback = fb1.base.gptr = fb1.base.egptr = NULL;
2005 fb1.base.pbase = fb1.base.pptr = fb1.base.base;
2006 fb1.base.epptr = fb1.base.ebuf;
2007 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "You know the rules and so do I\n", 31);
2008 ok(ret == 31, "wrong return, expected 31 got %d\n", ret);
2009 ret = (int) call_func1(p_filebuf_sync, &fb1);
2010 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2011 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2012 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2013 fb1.base.eback = fb1.base.base;
2014 fb1.base.gptr = fb1.base.base + 190;
2015 fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
2016 fb1.base.epptr = fb1.base.ebuf;
2017 ret = (int) call_func1(p_filebuf_sync, &fb1);
2018 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2019 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2020 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2021 ok(_tell(fb1.fd) == 0, "_tell failed\n");
2022 fb1.base.pbase = fb1.base.pptr = fb1.base.base;
2023 ret = (int) call_func1(p_filebuf_sync, &fb1);
2024 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2025 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
2026 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2027 fb1.base.epptr = fb1.base.ebuf;
2028 ret = (int) call_func1(p_filebuf_sync, &fb1);
2029 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2030 ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
2031 fb1.base.pbase = fb1.base.base;
2032 ret = (int) call_func1(p_filebuf_sync, &fb1);
2033 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2034 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
2035 fb1.base.pbase = fb1.base.base;
2036 fb1.base.epptr = fb1.base.ebuf;
2037 ret = (int) call_func1(p_filebuf_sync, &fb1);
2038 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2039 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
2040 ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
2041 fb1.base.eback = fb1.base.base;
2042 ret = (int) call_func1(p_filebuf_sync, &fb1);
2043 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2044 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
2045 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2046 ret = (int) call_func1(p_filebuf_sync, &fb1);
2047 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2048 ok(fb1.base.gptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.gptr);
2049 fb1.base.gptr = fb1.base.base;
2050 fb1.base.egptr = fb1.base.base + 100;
2051 fb1.base.pbase = fb1.base.base;
2052 ret = (int) call_func1(p_filebuf_sync, &fb1);
2053 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
2054 ok(fb1.base.gptr == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2055 ok(fb1.base.egptr == fb1.base.base + 100, "wrong get base, expected %p got %p\n", fb1.base.base + 100, fb1.base.egptr);
2056 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
2057 fb1.base.egptr = NULL;
2058 ret = (int) call_func1(p_filebuf_sync, &fb1);
2059 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2060 ok(fb1.base.gptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.gptr);
2061 ok(fb1.base.egptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.egptr);
2062 ret = (int) call_func1(p_filebuf_sync, &fb2);
2063 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
2064 fb3.base.eback = fb3.base.base;
2065 fb3.base.gptr = fb3.base.egptr = fb3.base.pbase = fb3.base.pptr = fb3.base.base + 256;
2066 fb3.base.epptr = fb3.base.ebuf;
2067 ret = (int) call_func3(p_streambuf_xsputn, &fb3.base, "A full commitment's what I'm thinking of\n", 41);
2068 ok(ret == 41, "wrong return, expected 41 got %d\n", ret);
2069 ret = (int) call_func1(p_filebuf_sync, &fb3);
2070 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
2071 ok(fb3.base.gptr == fb3.base.base + 256, "wrong get pointer, expected %p got %p\n", fb3.base.base + 256, fb3.base.gptr);
2072 ok(fb3.base.pptr == fb3.base.base + 297, "wrong put pointer, expected %p got %p\n", fb3.base.base + 297, fb3.base.pptr);
2073 fb3.base.eback = fb3.base.base;
2074 fb3.base.gptr = fb3.base.egptr = fb3.base.pbase = fb3.base.pptr = fb3.base.base + 256;
2075 fb3.base.epptr = fb3.base.ebuf;
2076 ret = (int) call_func1(p_filebuf_sync, &fb3);
2077 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2078 ok(fb3.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb3.base.gptr);
2079 ok(fb3.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb3.base.pptr);
2080 fb3.base.eback = fb3.base.base;
2081 fb3.base.gptr = fb3.base.base + 216;
2082 fb3.base.egptr = fb3.base.pbase = fb3.base.pptr = fb3.base.base + 256;
2083 fb3.base.epptr = fb3.base.ebuf;
2084 ok(_read(fb3.fd, fb3.base.gptr, 42) == 40, "read failed\n");
2085 ret = (int) call_func1(p_filebuf_sync, &fb3);
2086 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
2087 ok(fb3.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb3.base.gptr);
2088 ok(fb3.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb3.base.pptr);
2089 ok(_tell(fb3.fd) == 0, "_tell failed\n");
2090 fb3.base.eback = fb3.base.gptr = fb3.base.egptr = NULL;
2091 fb3.base.pbase = fb3.base.pptr = fb3.base.epptr = NULL;
2093 /* overflow */
2094 ret = (int) call_func2(p_filebuf_overflow, &fb1, EOF);
2095 ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
2096 fb1.base.pbase = fb1.base.pptr = fb1.base.epptr = NULL;
2097 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2098 fb1.base.egptr = fb1.base.ebuf;
2099 ret = (int) call_func2(p_filebuf_overflow, &fb1, 'a');
2100 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2101 fb1.base.gptr = fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
2102 fb1.base.epptr = fb1.base.ebuf;
2103 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "I just want to tell you how I'm feeling", 39);
2104 ok(ret == 39, "wrong return, expected 39 got %d\n", ret);
2105 ret = (int) call_func2(p_filebuf_overflow, &fb1, '\n');
2106 ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
2107 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2108 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
2109 ok(fb1.base.pptr == fb1.base.base + 1, "wrong put pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.pptr);
2110 ok(fb1.base.epptr == fb1.base.ebuf, "wrong put end pointer, expected %p got %p\n", fb1.base.ebuf, fb1.base.epptr);
2111 ok(*fb1.base.pbase == '\n', "wrong character, expected '\\n' got '%c'\n", *fb1.base.pbase);
2112 ret = (int) call_func2(p_filebuf_overflow, &fb1, EOF);
2113 ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
2114 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2115 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
2116 ok(fb1.base.pptr == fb1.base.base, "wrong put pointer, expected %p got %p\n", fb1.base.base, fb1.base.pptr);
2117 ok(fb1.base.epptr == fb1.base.ebuf, "wrong put end pointer, expected %p got %p\n", fb1.base.ebuf, fb1.base.epptr);
2118 ret = (int) call_func2(p_filebuf_overflow, &fb2, EOF);
2119 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2120 fb2.base.do_lock = 0;
2121 pret = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in|OPENMODE_out, filebuf_openprot);
2122 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
2123 fb2.base.do_lock = -1;
2124 ret = (int) call_func2(p_filebuf_overflow, &fb2, EOF);
2125 ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
2127 /* underflow */
2128 ret = (int) call_func1(p_filebuf_underflow, &fb1);
2129 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2130 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2131 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2132 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2133 fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
2134 fb1.base.epptr = fb1.base.ebuf;
2135 *fb1.base.gptr = 'A';
2136 ret = (int) call_func1(p_filebuf_underflow, &fb1);
2137 ok(ret == 'A', "wrong return, expected 'A' got %d\n", ret);
2138 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2139 ok(fb1.base.pptr == fb1.base.base + 256, "wrong put pointer, expected %p got %p\n", fb1.base.base + 256, fb1.base.pptr);
2140 *fb1.base.gptr = -50;
2141 ret = (int) call_func1(p_filebuf_underflow, &fb1);
2142 ok(ret == 206, "wrong return, expected 206 got %d\n", ret);
2143 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2144 ok(fb1.base.pptr == fb1.base.base + 256, "wrong put pointer, expected %p got %p\n", fb1.base.base + 256, fb1.base.pptr);
2145 fb1.base.gptr = fb1.base.ebuf;
2146 ret = (int) call_func1(p_filebuf_underflow, &fb1);
2147 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2148 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2149 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2150 ok(_lseek(fb1.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
2151 ret = (int) call_func1(p_filebuf_underflow, &fb1);
2152 ok(ret == 'f', "wrong return, expected 'f' got %d\n", ret);
2153 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
2154 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2155 ok(fb1.base.egptr == fb1.base.base + 106, "wrong get end pointer, expected %p got %p\n", fb1.base.base + 106, fb1.base.egptr);
2156 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2157 ret = (int) call_func1(p_filebuf_underflow, &fb2);
2158 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2159 ok(_write(fb2.fd, "A\n", 2) == 2, "_write failed\n");
2160 ok(_lseek(fb2.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
2161 ret = (int) call_func1(p_filebuf_underflow, &fb2);
2162 ok(ret == 'A', "wrong return, expected 'A' got %d\n", ret);
2163 ret = (int) call_func1(p_filebuf_underflow, &fb2);
2164 ok(ret == '\n', "wrong return, expected '\\n' got %d\n", ret);
2165 ok(_lseek(fb2.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
2166 ok(_write(fb2.fd, "\xCE\n", 2) == 2, "_write failed\n");
2167 ok(_lseek(fb2.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
2168 ret = (int) call_func1(p_filebuf_underflow, &fb2);
2169 ok(ret == 206, "wrong return, expected 206 got %d\n", ret);
2170 fb2.base.do_lock = 0;
2171 pret = call_func1(p_filebuf_close, &fb2);
2172 ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
2173 fb2.base.do_lock = -1;
2174 ret = (int) call_func1(p_filebuf_underflow, &fb2);
2175 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2177 /* seekoff */
2178 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 5, SEEKDIR_beg, 0);
2179 ok(ret == 5, "wrong return, expected 5 got %d\n", ret);
2180 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2181 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2182 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2183 fb1.base.egptr = fb1.base.ebuf;
2184 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 0, SEEKDIR_beg, 0);
2185 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2186 fb1.base.eback = fb1.base.gptr = fb1.base.egptr = NULL;
2187 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 10, SEEKDIR_beg, OPENMODE_in|OPENMODE_out);
2188 ok(ret == 10, "wrong return, expected 10 got %d\n", ret);
2189 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 0, SEEKDIR_cur, 0);
2190 ok(ret == 10, "wrong return, expected 10 got %d\n", ret);
2191 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 200, SEEKDIR_cur, OPENMODE_in);
2192 ok(ret == 210, "wrong return, expected 210 got %d\n", ret);
2193 ret = (int) call_func4(p_filebuf_seekoff, &fb1, -60, SEEKDIR_cur, 0);
2194 ok(ret == 150, "wrong return, expected 150 got %d\n", ret);
2195 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 0, SEEKDIR_end, 0);
2196 ok(ret == 106, "wrong return, expected 106 got %d\n", ret);
2197 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 20, SEEKDIR_end, OPENMODE_out);
2198 ok(ret == 126, "wrong return, expected 126 got %d\n", ret);
2199 ret = (int) call_func4(p_filebuf_seekoff, &fb1, -150, SEEKDIR_end, -1);
2200 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2201 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 10, 3, 0);
2202 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2203 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 16, SEEKDIR_beg, 0);
2204 ok(ret == 16, "wrong return, expected 16 got %d\n", ret);
2206 /* pbackfail */
2207 ret = (int) call_func2(p_streambuf_pbackfail, &fb1.base, 'B');
2208 ok(ret == 'B', "wrong return, expected 'B' got %d\n", ret);
2209 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2210 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2211 ok(_tell(fb1.fd) == 15, "_tell failed\n");
2212 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2213 fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
2214 fb1.base.epptr = fb1.base.ebuf;
2215 ret = (int) call_func2(p_streambuf_pbackfail, &fb1.base, 'C');
2216 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2217 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2218 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2219 ok(_tell(fb1.fd) == 15, "_tell failed\n");
2220 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2221 fb1.base.egptr = fb1.base.base + 2;
2222 ret = (int) call_func2(p_streambuf_pbackfail, &fb1.base, 'C');
2223 ok(ret == 'C', "wrong return, expected 'C' got %d\n", ret);
2224 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
2225 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2226 ok(_tell(fb1.fd) == 12, "_tell failed\n");
2227 fb1.base.eback = fb1.base.gptr = fb1.base.base;
2228 fb1.base.egptr = fb1.base.ebuf;
2229 *fb1.base.gptr++ = 'D';
2230 ret = (int) call_func2(p_streambuf_pbackfail, &fb1.base, 'C');
2231 ok(ret == 'C', "wrong return, expected 'C' got %d\n", ret);
2232 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
2233 ok(*fb1.base.gptr == 'C', "wrong character, expected 'C' got '%c'\n", *fb1.base.gptr);
2234 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
2235 ok(_tell(fb1.fd) == 12, "_tell failed\n");
2236 fb1.base.eback = fb1.base.gptr = fb1.base.egptr = NULL;
2238 /* close */
2239 pret = call_func1(p_filebuf_close, &fb2);
2240 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
2241 fb3.base.do_lock = 0;
2242 pret = call_func1(p_filebuf_close, &fb3);
2243 ok(pret == &fb3, "wrong return, expected %p got %p\n", &fb3, pret);
2244 ok(fb3.fd == -1, "wrong fd, expected -1 got %d\n", fb3.fd);
2245 fb3.fd = 5;
2246 pret = call_func1(p_filebuf_close, &fb3);
2247 ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
2248 ok(fb3.fd == 5, "wrong fd, expected 5 got %d\n", fb3.fd);
2249 fb3.base.do_lock = -1;
2251 SetEvent(lock_arg.test);
2252 WaitForSingleObject(thread, INFINITE);
2254 /* destructor */
2255 call_func1(p_filebuf_dtor, &fb1);
2256 ok(fb1.fd == -1, "wrong fd, expected -1 got %d\n", fb1.fd);
2257 call_func1(p_filebuf_dtor, &fb2);
2258 call_func1(p_filebuf_dtor, &fb3);
2260 ok(_unlink(filename1) == 0, "Couldn't unlink file named '%s'\n", filename1);
2261 ok(_unlink(filename2) == 0, "Couldn't unlink file named '%s'\n", filename2);
2262 ok(_unlink(filename3) == 0, "Couldn't unlink file named '%s'\n", filename3);
2263 CloseHandle(lock_arg.lock);
2264 CloseHandle(lock_arg.test);
2265 CloseHandle(thread);
2268 static void test_strstreambuf(void)
2270 strstreambuf ssb1, ssb2;
2271 streambuf *pret;
2272 char buffer[64], *pbuffer;
2273 int ret;
2275 memset(&ssb1, 0xab, sizeof(strstreambuf));
2276 memset(&ssb2, 0xab, sizeof(strstreambuf));
2278 /* constructors/destructor */
2279 call_func2(p_strstreambuf_dynamic_ctor, &ssb1, 64);
2280 ok(ssb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb1.base.allocated);
2281 ok(ssb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb1.base.unbuffered);
2282 ok(ssb1.dynamic == 1, "expected 1, got %d\n", ssb1.dynamic);
2283 ok(ssb1.increase == 64, "expected 64, got %d\n", ssb1.increase);
2284 ok(ssb1.constant == 0, "expected 0, got %d\n", ssb1.constant);
2285 ok(ssb1.f_alloc == NULL, "expected %p, got %p\n", NULL, ssb1.f_alloc);
2286 ok(ssb1.f_free == NULL, "expected %p, got %p\n", NULL, ssb1.f_free);
2287 call_func1(p_strstreambuf_dtor, &ssb1);
2288 call_func3(p_strstreambuf_funcs_ctor, &ssb2, (allocFunction)p_operator_new, p_operator_delete);
2289 ok(ssb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb2.base.allocated);
2290 ok(ssb2.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb2.base.unbuffered);
2291 ok(ssb2.dynamic == 1, "expected 1, got %d\n", ssb2.dynamic);
2292 ok(ssb2.increase == 1, "expected 1, got %d\n", ssb2.increase);
2293 ok(ssb2.constant == 0, "expected 0, got %d\n", ssb2.constant);
2294 ok(ssb2.f_alloc == (allocFunction)p_operator_new, "expected %p, got %p\n", p_operator_new, ssb2.f_alloc);
2295 ok(ssb2.f_free == p_operator_delete, "expected %p, got %p\n", p_operator_delete, ssb2.f_free);
2296 call_func1(p_strstreambuf_dtor, &ssb2);
2297 memset(&ssb1, 0xab, sizeof(strstreambuf));
2298 memset(&ssb2, 0xab, sizeof(strstreambuf));
2299 call_func4(p_strstreambuf_buffer_ctor, &ssb1, buffer, 64, buffer + 20);
2300 ok(ssb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb1.base.allocated);
2301 ok(ssb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb1.base.unbuffered);
2302 ok(ssb1.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb1.base.base);
2303 ok(ssb1.base.ebuf == buffer + 64, "wrong buffer end, expected %p got %p\n", buffer + 64, ssb1.base.ebuf);
2304 ok(ssb1.base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, ssb1.base.eback);
2305 ok(ssb1.base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, ssb1.base.gptr);
2306 ok(ssb1.base.egptr == buffer + 20, "wrong get end, expected %p got %p\n", buffer + 20, ssb1.base.egptr);
2307 ok(ssb1.base.pbase == buffer + 20, "wrong put base, expected %p got %p\n", buffer + 20, ssb1.base.pbase);
2308 ok(ssb1.base.pptr == buffer + 20, "wrong put pointer, expected %p got %p\n", buffer + 20, ssb1.base.pptr);
2309 ok(ssb1.base.epptr == buffer + 64, "wrong put end, expected %p got %p\n", buffer + 64, ssb1.base.epptr);
2310 ok(ssb1.dynamic == 0, "expected 0, got %d\n", ssb1.dynamic);
2311 ok(ssb1.constant == 1, "expected 1, got %d\n", ssb1.constant);
2312 call_func1(p_strstreambuf_dtor, &ssb1);
2313 strcpy(buffer, "Test");
2314 call_func4(p_strstreambuf_buffer_ctor, &ssb2, buffer, 0, buffer + 20);
2315 ok(ssb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb2.base.allocated);
2316 ok(ssb2.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb2.base.unbuffered);
2317 ok(ssb2.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb2.base.base);
2318 ok(ssb2.base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, ssb2.base.ebuf);
2319 ok(ssb2.base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, ssb2.base.eback);
2320 ok(ssb2.base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, ssb2.base.gptr);
2321 ok(ssb2.base.egptr == buffer + 20, "wrong get end, expected %p got %p\n", buffer + 20, ssb2.base.egptr);
2322 ok(ssb2.base.pbase == buffer + 20, "wrong put base, expected %p got %p\n", buffer + 20, ssb2.base.pbase);
2323 ok(ssb2.base.pptr == buffer + 20, "wrong put pointer, expected %p got %p\n", buffer + 20, ssb2.base.pptr);
2324 ok(ssb2.base.epptr == buffer + 4, "wrong put end, expected %p got %p\n", buffer + 4, ssb2.base.epptr);
2325 ok(ssb2.dynamic == 0, "expected 0, got %d\n", ssb2.dynamic);
2326 ok(ssb2.constant == 1, "expected 1, got %d\n", ssb2.constant);
2327 call_func1(p_strstreambuf_dtor, &ssb2);
2328 memset(&ssb1, 0xab, sizeof(strstreambuf));
2329 memset(&ssb2, 0xab, sizeof(strstreambuf));
2330 call_func4(p_strstreambuf_buffer_ctor, &ssb1, NULL, 16, buffer + 20);
2331 ok(ssb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb1.base.allocated);
2332 ok(ssb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb1.base.unbuffered);
2333 ok(ssb1.base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, ssb1.base.base);
2334 ok(ssb1.base.ebuf == (char*)16, "wrong buffer end, expected %p got %p\n", (char*)16, ssb1.base.ebuf);
2335 ok(ssb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, ssb1.base.eback);
2336 ok(ssb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, ssb1.base.gptr);
2337 ok(ssb1.base.egptr == buffer + 20, "wrong get end, expected %p got %p\n", buffer + 20, ssb1.base.egptr);
2338 ok(ssb1.base.pbase == buffer + 20, "wrong put base, expected %p got %p\n", buffer + 20, ssb1.base.pbase);
2339 ok(ssb1.base.pptr == buffer + 20, "wrong put pointer, expected %p got %p\n", buffer + 20, ssb1.base.pptr);
2340 ok(ssb1.base.epptr == (char*)16, "wrong put end, expected %p got %p\n", (char*)16, ssb1.base.epptr);
2341 ok(ssb1.dynamic == 0, "expected 0, got %d\n", ssb1.dynamic);
2342 ok(ssb1.constant == 1, "expected 1, got %d\n", ssb1.constant);
2343 call_func1(p_strstreambuf_dtor, &ssb1);
2344 call_func4(p_strstreambuf_buffer_ctor, &ssb2, buffer, 0, NULL);
2345 ok(ssb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb2.base.allocated);
2346 ok(ssb2.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb2.base.unbuffered);
2347 ok(ssb2.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb2.base.base);
2348 ok(ssb2.base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, ssb2.base.ebuf);
2349 ok(ssb2.base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, ssb2.base.eback);
2350 ok(ssb2.base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, ssb2.base.gptr);
2351 ok(ssb2.base.egptr == buffer + 4, "wrong get end, expected %p got %p\n", buffer + 4, ssb2.base.egptr);
2352 ok(ssb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, ssb2.base.pbase);
2353 ok(ssb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, ssb2.base.pptr);
2354 ok(ssb2.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, ssb2.base.epptr);
2355 ok(ssb2.dynamic == 0, "expected 0, got %d\n", ssb2.dynamic);
2356 ok(ssb2.constant == 1, "expected 1, got %d\n", ssb2.constant);
2357 call_func1(p_strstreambuf_dtor, &ssb2);
2358 memset(&ssb1, 0xab, sizeof(strstreambuf));
2359 memset(&ssb2, 0xab, sizeof(strstreambuf));
2360 call_func4(p_strstreambuf_buffer_ctor, &ssb1, buffer, -5, buffer + 20);
2361 ok(ssb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb1.base.allocated);
2362 ok(ssb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb1.base.unbuffered);
2363 ok(ssb1.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb1.base.base);
2364 ok(ssb1.base.ebuf == (char *)((ULONG_PTR)buffer + 0x7fffffff) || ssb1.base.ebuf == (char*)-1,
2365 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, ssb1.base.ebuf);
2366 ok(ssb1.base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, ssb1.base.eback);
2367 ok(ssb1.base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, ssb1.base.gptr);
2368 ok(ssb1.base.egptr == buffer + 20, "wrong get end, expected %p got %p\n", buffer + 20, ssb1.base.egptr);
2369 ok(ssb1.base.pbase == buffer + 20, "wrong put base, expected %p got %p\n", buffer + 20, ssb1.base.pbase);
2370 ok(ssb1.base.pptr == buffer + 20, "wrong put pointer, expected %p got %p\n", buffer + 20, ssb1.base.pptr);
2371 ok(ssb1.base.epptr == (char *)((ULONG_PTR)buffer + 0x7fffffff) || ssb1.base.epptr == (char*)-1,
2372 "wrong put end, expected %p + 0x7fffffff or -1, got %p\n", buffer, ssb1.base.epptr);
2373 ok(ssb1.dynamic == 0, "expected 0, got %d\n", ssb1.dynamic);
2374 ok(ssb1.constant == 1, "expected 1, got %d\n", ssb1.constant);
2375 call_func1(p_strstreambuf_ctor, &ssb2);
2376 ok(ssb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", ssb2.base.allocated);
2377 ok(ssb2.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ssb2.base.unbuffered);
2378 ok(ssb2.dynamic == 1, "expected 1, got %d\n", ssb2.dynamic);
2379 ok(ssb2.increase == 1, "expected 1, got %d\n", ssb2.increase);
2380 ok(ssb2.constant == 0, "expected 0, got %d\n", ssb2.constant);
2381 ok(ssb2.f_alloc == NULL, "expected %p, got %p\n", NULL, ssb2.f_alloc);
2382 ok(ssb2.f_free == NULL, "expected %p, got %p\n", NULL, ssb2.f_free);
2384 /* freeze */
2385 call_func2(p_strstreambuf_freeze, &ssb1, 0);
2386 ok(ssb1.dynamic == 0, "expected 0, got %d\n", ssb1.dynamic);
2387 ssb1.constant = 0;
2388 call_func2(p_strstreambuf_freeze, &ssb1, 0);
2389 ok(ssb1.dynamic == 1, "expected 1, got %d\n", ssb1.dynamic);
2390 call_func2(p_strstreambuf_freeze, &ssb1, 3);
2391 ok(ssb1.dynamic == 0, "expected 0, got %d\n", ssb1.dynamic);
2392 ssb1.constant = 1;
2393 call_func2(p_strstreambuf_freeze, &ssb2, 5);
2394 ok(ssb2.dynamic == 0, "expected 0, got %d\n", ssb2.dynamic);
2395 call_func2(p_strstreambuf_freeze, &ssb2, 0);
2396 ok(ssb2.dynamic == 1, "expected 1, got %d\n", ssb2.dynamic);
2398 /* doallocate */
2399 ssb2.dynamic = 0;
2400 ssb2.increase = 5;
2401 ret = (int) call_func1(p_strstreambuf_doallocate, &ssb2);
2402 ok(ret == 1, "return value %d\n", ret);
2403 ok(ssb2.base.ebuf == ssb2.base.base + 5, "expected %p, got %p\n", ssb2.base.base + 5, ssb2.base.ebuf);
2404 ssb2.base.eback = ssb2.base.base;
2405 ssb2.base.gptr = ssb2.base.base + 2;
2406 ssb2.base.egptr = ssb2.base.base + 4;
2407 strcpy(ssb2.base.base, "Check");
2408 ret = (int) call_func1(p_strstreambuf_doallocate, &ssb2);
2409 ok(ret == 1, "return value %d\n", ret);
2410 ok(ssb2.base.ebuf == ssb2.base.base + 10, "expected %p, got %p\n", ssb2.base.base + 10, ssb2.base.ebuf);
2411 ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
2412 ok(ssb2.base.gptr == ssb2.base.base + 2, "wrong get pointer, expected %p got %p\n", ssb2.base.base + 2, ssb2.base.gptr);
2413 ok(ssb2.base.egptr == ssb2.base.base + 4, "wrong get end, expected %p got %p\n", ssb2.base.base + 4, ssb2.base.egptr);
2414 ok(!strncmp(ssb2.base.base, "Check", 5), "strings are not equal\n");
2415 ssb2.base.pbase = ssb2.base.pptr = ssb2.base.base + 4;
2416 ssb2.base.epptr = ssb2.base.ebuf;
2417 ssb2.increase = -3;
2418 ret = (int) call_func1(p_strstreambuf_doallocate, &ssb2);
2419 ok(ret == 1, "return value %d\n", ret);
2420 ok(ssb2.base.ebuf == ssb2.base.base + 11, "expected %p, got %p\n", ssb2.base.base + 11, ssb2.base.ebuf);
2421 ok(ssb2.base.pbase == ssb2.base.base + 4, "wrong put base, expected %p got %p\n", ssb2.base.base + 4, ssb2.base.pbase);
2422 ok(ssb2.base.pptr == ssb2.base.base + 4, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 4, ssb2.base.pptr);
2423 ok(ssb2.base.epptr == ssb2.base.base + 10, "wrong put end, expected %p got %p\n", ssb2.base.base + 10, ssb2.base.epptr);
2424 ok(!strncmp(ssb2.base.base, "Check", 5), "strings are not equal\n");
2425 ssb2.dynamic = 1;
2427 /* setbuf */
2428 pret = call_func3(p_strstreambuf_setbuf, &ssb1, buffer + 16, 16);
2429 ok(pret == &ssb1.base, "expected %p got %p\n", &ssb1.base, pret);
2430 ok(ssb1.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb1.base.base);
2431 ok(ssb1.increase == 16, "expected 16, got %d\n", ssb1.increase);
2432 pret = call_func3(p_strstreambuf_setbuf, &ssb2, NULL, 2);
2433 ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
2434 ok(ssb2.increase == 2, "expected 2, got %d\n", ssb2.increase);
2435 pret = call_func3(p_strstreambuf_setbuf, &ssb2, buffer, 0);
2436 ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
2437 ok(ssb2.increase == 2, "expected 2, got %d\n", ssb2.increase);
2438 pret = call_func3(p_strstreambuf_setbuf, &ssb2, NULL, -2);
2439 ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
2440 ok(ssb2.increase == -2, "expected -2, got %d\n", ssb2.increase);
2442 /* underflow */
2443 ssb1.base.epptr = ssb1.base.ebuf = ssb1.base.base + 64;
2444 ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
2445 ok(ret == 'T', "expected 'T' got %d\n", ret);
2446 ssb1.base.gptr = ssb1.base.egptr;
2447 ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
2448 ok(ret == EOF, "expected EOF got %d\n", ret);
2449 ret = (int) call_func3(p_streambuf_xsputn, &ssb1.base, "Gotta make you understand", 5);
2450 ok(ret == 5, "expected 5 got %d\n", ret);
2451 ok(ssb1.base.pptr == buffer + 25, "wrong put pointer, expected %p got %p\n", buffer + 25, ssb1.base.pptr);
2452 ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
2453 ok(ret == 'G', "expected 'G' got %d\n", ret);
2454 ok(ssb1.base.egptr == buffer + 25, "wrong get end, expected %p got %p\n", buffer + 25, ssb1.base.egptr);
2455 *ssb1.base.gptr = -50;
2456 ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
2457 ok(ret == 206, "expected 206 got %d\n", ret);
2458 ok(ssb1.base.egptr == buffer + 25, "wrong get end, expected %p got %p\n", buffer + 25, ssb1.base.egptr);
2459 ssb1.base.gptr = ssb1.base.egptr = ssb1.base.pptr = ssb1.base.epptr;
2460 ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
2461 ok(ret == EOF, "expected EOF got %d\n", ret);
2462 ssb2.base.eback = ssb2.base.gptr = ssb2.base.egptr = NULL;
2463 ssb2.base.pbase = ssb2.base.pptr = ssb2.base.epptr = NULL;
2464 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2465 ok(ret == EOF, "expected EOF got %d\n", ret);
2466 ssb2.base.pbase = ssb2.base.pptr = ssb2.base.base;
2467 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2468 ok(ret == EOF, "expected EOF got %d\n", ret);
2469 ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
2470 ok(ssb2.base.gptr == ssb2.base.base, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
2471 ok(ssb2.base.egptr == ssb2.base.base, "wrong get end, expected %p got %p\n", ssb2.base.base, ssb2.base.egptr);
2472 ssb2.base.pptr = ssb2.base.base + 3;
2473 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2474 ok(ret == 'C', "expected 'C' got %d\n", ret);
2475 ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
2476 ok(ssb2.base.gptr == ssb2.base.base, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
2477 ok(ssb2.base.egptr == ssb2.base.base + 3, "wrong get end, expected %p got %p\n", ssb2.base.base + 3, ssb2.base.egptr);
2478 ssb2.base.gptr = ssb2.base.base + 2;
2479 ssb2.base.egptr = NULL;
2480 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2481 ok(ret == 'e', "expected 'e' got %d\n", ret);
2482 ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
2483 ok(ssb2.base.gptr == ssb2.base.base + 2, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
2484 ok(ssb2.base.egptr == ssb2.base.base + 3, "wrong get end, expected %p got %p\n", ssb2.base.base + 3, ssb2.base.egptr);
2485 ssb2.base.eback = ssb2.base.egptr = ssb2.base.base + 1;
2486 ssb2.base.gptr = ssb2.base.base + 3;
2487 ssb2.base.pptr = ssb2.base.base + 5;
2488 *(ssb2.base.base + 2) = -50;
2489 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2490 ok(ret == 206, "expected 206 got %d\n", ret);
2491 ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
2492 ok(ssb2.base.gptr == ssb2.base.base + 2, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
2493 ok(ssb2.base.egptr == ssb2.base.base + 5, "wrong get end, expected %p got %p\n", ssb2.base.base + 5, ssb2.base.egptr);
2494 ssb2.base.eback = ssb2.base.base;
2495 ssb2.base.gptr = ssb2.base.egptr = ssb2.base.ebuf;
2496 ssb2.base.pbase = ssb2.base.pptr = NULL;
2497 ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
2498 ok(ret == EOF, "expected EOF got %d\n", ret);
2500 /* overflow */
2501 ssb1.base.pptr = ssb1.base.epptr - 1;
2502 ret = (int) call_func2(p_strstreambuf_overflow, &ssb1, EOF);
2503 ok(ret == 1, "expected 1 got %d\n", ret);
2504 ret = (int) call_func2(p_strstreambuf_overflow, &ssb1, 'A');
2505 ok(ret == 1, "expected 1 got %d\n", ret);
2506 ok(ssb1.base.pptr == ssb1.base.epptr, "wrong put pointer, expected %p got %p\n", ssb1.base.epptr, ssb1.base.pptr);
2507 ok(*(ssb1.base.pptr - 1) == 'A', "expected 'A' got %d\n", *(ssb1.base.pptr - 1));
2508 ret = (int) call_func2(p_strstreambuf_overflow, &ssb1, 'B');
2509 ok(ret == EOF, "expected EOF got %d\n", ret);
2510 ret = (int) call_func2(p_strstreambuf_overflow, &ssb1, EOF);
2511 ok(ret == EOF, "expected EOF got %d\n", ret);
2512 ssb2.dynamic = 0;
2513 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'C');
2514 ok(ret == EOF, "expected EOF got %d\n", ret);
2515 ssb2.dynamic = 1;
2516 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'C');
2517 ok(ret == 1, "expected 1 got %d\n", ret);
2518 ok(ssb2.base.ebuf == ssb2.base.base + 12, "expected %p got %p\n", ssb2.base.base + 12, ssb2.base.ebuf);
2519 ok(ssb2.base.gptr == ssb2.base.base + 11, "wrong get pointer, expected %p got %p\n", ssb2.base.base + 11, ssb2.base.gptr);
2520 ok(ssb2.base.pbase == ssb2.base.base + 11, "wrong put base, expected %p got %p\n", ssb2.base.base + 11, ssb2.base.pbase);
2521 ok(ssb2.base.pptr == ssb2.base.base + 12, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 12, ssb2.base.pptr);
2522 ok(ssb2.base.epptr == ssb2.base.base + 12, "wrong put end, expected %p got %p\n", ssb2.base.base + 12, ssb2.base.epptr);
2523 ok(*(ssb2.base.pptr - 1) == 'C', "expected 'C' got %d\n", *(ssb2.base.pptr - 1));
2524 ssb2.increase = 4;
2525 ssb2.base.eback = ssb2.base.gptr = ssb2.base.egptr = NULL;
2526 ssb2.base.pbase = ssb2.base.pptr = ssb2.base.epptr = NULL;
2527 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'D');
2528 ok(ret == 1, "expected 1 got %d\n", ret);
2529 ok(ssb2.base.ebuf == ssb2.base.base + 16, "expected %p got %p\n", ssb2.base.base + 16, ssb2.base.ebuf);
2530 ok(ssb2.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, ssb2.base.gptr);
2531 ok(ssb2.base.pbase == ssb2.base.base, "wrong put base, expected %p got %p\n", ssb2.base.base, ssb2.base.pbase);
2532 ok(ssb2.base.pptr == ssb2.base.base + 1, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 1, ssb2.base.pptr);
2533 ok(ssb2.base.epptr == ssb2.base.base + 16, "wrong put end, expected %p got %p\n", ssb2.base.base + 16, ssb2.base.epptr);
2534 ok(*(ssb2.base.pptr - 1) == 'D', "expected 'D' got %d\n", *(ssb2.base.pptr - 1));
2535 ssb2.base.pbase = ssb2.base.base + 3;
2536 ssb2.base.pptr = ssb2.base.epptr + 5;
2537 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'E');
2538 ok(ret == 1, "expected 1 got %d\n", ret);
2539 ok(ssb2.base.ebuf == ssb2.base.base + 20, "expected %p got %p\n", ssb2.base.base + 20, ssb2.base.ebuf);
2540 ok(ssb2.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, ssb2.base.gptr);
2541 ok(ssb2.base.pbase == ssb2.base.base + 3, "wrong put base, expected %p got %p\n", ssb2.base.base + 3, ssb2.base.pbase);
2542 ok(ssb2.base.pptr == ssb2.base.base + 22, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 22, ssb2.base.pptr);
2543 ok(ssb2.base.epptr == ssb2.base.base + 20, "wrong put end, expected %p got %p\n", ssb2.base.base + 20, ssb2.base.epptr);
2544 ok(*(ssb2.base.pptr - 1) == 'E', "expected 'E' got %d\n", *(ssb2.base.pptr - 1));
2545 ssb2.base.egptr = ssb2.base.base + 2;
2546 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'F');
2547 ok(ret == 1, "expected 1 got %d\n", ret);
2548 ok(ssb2.base.ebuf == ssb2.base.base + 24, "expected %p got %p\n", ssb2.base.base + 24, ssb2.base.ebuf);
2549 ok(ssb2.base.gptr != NULL, "wrong get pointer, expected != NULL\n");
2550 ok(ssb2.base.pbase == ssb2.base.base + 3, "wrong put base, expected %p got %p\n", ssb2.base.base + 3, ssb2.base.pbase);
2551 ok(ssb2.base.pptr == ssb2.base.base + 23, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 23, ssb2.base.pptr);
2552 ok(ssb2.base.epptr == ssb2.base.base + 24, "wrong put end, expected %p got %p\n", ssb2.base.base + 24, ssb2.base.epptr);
2553 ok(*(ssb2.base.pptr - 1) == 'F', "expected 'F' got %d\n", *(ssb2.base.pptr - 1));
2554 ssb2.base.eback = ssb2.base.gptr = ssb2.base.base;
2555 ssb2.base.epptr = NULL;
2556 ret = (int) call_func2(p_strstreambuf_overflow, &ssb2, 'G');
2557 ok(ret == 1, "expected 1 got %d\n", ret);
2558 ok(ssb2.base.ebuf == ssb2.base.base + 28, "expected %p got %p\n", ssb2.base.base + 28, ssb2.base.ebuf);
2559 ok(ssb2.base.gptr == ssb2.base.base, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
2560 ok(ssb2.base.pbase == ssb2.base.base + 2, "wrong put base, expected %p got %p\n", ssb2.base.base + 2, ssb2.base.pbase);
2561 ok(ssb2.base.pptr == ssb2.base.base + 3, "wrong put pointer, expected %p got %p\n", ssb2.base.base + 3, ssb2.base.pptr);
2562 ok(ssb2.base.epptr == ssb2.base.base + 28, "wrong put end, expected %p got %p\n", ssb2.base.base + 28, ssb2.base.epptr);
2563 ok(*(ssb2.base.pptr - 1) == 'G', "expected 'G' got %d\n", *(ssb2.base.pptr - 1));
2565 /* seekoff */
2566 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 0, SEEKDIR_beg, OPENMODE_in);
2567 ok(ret == 0, "expected 0 got %d\n", ret);
2568 ok(ssb1.base.gptr == ssb1.base.eback, "wrong get pointer, expected %p got %p\n", ssb1.base.eback, ssb1.base.gptr);
2569 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 3, SEEKDIR_beg, OPENMODE_in);
2570 ok(ret == 3, "expected 3 got %d\n", ret);
2571 ok(ssb1.base.gptr == ssb1.base.eback + 3, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 3, ssb1.base.gptr);
2572 ssb1.base.egptr = ssb1.base.pbase;
2573 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 25, SEEKDIR_beg, OPENMODE_in);
2574 ok(ret == EOF, "expected EOF got %d\n", ret);
2575 ok(ssb1.base.gptr == ssb1.base.eback + 3, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 3, ssb1.base.gptr);
2576 ssb1.base.gptr = ssb1.base.egptr;
2577 ssb1.base.pptr = ssb1.base.pbase + 10;
2578 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 25, SEEKDIR_beg, OPENMODE_in);
2579 ok(ret == 25, "expected 25 got %d\n", ret);
2580 ok(ssb1.base.gptr == ssb1.base.eback + 25, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 25, ssb1.base.gptr);
2581 ok(ssb1.base.egptr == ssb1.base.pptr, "wrong get end, expected %p got %p\n", ssb1.base.pptr, ssb1.base.egptr);
2582 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -24, SEEKDIR_cur, OPENMODE_in);
2583 ok(ret == 1, "expected 1 got %d\n", ret);
2584 ok(ssb1.base.gptr == ssb1.base.eback + 1, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 1, ssb1.base.gptr);
2585 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -5, SEEKDIR_cur, OPENMODE_in);
2586 ok(ret == EOF, "expected EOF got %d\n", ret);
2587 ok(ssb1.base.gptr == ssb1.base.eback + 1, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 1, ssb1.base.gptr);
2588 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 0, SEEKDIR_end, OPENMODE_in);
2589 ok(ret == 30, "expected 30 got %d\n", ret);
2590 ok(ssb1.base.gptr == ssb1.base.egptr, "wrong get pointer, expected %p got %p\n", ssb1.base.egptr, ssb1.base.gptr);
2591 ssb1.base.gptr = ssb1.base.eback;
2592 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -2, SEEKDIR_end, OPENMODE_in);
2593 ok(ret == 28, "expected 28 got %d\n", ret);
2594 ok(ssb1.base.gptr == ssb1.base.egptr - 2, "wrong get pointer, expected %p got %p\n", ssb1.base.egptr - 2, ssb1.base.gptr);
2595 ssb1.base.gptr = ssb1.base.egptr;
2596 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -5, SEEKDIR_end, OPENMODE_in);
2597 ok(ret == 25, "expected 25 got %d\n", ret);
2598 ok(ssb1.base.gptr == ssb1.base.egptr - 5, "wrong get pointer, expected %p got %p\n", ssb1.base.egptr - 5, ssb1.base.gptr);
2599 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 1, SEEKDIR_end, OPENMODE_in);
2600 ok(ret == EOF, "expected EOF got %d\n", ret);
2601 ok(ssb1.base.gptr == ssb1.base.egptr - 5, "wrong get pointer, expected %p got %p\n", ssb1.base.egptr - 5, ssb1.base.gptr);
2602 ssb1.base.gptr = ssb1.base.egptr;
2603 ssb1.base.pptr = ssb1.base.egptr + 5;
2604 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 1, SEEKDIR_end, OPENMODE_in);
2605 ok(ret == EOF, "expected EOF got %d\n", ret);
2606 ok(ssb1.base.gptr == ssb1.base.egptr - 5, "wrong get pointer, expected %p got %p\n", ssb1.base.egptr - 5, ssb1.base.gptr);
2607 ok(ssb1.base.egptr == ssb1.base.pptr, "wrong get end, expected %p got %p\n", ssb1.base.pptr, ssb1.base.egptr);
2608 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 3, SEEKDIR_beg, OPENMODE_out);
2609 ok(ret == 3, "expected 3 got %d\n", ret);
2610 ok(ssb1.base.pptr == ssb1.base.pbase + 3, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 3, ssb1.base.pptr);
2611 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -2, SEEKDIR_beg, OPENMODE_out);
2612 ok(ret == EOF, "expected EOF got %d\n", ret);
2613 ok(ssb1.base.pptr == ssb1.base.pbase + 3, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 3, ssb1.base.pptr);
2614 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 50, SEEKDIR_beg, OPENMODE_out);
2615 ok(ret == EOF, "expected EOF got %d\n", ret);
2616 ok(ssb1.base.pptr == ssb1.base.pbase + 3, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 3, ssb1.base.pptr);
2617 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 5, SEEKDIR_cur, OPENMODE_out);
2618 ok(ret == 8, "expected 8 got %d\n", ret);
2619 ok(ssb1.base.pptr == ssb1.base.pbase + 8, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 8, ssb1.base.pptr);
2620 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, -2, SEEKDIR_end, OPENMODE_out);
2621 ok(ret == 42, "expected 42 got %d\n", ret);
2622 ok(ssb1.base.pptr == ssb1.base.epptr - 2, "wrong put pointer, expected %p got %p\n", ssb1.base.epptr - 2, ssb1.base.pptr);
2623 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 0, SEEKDIR_end, OPENMODE_out);
2624 ok(ret == 44, "expected 44 got %d\n", ret);
2625 ok(ssb1.base.pptr == ssb1.base.epptr, "wrong put pointer, expected %p got %p\n", ssb1.base.epptr, ssb1.base.pptr);
2626 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 5, SEEKDIR_beg, OPENMODE_in|OPENMODE_out);
2627 ok(ret == 5, "expected 5 got %d\n", ret);
2628 ok(ssb1.base.gptr == ssb1.base.eback + 5, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 5, ssb1.base.gptr);
2629 ok(ssb1.base.pptr == ssb1.base.pbase + 5, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 5, ssb1.base.pptr);
2630 ssb1.base.egptr = ssb1.base.pbase;
2631 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 21, SEEKDIR_beg, OPENMODE_in|OPENMODE_out);
2632 ok(ret == EOF, "expected EOF got %d\n", ret);
2633 ok(ssb1.base.gptr == ssb1.base.eback + 5, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 5, ssb1.base.gptr);
2634 ok(ssb1.base.pptr == ssb1.base.pbase + 5, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 5, ssb1.base.pptr);
2635 ssb1.base.egptr = ssb1.base.epptr;
2636 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 50, SEEKDIR_beg, OPENMODE_in|OPENMODE_out);
2637 ok(ret == EOF, "expected EOF got %d\n", ret);
2638 ok(ssb1.base.gptr == ssb1.base.eback + 50, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 50, ssb1.base.gptr);
2639 ok(ssb1.base.pptr == ssb1.base.pbase + 5, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 5, ssb1.base.pptr);
2640 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb1, 2, SEEKDIR_cur, OPENMODE_in|OPENMODE_out);
2641 ok(ret == 7, "expected 7 got %d\n", ret);
2642 ok(ssb1.base.gptr == ssb1.base.eback + 52, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 52, ssb1.base.gptr);
2643 ok(ssb1.base.pptr == ssb1.base.pbase + 7, "wrong put pointer, expected %p got %p\n", ssb1.base.pbase + 7, ssb1.base.pptr);
2644 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb2, 0, SEEKDIR_beg, OPENMODE_in|OPENMODE_out);
2645 ok(ret == 0, "expected 0 got %d\n", ret);
2646 ok(ssb2.base.gptr == ssb2.base.eback, "wrong get pointer, expected %p got %p\n", ssb2.base.eback, ssb2.base.gptr);
2647 ok(ssb2.base.pptr == ssb2.base.pbase, "wrong put pointer, expected %p got %p\n", ssb2.base.pbase, ssb2.base.pptr);
2648 ssb2.base.gptr = ssb2.base.egptr;
2649 ssb2.base.pptr += 10;
2650 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb2, 5, SEEKDIR_cur, OPENMODE_in|OPENMODE_out);
2651 ok(ret == 15, "expected 15 got %d\n", ret);
2652 ok(ssb2.base.gptr == ssb2.base.eback + 7, "wrong get pointer, expected %p got %p\n", ssb2.base.eback + 7, ssb2.base.gptr);
2653 ok(ssb2.base.egptr == ssb2.base.eback + 12, "wrong get end, expected %p got %p\n", ssb2.base.eback + 12, ssb2.base.egptr);
2654 ok(ssb2.base.pptr == ssb2.base.pbase + 15, "wrong put pointer, expected %p got %p\n", ssb2.base.pbase + 15, ssb2.base.pptr);
2655 ssb2.base.pptr = ssb2.base.epptr;
2656 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb2, -1, SEEKDIR_cur, OPENMODE_in|OPENMODE_out);
2657 ok(ret == 25, "expected 25 got %d\n", ret);
2658 ok(ssb2.base.gptr == ssb2.base.eback + 6, "wrong get pointer, expected %p got %p\n", ssb2.base.eback + 6, ssb2.base.gptr);
2659 ok(ssb2.base.pptr == ssb2.base.pbase + 25, "wrong put pointer, expected %p got %p\n", ssb2.base.pbase + 25, ssb2.base.pptr);
2660 pbuffer = ssb2.base.pbase;
2661 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb2, 50, SEEKDIR_beg, OPENMODE_out);
2662 ok(ret == 50, "expected 50 got %d\n", ret);
2663 ok(ssb2.base.gptr == ssb2.base.eback + 6, "wrong get pointer, expected %p got %p\n", ssb2.base.eback + 6, ssb2.base.gptr);
2664 ok(ssb2.base.pptr == pbuffer + 50, "wrong put pointer, expected %p got %p\n", pbuffer + 50, ssb2.base.pptr);
2665 ok(ssb2.increase == 50, "expected 50 got %d\n", ssb2.increase);
2666 ssb2.base.epptr = NULL;
2667 ssb2.increase = 8;
2668 ret = (int) call_func4(p_strstreambuf_seekoff, &ssb2, 0, SEEKDIR_end, OPENMODE_out);
2669 ok(ret == 74, "expected 74 got %d\n", ret);
2670 ok(ssb2.base.pptr == ssb2.base.epptr, "wrong put pointer, expected %p got %p\n", ssb2.base.epptr, ssb2.base.pptr);
2672 /* pbackfail */
2673 *(ssb1.base.gptr-1) = 'A';
2674 ret = (int) call_func2(p_streambuf_pbackfail, &ssb1.base, 'X');
2675 ok(ret == 'X', "wrong return, expected 'X' got %d\n", ret);
2676 ok(ssb1.base.gptr == ssb1.base.eback + 51, "wrong get pointer, expected %p got %p\n", ssb1.base.eback + 51, ssb1.base.gptr);
2677 ok(*ssb1.base.gptr == 'X', "expected 'X' got '%c'\n", *ssb1.base.gptr);
2678 ssb1.base.gptr = ssb1.base.eback;
2679 ret = (int) call_func2(p_streambuf_pbackfail, &ssb1.base, 'Y');
2680 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
2681 ssb1.base.gptr = ssb1.base.eback + 1;
2682 ret = (int) call_func2(p_streambuf_pbackfail, &ssb1.base, EOF);
2683 ok(ret == (char)EOF, "wrong return, expected EOF got %d\n", ret);
2684 ok(ssb1.base.gptr == ssb1.base.eback, "wrong get pointer, expected %p got %p\n", ssb1.base.eback, ssb1.base.gptr);
2685 ok((signed char)*ssb1.base.gptr == EOF, "expected EOF got '%c'\n", *ssb1.base.gptr);
2687 call_func1(p_strstreambuf_dtor, &ssb1);
2688 call_func1(p_strstreambuf_dtor, &ssb2);
2691 static void test_stdiobuf(void)
2693 stdiobuf stb1, stb2;
2694 FILE *file1, *file2;
2695 const char filename1[] = "stdiobuf_test1";
2696 const char filename2[] = "stdiobuf_test2";
2697 int ret, last;
2698 char buffer[64];
2700 memset(&stb1, 0xab, sizeof(stdiobuf));
2701 memset(&stb2, 0xab, sizeof(stdiobuf));
2703 file1 = fopen(filename1, "w");
2704 fputs("Never gonna give you up, never gonna let you down", file1);
2705 fclose(file1);
2706 file1 = fopen(filename1, "r");
2707 ok(file1 != NULL, "Couldn't open the file named '%s'\n", filename1);
2708 file2 = fopen(filename2, "w+");
2709 ok(file2 != NULL, "Couldn't open the file named '%s'\n", filename2);
2711 /* constructors/destructor */
2712 call_func2(p_stdiobuf_file_ctor, &stb1, NULL);
2713 ok(stb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", stb1.base.allocated);
2714 ok(stb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", stb1.base.unbuffered);
2715 ok(stb1.file == NULL, "wrong file pointer, expected %p got %p\n", NULL, stb1.file);
2716 call_func1(p_stdiobuf_dtor, &stb1);
2717 call_func2(p_stdiobuf_file_ctor, &stb1, file1);
2718 ok(stb1.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", stb1.base.allocated);
2719 ok(stb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", stb1.base.unbuffered);
2720 ok(stb1.file == file1, "wrong file pointer, expected %p got %p\n", file1, stb1.file);
2721 call_func2(p_stdiobuf_file_ctor, &stb2, file2);
2722 ok(stb2.base.allocated == 0, "wrong allocate value, expected 0 got %d\n", stb2.base.allocated);
2723 ok(stb2.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", stb2.base.unbuffered);
2724 ok(stb2.file == file2, "wrong file pointer, expected %p got %p\n", file2, stb2.file);
2726 /* overflow */
2727 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, EOF);
2728 ok(ret == 1, "expected 1 got %d\n", ret);
2729 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, 'a');
2730 ok(ret == EOF, "expected EOF got %d\n", ret);
2731 stb1.base.unbuffered = 0;
2732 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, 'a');
2733 ok(ret == 1, "expected 1 got %d\n", ret);
2734 ok(stb1.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", stb1.base.allocated);
2735 ok(stb1.base.ebuf == stb1.base.base + 512, "expected %p got %p\n", stb1.base.base + 512, stb1.base.ebuf);
2736 ok(stb1.base.pbase == stb1.base.base + 256, "wrong put base, expected %p got %p\n", stb1.base.base + 256, stb1.base.pbase);
2737 ok(stb1.base.pptr == stb1.base.pbase + 1, "wrong put pointer, expected %p got %p\n", stb1.base.pbase + 1, stb1.base.pptr);
2738 ok(stb1.base.epptr == stb1.base.ebuf, "wrong put end, expected %p got %p\n", stb1.base.ebuf, stb1.base.epptr);
2739 ok(*(stb1.base.pptr-1) == 'a', "expected 'a', got '%c'\n", *(stb1.base.pptr-1));
2740 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, EOF);
2741 ok(ret == EOF, "expected EOF got %d\n", ret);
2742 ok(stb1.base.pptr == stb1.base.pbase + 1, "wrong put pointer, expected %p got %p\n", stb1.base.pbase + 1, stb1.base.pptr);
2743 stb1.base.pptr = stb1.base.pbase;
2744 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, EOF);
2745 ok(ret == 1, "expected 1 got %d\n", ret);
2746 ok(stb1.base.pptr == stb1.base.pbase, "wrong put pointer, expected %p got %p\n", stb1.base.pbase, stb1.base.pptr);
2747 ret = (int) call_func2(p_stdiobuf_overflow, &stb1, 'b');
2748 ok(ret == 1, "expected 1 got %d\n", ret);
2749 ok(stb1.base.pptr == stb1.base.pbase + 1, "wrong put pointer, expected %p got %p\n", stb1.base.pbase + 1, stb1.base.pptr);
2750 ok(*(stb1.base.pptr-1) == 'b', "expected 'b', got '%c'\n", *(stb1.base.pptr-1));
2751 stb1.base.unbuffered = 1;
2752 ret = (int) call_func2(p_stdiobuf_overflow, &stb2, EOF);
2753 ok(ret == 1, "expected 1 got %d\n", ret);
2754 ret = (int) call_func2(p_stdiobuf_overflow, &stb2, 'a');
2755 ok(ret == 'a', "expected 'a' got %d\n", ret);
2756 stb2.base.unbuffered = 0;
2757 stb2.base.base = buffer;
2758 stb2.base.pbase = stb2.base.pptr = buffer + 32;
2759 stb2.base.ebuf = stb2.base.epptr = buffer + 64;
2760 ret = (int) call_func3(p_streambuf_xsputn, &stb2.base, "Never gonna run around", 22);
2761 ok(ret == 22, "expected 22 got %d\n", ret);
2762 ret = (int) call_func2(p_stdiobuf_overflow, &stb2, 'c');
2763 ok(ret == 1, "expected 1 got %d\n", ret);
2764 ok(stb2.base.pptr == stb2.base.pbase + 1, "wrong put pointer, expected %p got %p\n", stb2.base.pbase + 1, stb2.base.pptr);
2765 ok(*(stb2.base.pptr-1) == 'c', "expected 'c', got '%c'\n", *(stb2.base.pptr-1));
2766 stb2.base.pbase = stb2.base.pptr + 3;
2767 ret = (int) call_func2(p_stdiobuf_overflow, &stb2, 'd');
2768 ok(ret == 1, "expected 1 got %d\n", ret);
2769 ok(stb2.base.pptr == stb2.base.pbase - 2, "wrong put pointer, expected %p got %p\n", stb2.base.pbase - 2, stb2.base.pptr);
2770 ok(*(stb2.base.pptr-1) == 'd', "expected 'd', got '%c'\n", *(stb2.base.pptr-1));
2771 stb2.base.pbase = stb2.base.pptr = buffer + 32;
2772 stb2.base.epptr = buffer + 30;
2773 ret = (int) call_func2(p_stdiobuf_overflow, &stb2, 'd');
2774 ok(ret == 'd', "expected 'd' got %d\n", ret);
2775 ok(stb2.base.pptr == stb2.base.pbase, "wrong put pointer, expected %p got %p\n", stb2.base.pbase, stb2.base.pptr);
2776 stb2.base.epptr = buffer + 64;
2777 stb2.base.unbuffered = 1;
2779 /* underflow */
2780 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2781 ok(ret == 'N', "expected 'N' got %d\n", ret);
2782 stb1.base.unbuffered = 0;
2783 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2784 ok(ret == 'e', "expected 'e' got %d\n", ret);
2785 ok(stb1.base.eback == stb1.base.base, "wrong get base, expected %p got %p\n", stb1.base.base, stb1.base.eback);
2786 ok(stb1.base.gptr == stb1.base.egptr - 47, "wrong get pointer, expected %p got %p\n", stb1.base.egptr - 47, stb1.base.gptr);
2787 ok(stb1.base.egptr == stb1.base.base + 256, "wrong get end, expected %p got %p\n", stb1.base.base + 256, stb1.base.egptr);
2788 ok(*stb1.base.gptr == 'v', "expected 'v' got '%c'\n", *stb1.base.gptr);
2789 stb1.base.pbase = stb1.base.pptr = stb1.base.epptr = NULL;
2790 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2791 ok(ret == 'v', "expected 'v' got %d\n", ret);
2792 ok(stb1.base.gptr == stb1.base.egptr - 46, "wrong get pointer, expected %p got %p\n", stb1.base.egptr - 46, stb1.base.gptr);
2793 *stb1.base.gptr = -50;
2794 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2795 ok(ret == 206, "expected 206 got %d\n", ret);
2796 ok(stb1.base.gptr == stb1.base.egptr - 45, "wrong get pointer, expected %p got %p\n", stb1.base.egptr - 45, stb1.base.gptr);
2797 stb1.base.gptr = stb1.base.egptr;
2798 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2799 ok(ret == EOF, "expected EOF got %d\n", ret);
2800 stb1.base.unbuffered = 1;
2801 ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
2802 ok(ret == EOF, "expected EOF got %d\n", ret);
2803 rewind(stb2.file);
2804 ret = (int) call_func1(p_stdiobuf_underflow, &stb2);
2805 ok(ret == 'a', "expected 'a' got %d\n", ret);
2806 stb2.base.unbuffered = 0;
2807 stb2.base.eback = stb2.base.gptr = buffer + 16;
2808 stb2.base.egptr = buffer + 32;
2809 strcpy(buffer + 16, "and desert you");
2810 ret = (int) call_func1(p_stdiobuf_underflow, &stb2);
2811 ok(ret == 'a', "expected 'a' got %d\n", ret);
2812 ok(stb2.base.gptr == buffer + 17, "wrong get pointer, expected %p got %p\n", buffer + 17, stb2.base.gptr);
2813 stb2.base.eback = buffer;
2814 stb2.base.gptr = stb2.base.egptr;
2815 stb2.base.pbase = stb2.base.pptr = stb2.base.epptr = NULL;
2816 ret = (int) call_func1(p_stdiobuf_underflow, &stb2);
2817 ok(ret == 'N', "expected 'N' got %d\n", ret);
2818 ok(stb2.base.gptr == stb2.base.egptr - 22, "wrong get pointer, expected %p got %p\n", stb2.base.egptr - 22, stb2.base.gptr);
2819 ok(ftell(stb2.file) == 24, "ftell failed\n");
2820 stb2.base.gptr = stb2.base.egptr;
2821 ret = (int) call_func1(p_stdiobuf_underflow, &stb2);
2822 ok(ret == EOF, "expected EOF got %d\n", ret);
2823 stb2.base.unbuffered = 1;
2824 ret = (int) call_func1(p_stdiobuf_underflow, &stb2);
2825 ok(ret == EOF, "expected EOF got %d\n", ret);
2827 /* sync */
2828 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2829 ok(ret == 0, "expected 0 got %d\n", ret);
2830 stb1.base.gptr = stb1.base.eback;
2831 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2832 ok(ret == 0, "expected 0 got %d\n", ret);
2833 stb1.base.unbuffered = 0;
2834 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2835 ok(ret == EOF, "expected EOF got %d\n", ret);
2836 ok(stb1.base.pbase == stb1.base.base + 256, "wrong put base, expected %p got %p\n", stb1.base.base + 256, stb1.base.pbase);
2837 ok(stb1.base.pptr == stb1.base.base + 256, "wrong put pointer, expected %p got %p\n", stb1.base.base + 256, stb1.base.pptr);
2838 ok(stb1.base.epptr == stb1.base.base + 512, "wrong put end, expected %p got %p\n", stb1.base.base + 512, stb1.base.epptr);
2839 stb1.base.gptr = stb1.base.egptr;
2840 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2841 ok(ret == 0, "expected 0 got %d\n", ret);
2842 stb1.base.eback = stb1.base.gptr = stb1.base.egptr = NULL;
2843 stb1.base.pptr = stb1.base.epptr;
2844 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2845 ok(ret == EOF, "expected EOF got %d\n", ret);
2846 ok(stb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, stb1.base.gptr);
2847 stb1.base.pptr = stb1.base.pbase;
2848 ret = (int) call_func1(p_stdiobuf_sync, &stb1);
2849 ok(ret == 0, "expected 0 got %d\n", ret);
2850 ok(stb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, stb1.base.gptr);
2851 stb1.base.unbuffered = 1;
2852 stb2.base.unbuffered = 0;
2853 stb2.base.egptr = stb2.base.ebuf;
2854 ret = (int) call_func1(p_stdiobuf_sync, &stb2);
2855 ok(ret == EOF, "expected EOF got %d\n", ret);
2856 ok(stb2.base.pbase == stb2.base.base + 32, "wrong put base, expected %p got %p\n", stb2.base.base + 32, stb2.base.pbase);
2857 ok(stb2.base.pptr == stb2.base.base + 32, "wrong put pointer, expected %p got %p\n", stb2.base.base + 32, stb2.base.pptr);
2858 ok(stb2.base.epptr == stb2.base.base + 64, "wrong put end, expected %p got %p\n", stb2.base.base + 64, stb2.base.epptr);
2859 stb2.base.egptr = stb2.base.pbase;
2860 stb2.base.gptr = stb2.base.egptr - 25;
2861 ret = (int) call_func1(p_stdiobuf_sync, &stb2);
2862 ok(ret == EOF, "expected EOF got %d\n", ret);
2863 ret = (int) call_func3(p_streambuf_xsputn, &stb2.base, "Never gonna make you cry", 24);
2864 ok(ret == 24, "expected 24 got %d\n", ret);
2865 ret = (int) call_func1(p_stdiobuf_sync, &stb2);
2866 ok(ret == 0, "expected 0 got %d\n", ret);
2867 ok(ftell(stb2.file) == 23, "ftell failed\n");
2868 ok(fseek(stb2.file, 3, SEEK_SET) == 0, "fseek failed\n");
2869 stb2.base.gptr = stb2.base.egptr - 3;
2870 strcpy(stb2.base.gptr, "a\nc");
2871 ret = (int) call_func1(p_stdiobuf_sync, &stb2);
2872 ok(ret == EOF, "expected EOF got %d\n", ret);
2873 ok(stb2.base.gptr == stb2.base.egptr - 3, "wrong get pointer, expected %p got %p\n", stb2.base.egptr - 3, stb2.base.gptr);
2874 *(stb2.base.gptr+1) = 'b';
2875 ret = (int) call_func1(p_stdiobuf_sync, &stb2);
2876 ok(ret == 0, "expected 0 got %d\n", ret);
2877 ok(stb2.base.gptr == stb2.base.egptr, "wrong get pointer, expected %p got %p\n", stb2.base.egptr, stb2.base.gptr);
2878 stb2.base.unbuffered = 1;
2880 /* setrwbuf */
2881 ret = (int) call_func3(p_stdiobuf_setrwbuf, &stb1, 100, 60);
2882 ok(ret == 1, "expected 1 got %d\n", ret);
2883 ok(stb1.base.allocated == 1, "wrong allocate value, expected 1 got %d\n", stb1.base.allocated);
2884 ok(stb1.base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", stb1.base.unbuffered);
2885 ok(stb1.base.ebuf == stb1.base.base + 160, "expected %p got %p\n", stb1.base.base + 160, stb1.base.ebuf);
2886 ok(stb1.base.eback == stb1.base.base, "wrong get base, expected %p got %p\n", stb1.base.base, stb1.base.eback);
2887 ok(stb1.base.gptr == stb1.base.base + 100, "wrong get pointer, expected %p got %p\n", stb1.base.base + 100, stb1.base.gptr);
2888 ok(stb1.base.egptr == stb1.base.base + 100, "wrong get end, expected %p got %p\n", stb1.base.base + 100, stb1.base.egptr);
2889 ok(stb1.base.pbase == stb1.base.base + 100, "wrong put base, expected %p got %p\n", stb1.base.base + 100, stb1.base.pbase);
2890 ok(stb1.base.pptr == stb1.base.base + 100, "wrong put pointer, expected %p got %p\n", stb1.base.base + 100, stb1.base.pptr);
2891 ok(stb1.base.epptr == stb1.base.base + 160, "wrong put end, expected %p got %p\n", stb1.base.base + 160, stb1.base.epptr);
2892 ret = (int) call_func3(p_stdiobuf_setrwbuf, &stb1, -1, 64);
2893 ok(ret == 0 || ret == 1, "expected 0 or 1, got %d\n", ret);
2894 ret = (int) call_func3(p_stdiobuf_setrwbuf, &stb1, 32, -8);
2895 ok(ret == 0 || ret == 1, "expected 0 or 1, got %d\n", ret);
2896 ret = (int) call_func3(p_stdiobuf_setrwbuf, &stb1, 0, 64);
2897 ok(ret == 1, "expected 1 got %d\n", ret);
2898 ok(stb1.base.ebuf == stb1.base.base + 64, "expected %p got %p\n", stb1.base.base + 64, stb1.base.ebuf);
2899 ok(stb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, stb1.base.eback);
2900 ok(stb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, stb1.base.gptr);
2901 ok(stb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, stb1.base.egptr);
2902 ok(stb1.base.pbase == stb1.base.base, "wrong put base, expected %p got %p\n", stb1.base.base, stb1.base.pbase);
2903 ok(stb1.base.pptr == stb1.base.base, "wrong put pointer, expected %p got %p\n", stb1.base.base, stb1.base.pptr);
2904 ok(stb1.base.epptr == stb1.base.base + 64, "wrong put end, expected %p got %p\n", stb1.base.base + 64, stb1.base.epptr);
2905 ret = (int) call_func3(p_stdiobuf_setrwbuf, &stb1, 0, 0);
2906 ok(ret == 0, "expected 0 got %d\n", ret);
2907 ok(stb1.base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", stb1.base.unbuffered);
2909 /* seekoff */
2910 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 0, SEEKDIR_beg, OPENMODE_in);
2911 ok(ret == 0, "expected 0 got %d\n", ret);
2912 stb1.base.unbuffered = 0;
2913 ret = (int) call_func3(p_streambuf_xsputn, &stb1.base, "Never gonna say goodbye", 22);
2914 ok(ret == 22, "expected 22 got %d\n", ret);
2915 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 5, SEEKDIR_beg, OPENMODE_in);
2916 ok(ret == 5, "expected 5 got %d\n", ret);
2917 ok(stb1.base.pptr == stb1.base.pbase + 22, "wrong put pointer, expected %p got %p\n", stb1.base.pbase + 22, stb1.base.pptr);
2918 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 300, SEEKDIR_beg, OPENMODE_in);
2919 ok(ret == 300, "expected 300 got %d\n", ret);
2920 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, -310, SEEKDIR_cur, OPENMODE_in);
2921 ok(ret == EOF, "expected EOF got %d\n", ret);
2922 stb1.base.eback = stb1.base.base;
2923 stb1.base.gptr = stb1.base.egptr = stb1.base.pbase = stb1.base.base + 10;
2924 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, -280, SEEKDIR_cur, OPENMODE_in);
2925 ok(ret == 20, "expected 20 got %d\n", ret);
2926 stb1.base.gptr = stb1.base.eback;
2927 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 80, SEEKDIR_cur, OPENMODE_in);
2928 ok(ret == 100, "expected 100 got %d\n", ret);
2929 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 0, SEEKDIR_end, OPENMODE_in);
2930 ok(ret == 49, "expected 49 got %d\n", ret);
2931 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, 1, SEEKDIR_end, OPENMODE_in);
2932 ok(ret == 50, "expected 50 got %d\n", ret);
2933 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, -60, SEEKDIR_end, OPENMODE_in);
2934 ok(ret == EOF, "expected EOF got %d\n", ret);
2935 ret = (int) call_func4(p_stdiobuf_seekoff, &stb1, -20, SEEKDIR_end, OPENMODE_out);
2936 ok(ret == 29, "expected 29 got %d\n", ret);
2937 stb1.base.eback = stb1.base.gptr = stb1.base.egptr = NULL;
2938 stb1.base.pptr = stb1.base.pbase;
2939 stb1.base.unbuffered = 1;
2940 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, 0, SEEKDIR_beg, OPENMODE_in);
2941 ok(ret == 0, "expected 0 got %d\n", ret);
2942 stb2.base.pptr += 10;
2943 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, 20, SEEKDIR_beg, OPENMODE_in);
2944 ok(ret == 20, "expected 20 got %d\n", ret);
2945 ok(stb2.base.pptr == stb2.base.pbase + 10, "wrong put pointer, expected %p got %p\n", stb2.base.pbase + 10, stb2.base.pptr);
2946 stb2.base.unbuffered = 0;
2947 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, 10, SEEKDIR_cur, OPENMODE_in);
2948 ok(ret == 40, "expected 40 got %d\n", ret);
2949 ok(stb2.base.pptr == stb2.base.pbase, "wrong put pointer, expected %p got %p\n", stb2.base.pbase, stb2.base.pptr);
2950 stb2.base.gptr = stb2.base.eback;
2951 stb2.base.pptr += 5;
2952 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, -50, SEEKDIR_cur, OPENMODE_in|OPENMODE_out);
2953 ok(ret == EOF, "expected EOF got %d\n", ret);
2954 ok(stb2.base.pptr == stb2.base.pbase, "wrong put pointer, expected %p got %p\n", stb2.base.pbase, stb2.base.pptr);
2955 stb2.base.pbase = stb2.base.pptr = stb2.base.epptr = NULL;
2956 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, 0, SEEKDIR_end, OPENMODE_in|OPENMODE_out);
2957 ok(ret == 48, "expected 48 got %d\n", ret);
2958 ok(stb2.base.pbase == stb2.base.base + 32, "wrong put pointer, expected %p got %p\n", stb2.base.base + 32, stb2.base.pbase);
2959 ok(stb2.base.pptr == stb2.base.base + 32, "wrong put pointer, expected %p got %p\n", stb2.base.base + 32, stb2.base.pptr);
2960 ok(stb2.base.epptr == stb2.base.ebuf, "wrong put pointer, expected %p got %p\n", stb2.base.ebuf, stb2.base.epptr);
2961 ret = (int) call_func4(p_stdiobuf_seekoff, &stb2, -28, SEEKDIR_end, -1);
2962 ok(ret == 20, "expected 20 got %d\n", ret);
2963 stb2.base.gptr = stb2.base.egptr;
2964 stb2.base.unbuffered = 1;
2966 /* pbackfail */
2967 last = fgetc(stb1.file);
2968 ok(last == 'r', "expected 'r' got %d\n", last);
2969 ok(ftell(stb1.file) == 30, "ftell failed\n");
2970 ret = (int) call_func2(p_stdiobuf_pbackfail, &stb1, 'i');
2971 ok(ret == 'i', "expected 'i' got %d\n", ret);
2972 ok(ftell(stb1.file) == 29, "ftell failed\n");
2973 last = fgetc(stb1.file);
2974 ok(last == 'r', "expected 'r' got %d\n", last);
2975 ok(ftell(stb1.file) == 30, "ftell failed\n");
2976 stb1.base.eback = stb1.base.base;
2977 stb1.base.gptr = stb1.base.egptr = stb1.base.base + 9;
2978 strcpy(stb1.base.eback, "pbackfail");
2979 ret = (int) call_func2(p_stdiobuf_pbackfail, &stb1, 'j');
2980 ok(ret == 'j', "expected 'j' got %d\n", ret);
2981 ok(stb1.base.gptr == stb1.base.base + 8, "wrong get pointer, expected %p got %p\n", stb1.base.base + 8, stb1.base.gptr);
2982 ok(strncmp(stb1.base.eback, "pbackfaij", 9) == 0, "strncmp failed\n");
2983 ok(ftell(stb1.file) == 30, "ftell failed\n");
2984 stb1.base.gptr = stb1.base.eback;
2985 ret = (int) call_func2(p_stdiobuf_pbackfail, &stb1, 'k');
2986 ok(ret == 'k', "expected 'k' got %d\n", ret);
2987 ok(stb1.base.gptr == stb1.base.base, "wrong get pointer, expected %p got %p\n", stb1.base.base, stb1.base.gptr);
2988 ok(strncmp(stb1.base.eback, "pbackfaij", 9) == 0, "strncmp failed\n");
2989 ok(ftell(stb1.file) == 29, "ftell failed\n");
2990 stb1.base.unbuffered = 0;
2991 ret = (int) call_func2(p_stdiobuf_pbackfail, &stb1, 'l');
2992 ok(ret == 'l', "expected 'l' got %d\n", ret);
2993 ok(strncmp(stb1.base.eback, "lpbackfai", 9) == 0, "strncmp failed\n");
2994 ok(ftell(stb1.file) == 28, "ftell failed\n");
2995 stb1.base.egptr = NULL;
2996 ret = (int) call_func2(p_stdiobuf_pbackfail, &stb1, 'm');
2997 ok(ret == 'm', "expected 'm' got %d\n", ret);
2998 ok(strncmp(stb1.base.eback, "lpbackfai", 9) == 0, "strncmp failed\n");
2999 ok(ftell(stb1.file) == 27, "ftell failed\n");
3000 stb1.base.unbuffered = 1;
3002 call_func1(p_stdiobuf_dtor, &stb1);
3003 call_func1(p_stdiobuf_dtor, &stb2);
3004 fclose(file1);
3005 fclose(file2);
3006 ok(_unlink(filename1) == 0, "Couldn't unlink file named '%s'\n", filename1);
3007 ok(_unlink(filename2) == 0, "Couldn't unlink file named '%s'\n", filename2);
3010 struct ios_lock_arg
3012 ios *ios_obj;
3013 HANDLE lock;
3014 HANDLE release[3];
3017 static DWORD WINAPI lock_ios(void *arg)
3019 struct ios_lock_arg *lock_arg = arg;
3020 p_ios_lock(lock_arg->ios_obj);
3021 p_ios_lockbuf(lock_arg->ios_obj);
3022 p_ios_lockc();
3023 SetEvent(lock_arg->lock);
3024 WaitForSingleObject(lock_arg->release[0], INFINITE);
3025 p_ios_unlockc();
3026 WaitForSingleObject(lock_arg->release[1], INFINITE);
3027 p_ios_unlockbuf(lock_arg->ios_obj);
3028 WaitForSingleObject(lock_arg->release[2], INFINITE);
3029 p_ios_unlock(lock_arg->ios_obj);
3030 return 0;
3033 static void test_ios(void)
3035 ios ios_obj, ios_obj2;
3036 streambuf *psb;
3037 struct ios_lock_arg lock_arg;
3038 HANDLE thread;
3039 BOOL locked;
3040 LONG *pret, expected, ret;
3041 void **pret2;
3042 int i;
3044 memset(&ios_obj, 0xab, sizeof(ios));
3045 memset(&ios_obj2, 0xab, sizeof(ios));
3046 psb = p_operator_new(sizeof(streambuf));
3047 ok(psb != NULL, "failed to allocate streambuf object\n");
3048 call_func1(p_streambuf_ctor, psb);
3050 /* constructor/destructor */
3051 ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
3052 call_func2(p_ios_sb_ctor, &ios_obj, NULL);
3053 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3054 ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
3055 ok(ios_obj.special[0] == 0, "expected 0 got %d\n", ios_obj.special[0]);
3056 ok(ios_obj.special[1] == 0, "expected 0 got %d\n", ios_obj.special[1]);
3057 ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
3058 ok(ios_obj.tie == NULL, "expected %p got %p\n", NULL, ios_obj.tie);
3059 ok(ios_obj.flags == 0, "expected 0 got %x\n", ios_obj.flags);
3060 ok(ios_obj.precision == 6, "expected 6 got %d\n", ios_obj.precision);
3061 ok(ios_obj.fill == ' ', "expected ' ' got %d\n", ios_obj.fill);
3062 ok(ios_obj.width == 0, "expected 0 got %d\n", ios_obj.width);
3063 ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
3064 ok(ios_obj.lock.LockCount == -1, "expected -1 got %lu\n", ios_obj.lock.LockCount);
3065 ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
3066 ios_obj.state = 0x8;
3067 call_func1(p_ios_dtor, &ios_obj);
3068 ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
3069 ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
3070 memset(&ios_obj, 0xab, sizeof(ios));
3071 call_func2(p_ios_sb_ctor, &ios_obj, psb);
3072 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
3073 ok(ios_obj.state == IOSTATE_goodbit, "expected %x got %x\n", IOSTATE_goodbit, ios_obj.state);
3074 ok(ios_obj.special[0] == 0, "expected 0 got %d\n", ios_obj.special[0]);
3075 ok(ios_obj.special[1] == 0, "expected 0 got %d\n", ios_obj.special[1]);
3076 ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
3077 ok(ios_obj.tie == NULL, "expected %p got %p\n", NULL, ios_obj.tie);
3078 ok(ios_obj.flags == 0, "expected 0 got %x\n", ios_obj.flags);
3079 ok(ios_obj.precision == 6, "expected 6 got %d\n", ios_obj.precision);
3080 ok(ios_obj.fill == ' ', "expected ' ' got %d\n", ios_obj.fill);
3081 ok(ios_obj.width == 0, "expected 0 got %d\n", ios_obj.width);
3082 ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
3083 ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
3084 ios_obj.state = 0x8;
3085 call_func1(p_ios_dtor, &ios_obj);
3086 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3087 ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
3088 ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
3089 memset(&ios_obj, 0xab, sizeof(ios));
3090 call_func1(p_ios_ctor, &ios_obj);
3091 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3092 ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
3093 ok(ios_obj.special[0] == 0, "expected 0 got %d\n", ios_obj.special[0]);
3094 ok(ios_obj.special[1] == 0, "expected 0 got %d\n", ios_obj.special[1]);
3095 ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
3096 ok(ios_obj.tie == NULL, "expected %p got %p\n", NULL, ios_obj.tie);
3097 ok(ios_obj.flags == 0, "expected 0 got %x\n", ios_obj.flags);
3098 ok(ios_obj.precision == 6, "expected 6 got %d\n", ios_obj.precision);
3099 ok(ios_obj.fill == ' ', "expected ' ' got %d\n", ios_obj.fill);
3100 ok(ios_obj.width == 0, "expected 0 got %d\n", ios_obj.width);
3101 ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
3102 ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
3104 /* init */
3105 ios_obj.state |= 0x8;
3106 call_func2(p_ios_init, &ios_obj, psb);
3107 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
3108 ok(ios_obj.state == 0x8, "expected %x got %x\n", 0x8, ios_obj.state);
3109 call_func2(p_ios_init, &ios_obj, NULL);
3110 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3111 ok(ios_obj.state == (0x8|IOSTATE_badbit), "expected %x got %x\n", (0x8|IOSTATE_badbit), ios_obj.state);
3112 ios_obj.sb = psb;
3113 ios_obj.delbuf = 0;
3114 call_func2(p_ios_init, &ios_obj, psb);
3115 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
3116 ok(ios_obj.state == 0x8, "expected %x got %x\n", 0x8, ios_obj.state);
3117 call_func1(p_ios_dtor, &ios_obj);
3119 /* copy constructor */
3120 memset(&ios_obj, 0xcd, sizeof(ios));
3121 call_func2(p_ios_copy_ctor, &ios_obj, &ios_obj2);
3122 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3123 ok(ios_obj.state == (ios_obj2.state|IOSTATE_badbit), "expected %x got %x\n",
3124 ios_obj2.state|IOSTATE_badbit, ios_obj.state);
3125 ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
3126 ok(ios_obj.tie == ios_obj2.tie, "expected %p got %p\n", ios_obj2.tie, ios_obj.tie);
3127 ok(ios_obj.flags == ios_obj2.flags, "expected %x got %x\n", ios_obj2.flags, ios_obj.flags);
3128 ok(ios_obj.precision == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.precision);
3129 ok(ios_obj.fill == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.fill);
3130 ok(ios_obj.width == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.width);
3131 ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
3132 ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
3134 /* assignment */
3135 ios_obj.state = 0xcdcdcdcd;
3136 ios_obj.delbuf = 0xcdcdcdcd;
3137 ios_obj.tie = (ostream*) 0xcdcdcdcd;
3138 ios_obj.flags = 0xcdcdcdcd;
3139 ios_obj.precision = 0xcdcdcdcd;
3140 ios_obj.fill = 0xcd;
3141 ios_obj.width = 0xcdcdcdcd;
3142 ios_obj.do_lock = 0xcdcdcdcd;
3143 call_func2(p_ios_assign, &ios_obj, &ios_obj2);
3144 ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
3145 ok(ios_obj.state == (ios_obj2.state|IOSTATE_badbit), "expected %x got %x\n",
3146 ios_obj2.state|IOSTATE_badbit, ios_obj.state);
3147 ok(ios_obj.delbuf == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios_obj.delbuf);
3148 ok(ios_obj.tie == ios_obj2.tie, "expected %p got %p\n", ios_obj2.tie, ios_obj.tie);
3149 ok(ios_obj.flags == ios_obj2.flags, "expected %x got %x\n", ios_obj2.flags, ios_obj.flags);
3150 ok(ios_obj.precision == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.precision);
3151 ok(ios_obj.fill == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.fill);
3152 ok(ios_obj.width == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.width);
3153 ok(ios_obj.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios_obj.do_lock);
3155 /* locking */
3156 ios_obj.sb = psb;
3157 ios_obj.do_lock = 1;
3158 ios_obj.sb->do_lock = 0;
3159 p_ios_clrlock(&ios_obj);
3160 ok(ios_obj.do_lock == 1, "expected 1 got %d\n", ios_obj.do_lock);
3161 ok(ios_obj.sb->do_lock == 1, "expected 1 got %d\n", ios_obj.sb->do_lock);
3162 ios_obj.do_lock = 0;
3163 p_ios_clrlock(&ios_obj);
3164 ok(ios_obj.do_lock == 1, "expected 1 got %d\n", ios_obj.do_lock);
3165 ok(ios_obj.sb->do_lock == 1, "expected 1 got %d\n", ios_obj.sb->do_lock);
3166 p_ios_setlock(&ios_obj);
3167 ok(ios_obj.do_lock == 0, "expected 0 got %d\n", ios_obj.do_lock);
3168 ok(ios_obj.sb->do_lock == 0, "expected 0 got %d\n", ios_obj.sb->do_lock);
3169 ios_obj.do_lock = -1;
3170 p_ios_setlock(&ios_obj);
3171 ok(ios_obj.do_lock == -2, "expected -2 got %d\n", ios_obj.do_lock);
3172 ok(ios_obj.sb->do_lock == -1, "expected -1 got %d\n", ios_obj.sb->do_lock);
3174 lock_arg.ios_obj = &ios_obj;
3175 lock_arg.lock = CreateEventW(NULL, FALSE, FALSE, NULL);
3176 ok(lock_arg.lock != NULL, "CreateEventW failed\n");
3177 lock_arg.release[0] = CreateEventW(NULL, FALSE, FALSE, NULL);
3178 ok(lock_arg.release[0] != NULL, "CreateEventW failed\n");
3179 lock_arg.release[1] = CreateEventW(NULL, FALSE, FALSE, NULL);
3180 ok(lock_arg.release[1] != NULL, "CreateEventW failed\n");
3181 lock_arg.release[2] = CreateEventW(NULL, FALSE, FALSE, NULL);
3182 ok(lock_arg.release[2] != NULL, "CreateEventW failed\n");
3183 thread = CreateThread(NULL, 0, lock_ios, (void*)&lock_arg, 0, NULL);
3184 ok(thread != NULL, "CreateThread failed\n");
3185 WaitForSingleObject(lock_arg.lock, INFINITE);
3187 locked = TryEnterCriticalSection(&ios_obj.lock);
3188 ok(locked == 0, "the ios object was not locked before\n");
3189 locked = TryEnterCriticalSection(&ios_obj.sb->lock);
3190 ok(locked == 0, "the streambuf was not locked before\n");
3191 locked = TryEnterCriticalSection(p_ios_static_lock);
3192 ok(locked == 0, "the static critical section was not locked before\n");
3194 /* flags */
3195 ios_obj.flags = 0x8000;
3196 ret = (LONG) call_func1(p_ios_flags_get, &ios_obj);
3197 ok(ret == 0x8000, "expected 0x8000 got %lx\n", ret);
3198 ret = (LONG) call_func2(p_ios_flags_set, &ios_obj, 0x444);
3199 ok(ret == 0x8000, "expected 0x8000 got %lx\n", ret);
3200 ok(ios_obj.flags == 0x444, "expected 0x444 got %x\n", ios_obj.flags);
3201 ret = (LONG) call_func2(p_ios_flags_set, &ios_obj, 0);
3202 ok(ret == 0x444, "expected 0x444 got %lx\n", ret);
3203 ok(ios_obj.flags == 0, "expected %x got %x\n", 0, ios_obj.flags);
3205 /* setf */
3206 ios_obj.do_lock = 0;
3207 ios_obj.flags = 0x8400;
3208 ret = (LONG) call_func2(p_ios_setf, &ios_obj, 0x444);
3209 ok(ret == 0x8400, "expected 0x8400 got %lx\n", ret);
3210 ok(ios_obj.flags == 0x8444, "expected 0x8444 got %x\n", ios_obj.flags);
3211 ret = (LONG) call_func3(p_ios_setf_mask, &ios_obj, 0x111, 0);
3212 ok(ret == 0x8444, "expected 0x8444 got %lx\n", ret);
3213 ok(ios_obj.flags == 0x8444, "expected 0x8444 got %x\n", ios_obj.flags);
3214 ret = (LONG) call_func3(p_ios_setf_mask, &ios_obj, 0x111, 0x105);
3215 ok(ret == 0x8444, "expected 0x8444 got %lx\n", ret);
3216 ok(ios_obj.flags == 0x8541, "expected 0x8541 got %x\n", ios_obj.flags);
3218 /* unsetf */
3219 ret = (LONG) call_func2(p_ios_unsetf, &ios_obj, 0x1111);
3220 ok(ret == 0x8541, "expected 0x8541 got %lx\n", ret);
3221 ok(ios_obj.flags == 0x8440, "expected 0x8440 got %x\n", ios_obj.flags);
3222 ret = (LONG) call_func2(p_ios_unsetf, &ios_obj, 0x8008);
3223 ok(ret == 0x8440, "expected 0x8440 got %lx\n", ret);
3224 ok(ios_obj.flags == 0x440, "expected 0x440 got %x\n", ios_obj.flags);
3225 ios_obj.do_lock = -1;
3227 /* state */
3228 ios_obj.state = 0x8;
3229 ret = (LONG) call_func1(p_ios_good, &ios_obj);
3230 ok(ret == 0, "expected 0 got %ld\n", ret);
3231 ios_obj.state = IOSTATE_goodbit;
3232 ret = (LONG) call_func1(p_ios_good, &ios_obj);
3233 ok(ret == 1, "expected 1 got %ld\n", ret);
3234 ret = (LONG) call_func1(p_ios_bad, &ios_obj);
3235 ok(ret == 0, "expected 0 got %ld\n", ret);
3236 ios_obj.state = (IOSTATE_eofbit|IOSTATE_badbit);
3237 ret = (LONG) call_func1(p_ios_bad, &ios_obj);
3238 ok(ret == IOSTATE_badbit, "expected 4 got %ld\n", ret);
3239 ret = (LONG) call_func1(p_ios_eof, &ios_obj);
3240 ok(ret == IOSTATE_eofbit, "expected 1 got %ld\n", ret);
3241 ios_obj.state = 0x8;
3242 ret = (LONG) call_func1(p_ios_eof, &ios_obj);
3243 ok(ret == 0, "expected 0 got %ld\n", ret);
3244 ret = (LONG) call_func1(p_ios_fail, &ios_obj);
3245 ok(ret == 0, "expected 0 got %ld\n", ret);
3246 ios_obj.state = IOSTATE_badbit;
3247 ret = (LONG) call_func1(p_ios_fail, &ios_obj);
3248 ok(ret == IOSTATE_badbit, "expected 4 got %ld\n", ret);
3249 ios_obj.state = (IOSTATE_eofbit|IOSTATE_failbit);
3250 ret = (LONG) call_func1(p_ios_fail, &ios_obj);
3251 ok(ret == IOSTATE_failbit, "expected 2 got %ld\n", ret);
3252 ios_obj.state = (IOSTATE_eofbit|IOSTATE_failbit|IOSTATE_badbit);
3253 ret = (LONG) call_func1(p_ios_fail, &ios_obj);
3254 ok(ret == (IOSTATE_failbit|IOSTATE_badbit), "expected 6 got %ld\n", ret);
3255 ios_obj.do_lock = 0;
3256 call_func2(p_ios_clear, &ios_obj, 0);
3257 ok(ios_obj.state == IOSTATE_goodbit, "expected 0 got %d\n", ios_obj.state);
3258 call_func2(p_ios_clear, &ios_obj, 0x8|IOSTATE_eofbit);
3259 ok(ios_obj.state == (0x8|IOSTATE_eofbit), "expected 9 got %d\n", ios_obj.state);
3260 ios_obj.do_lock = -1;
3262 SetEvent(lock_arg.release[0]);
3264 /* bitalloc */
3265 expected = 0x10000;
3266 for (i = 0; i < 20; i++) {
3267 ret = p_ios_bitalloc();
3268 ok(ret == expected, "expected %lx got %lx\n", expected, ret);
3269 ok(*p_ios_maxbit == expected, "expected %lx got %lx\n", expected, *p_ios_maxbit);
3270 expected <<= 1;
3273 /* xalloc/pword/iword */
3274 ok(*p_ios_curindex == -1, "expected -1 got %d\n", *p_ios_curindex);
3275 expected = 0;
3276 for (i = 0; i < 8; i++) {
3277 ret = p_ios_xalloc();
3278 ok(ret == expected, "expected %ld got %ld\n", expected, ret);
3279 ok(*p_ios_curindex == expected, "expected %ld got %d\n", expected, *p_ios_curindex);
3280 pret = call_func2(p_ios_iword, &ios_obj, ret);
3281 ok(pret == &p_ios_statebuf[ret], "expected %p got %p\n", &p_ios_statebuf[ret], pret);
3282 ok(*pret == 0, "expected 0 got %ld\n", *pret);
3283 pret2 = call_func2(p_ios_pword, &ios_obj, ret);
3284 ok(pret2 == (void**)&p_ios_statebuf[ret], "expected %p got %p\n", (void**)&p_ios_statebuf[ret], pret2);
3285 expected++;
3287 ret = p_ios_xalloc();
3288 ok(ret == -1, "expected -1 got %ld\n", ret);
3289 ok(*p_ios_curindex == 7, "expected 7 got %d\n", *p_ios_curindex);
3291 SetEvent(lock_arg.release[1]);
3292 SetEvent(lock_arg.release[2]);
3293 WaitForSingleObject(thread, INFINITE);
3295 ios_obj.delbuf = 1;
3296 call_func1(p_ios_dtor, &ios_obj);
3297 ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
3298 ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
3299 CloseHandle(lock_arg.lock);
3300 CloseHandle(lock_arg.release[0]);
3301 CloseHandle(lock_arg.release[1]);
3302 CloseHandle(lock_arg.release[2]);
3303 CloseHandle(thread);
3306 static void test_ostream(void) {
3307 ostream os1, os2, *pos;
3308 filebuf fb1, fb2, *pfb;
3309 const char filename1[] = "test1";
3310 const char filename2[] = "test2";
3311 int fd, ret;
3313 memset(&os1, 0xab, sizeof(ostream));
3314 memset(&os2, 0xab, sizeof(ostream));
3315 memset(&fb1, 0xab, sizeof(filebuf));
3316 memset(&fb2, 0xab, sizeof(filebuf));
3318 /* constructors/destructors */
3319 pos = call_func2(p_ostream_ctor, &os1, TRUE);
3320 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3321 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
3322 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
3323 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
3324 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3325 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
3326 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
3327 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
3328 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
3329 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3330 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
3331 call_func1(p_ostream_vbase_dtor, &os1);
3332 memset(&os1, 0xab, sizeof(ostream));
3333 pos = call_func3(p_ostream_sb_ctor, &os1, &fb1.base, TRUE);
3334 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3335 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
3336 ok(os1.base_ios.sb == &fb1.base, "expected %p got %p\n", &fb1.base, os1.base_ios.sb);
3337 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3338 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3339 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
3340 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
3341 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
3342 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
3343 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3344 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
3345 ok(fb1.base.allocated == 0xabababab, "expected %d got %d\n", 0xabababab, fb1.base.allocated);
3346 call_func1(p_ostream_vbase_dtor, &os1);
3347 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
3348 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
3349 memset(&os1.base_ios, 0xab, sizeof(ios));
3350 os1.unknown = 0xabababab;
3351 os1.base_ios.state = 0xabababab | IOSTATE_badbit;
3352 pos = call_func2(p_ostream_ctor, &os1, FALSE);
3353 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3354 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
3355 ok(os1.base_ios.sb == os2.base_ios.sb, "expected %p got %p\n", os2.base_ios.sb, os1.base_ios.sb);
3356 ok(os1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
3357 0xabababab|IOSTATE_badbit, os1.base_ios.state);
3358 ok(os1.base_ios.delbuf == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.delbuf);
3359 ok(os1.base_ios.tie == os2.base_ios.tie, "expected %p got %p\n", os2.base_ios.tie, os1.base_ios.tie);
3360 ok(os1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os1.base_ios.flags);
3361 ok(os1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.precision);
3362 ok(os1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os1.base_ios.fill);
3363 ok(os1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.width);
3364 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
3365 call_func1(p_ostream_dtor, &os1.base_ios);
3366 os1.unknown = 0xabababab;
3367 os1.base_ios.delbuf = 0;
3368 call_func1(p_filebuf_ctor, &fb1);
3369 pfb = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_out, filebuf_openprot);
3370 ok(pfb == &fb1, "wrong return, expected %p got %p\n", &fb1, pfb);
3371 ok(fb1.base.allocated == 1, "expected %d got %d\n", 1, fb1.base.allocated);
3372 pos = call_func3(p_ostream_sb_ctor, &os1, &fb1.base, FALSE);
3373 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3374 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
3375 ok(os1.base_ios.sb == &fb1.base, "expected %p got %p\n", &fb1.base, os1.base_ios.sb);
3376 ok(os1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.state);
3377 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3378 ok(os1.base_ios.tie == os2.base_ios.tie, "expected %p got %p\n", os2.base_ios.tie, os1.base_ios.tie);
3379 ok(os1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os1.base_ios.flags);
3380 ok(os1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.precision);
3381 ok(os1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os1.base_ios.fill);
3382 ok(os1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.width);
3383 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
3384 call_func1(p_ostream_dtor, &os1.base_ios);
3385 memset(&os1, 0xab, sizeof(ostream));
3386 pos = call_func3(p_ostream_sb_ctor, &os1, NULL, TRUE);
3387 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3388 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
3389 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
3390 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
3391 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3392 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
3393 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
3394 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
3395 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
3396 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3397 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
3398 call_func1(p_ostream_vbase_dtor, &os1);
3399 memset(&os1.base_ios, 0xcd, sizeof(ios));
3400 os1.unknown = 0xcdcdcdcd;
3401 pos = call_func3(p_ostream_copy_ctor, &os2, &os1, TRUE);
3402 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
3403 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
3404 ok(os2.base_ios.sb == os1.base_ios.sb, "expected %p got %p\n", os1.base_ios.sb, os2.base_ios.sb);
3405 ok(os2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os2.base_ios.state);
3406 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
3407 ok(os2.base_ios.tie == NULL, "expected %p got %p\n", NULL, os2.base_ios.tie);
3408 ok(os2.base_ios.flags == 0, "expected 0 got %x\n", os2.base_ios.flags);
3409 ok(os2.base_ios.precision == 6, "expected 6 got %d\n", os2.base_ios.precision);
3410 ok(os2.base_ios.fill == ' ', "expected 32 got %d\n", os2.base_ios.fill);
3411 ok(os2.base_ios.width == 0, "expected 0 got %d\n", os2.base_ios.width);
3412 ok(os2.base_ios.do_lock == -1, "expected -1 got %d\n", os2.base_ios.do_lock);
3413 call_func1(p_ostream_vbase_dtor, &os2);
3414 memset(&os2.base_ios, 0xab, sizeof(ios));
3415 os2.unknown = 0xabababab;
3416 os2.base_ios.state = 0xabababab | IOSTATE_badbit;
3417 os2.base_ios.delbuf = 0;
3418 os2.base_ios.tie = &os2;
3419 pos = call_func3(p_ostream_copy_ctor, &os2, &os1, FALSE);
3420 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
3421 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
3422 ok(os2.base_ios.sb == os1.base_ios.sb, "expected %p got %p\n", os1.base_ios.sb, os2.base_ios.sb);
3423 ok(os2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.state);
3424 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
3425 ok(os2.base_ios.tie == &os2, "expected %p got %p\n", &os2, os2.base_ios.tie);
3426 ok(os2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os2.base_ios.flags);
3427 ok(os2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.precision);
3428 ok(os2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os2.base_ios.fill);
3429 ok(os2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.width);
3430 ok(os2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.do_lock);
3431 call_func1(p_ostream_dtor, &os2.base_ios);
3432 os1.base_ios.sb = NULL;
3433 pos = call_func3(p_ostream_copy_ctor, &os2, &os1, TRUE);
3434 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
3435 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
3436 ok(os2.base_ios.sb == NULL, "expected %p got %p\n", NULL, os2.base_ios.sb);
3437 ok(os2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os2.base_ios.state);
3438 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
3439 ok(os2.base_ios.tie == NULL, "expected %p got %p\n", NULL, os2.base_ios.tie);
3440 ok(os2.base_ios.flags == 0, "expected 0 got %x\n", os2.base_ios.flags);
3441 ok(os2.base_ios.precision == 6, "expected 6 got %d\n", os2.base_ios.precision);
3442 ok(os2.base_ios.fill == ' ', "expected 32 got %d\n", os2.base_ios.fill);
3443 ok(os2.base_ios.width == 0, "expected 0 got %d\n", os2.base_ios.width);
3444 ok(os2.base_ios.do_lock == -1, "expected -1 got %d\n", os2.base_ios.do_lock);
3446 /* assignment */
3447 pos = call_func2(p_ostream_ctor, &os1, TRUE);
3448 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3449 os1.unknown = 0xabababab;
3450 os1.base_ios.state = 0xabababab;
3451 os1.base_ios.special[0] = 0xabababab;
3452 os1.base_ios.delbuf = 0xabababab;
3453 os1.base_ios.tie = (ostream*) 0xabababab;
3454 os1.base_ios.flags = 0xabababab;
3455 os1.base_ios.precision = 0xabababab;
3456 os1.base_ios.width = 0xabababab;
3457 os1.base_ios.do_lock = 0xabababab;
3458 pos = call_func2(p_ostream_assign_sb, &os1, &fb1.base);
3459 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3460 ok(os1.unknown == 0xabababab, "expected 0 got %d\n", os1.unknown);
3461 ok(os1.base_ios.sb == &fb1.base, "expected %p got %p\n", &fb1.base, os1.base_ios.sb);
3462 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3463 ok(os1.base_ios.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.fill);
3464 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3465 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
3466 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
3467 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
3468 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3469 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
3470 os1.base_ios.state = 0x8000;
3471 pos = call_func2(p_ostream_assign_sb, &os1, NULL);
3472 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3473 ok(os1.unknown == 0xabababab, "expected 0 got %d\n", os1.unknown);
3474 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
3475 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
3476 ok(os1.base_ios.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.fill);
3477 ok(os1.base_ios.delbuf == 0, "expected 0 got %d\n", os1.base_ios.delbuf);
3478 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
3479 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
3480 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
3481 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3482 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
3483 os2.unknown = 0xcdcdcdcd;
3484 os2.base_ios.state = 0xcdcdcdcd;
3485 os2.base_ios.special[0] = 0xcdcdcdcd;
3486 os2.base_ios.delbuf = 0xcdcdcdcd;
3487 os2.base_ios.tie = (ostream*) 0xcdcdcdcd;
3488 os2.base_ios.flags = 0xcdcdcdcd;
3489 os2.base_ios.precision = 0xcdcdcdcd;
3490 os2.base_ios.width = 0xcdcdcdcd;
3491 os2.base_ios.do_lock = 0xcdcdcdcd;
3492 pos = call_func2(p_ostream_assign, &os2, &os1);
3493 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
3494 ok(os2.unknown == 0xcdcdcdcd, "expected 0 got %d\n", os2.unknown);
3495 ok(os2.base_ios.sb == NULL, "expected %p got %p\n", NULL, os2.base_ios.sb);
3496 ok(os2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os2.base_ios.state);
3497 ok(os2.base_ios.special[0] == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, os2.base_ios.fill);
3498 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
3499 ok(os2.base_ios.tie == NULL, "expected %p got %p\n", NULL, os2.base_ios.tie);
3500 ok(os2.base_ios.flags == 0, "expected 0 got %x\n", os2.base_ios.flags);
3501 ok(os2.base_ios.precision == 6, "expected 6 got %d\n", os2.base_ios.precision);
3502 ok(os2.base_ios.width == 0, "expected 0 got %d\n", os2.base_ios.width);
3503 ok(os2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, os2.base_ios.do_lock);
3505 /* flush */
3506 if (0) /* crashes on native */
3507 pos = call_func1(p_ostream_flush, &os1);
3508 os1.base_ios.sb = &fb2.base;
3509 call_func1(p_filebuf_ctor, &fb2);
3510 pos = call_func1(p_ostream_flush, &os1);
3511 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3512 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3513 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3514 os1.base_ios.sb = &fb1.base;
3515 os1.base_ios.state = IOSTATE_eofbit;
3516 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "Never gonna tell a lie", 22);
3517 ok(ret == 22, "expected 22 got %d\n", ret);
3518 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3519 ok(fb1.base.pptr == fb1.base.base + 22, "wrong put pointer, expected %p got %p\n", fb1.base.base + 22, fb1.base.pptr);
3520 pos = call_func1(p_ostream_flush, &os1);
3521 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3522 ok(os1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, os1.base_ios.state);
3523 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3524 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3525 os1.base_ios.tie = &os2;
3526 os2.base_ios.sb = &fb2.base;
3527 os2.base_ios.state = IOSTATE_goodbit;
3528 pfb = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_out, filebuf_openprot);
3529 ok(pfb == &fb2, "wrong return, expected %p got %p\n", &fb2, pfb);
3530 ret = (int) call_func3(p_streambuf_xsputn, &fb2.base, "and hurt you", 12);
3531 ok(ret == 12, "expected 12 got %d\n", ret);
3532 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
3533 ok(fb2.base.pptr == fb2.base.base + 12, "wrong put pointer, expected %p got %p\n", fb2.base.base + 12, fb2.base.pptr);
3534 pos = call_func1(p_ostream_flush, &os1);
3535 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3536 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
3537 ok(fb2.base.pptr == fb2.base.base + 12, "wrong put pointer, expected %p got %p\n", fb2.base.base + 12, fb2.base.pptr);
3539 /* opfx */
3540 ret = (int) call_func1(p_ostream_opfx, &os1);
3541 ok(ret == 0, "expected 0 got %d\n", ret);
3542 ok(os1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
3543 IOSTATE_eofbit|IOSTATE_failbit, os1.base_ios.state);
3544 os1.base_ios.state = IOSTATE_badbit;
3545 ret = (int) call_func1(p_ostream_opfx, &os1);
3546 ok(ret == 0, "expected 0 got %d\n", ret);
3547 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3548 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3549 os1.base_ios.sb = &fb1.base;
3550 os1.base_ios.state = IOSTATE_badbit;
3551 ret = (int) call_func1(p_ostream_opfx, &os1);
3552 ok(ret == 0, "expected 0 got %d\n", ret);
3553 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3554 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3555 os1.base_ios.state = IOSTATE_failbit;
3556 ret = (int) call_func1(p_ostream_opfx, &os1);
3557 ok(ret == 0, "expected 0 got %d\n", ret);
3558 ok(os1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, os1.base_ios.state);
3559 os1.base_ios.state = IOSTATE_goodbit;
3560 os1.base_ios.tie = &os2;
3561 os2.base_ios.sb = NULL;
3562 if (0) /* crashes on native */
3563 ret = (int) call_func1(p_ostream_opfx, &os1);
3564 os2.base_ios.sb = &fb2.base;
3565 os2.base_ios.state = IOSTATE_badbit;
3566 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "We've known each other", 22);
3567 ok(ret == 22, "expected 22 got %d\n", ret);
3568 ret = (int) call_func1(p_ostream_opfx, &os1);
3569 ok(ret == 1, "expected 1 got %d\n", ret);
3570 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3571 ok(os2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os2.base_ios.state);
3572 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3573 ok(fb1.base.pptr == fb1.base.base + 22, "wrong put pointer, expected %p got %p\n", fb1.base.base + 22, fb1.base.pptr);
3574 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
3575 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
3577 /* osfx */
3578 os1.base_ios.state = IOSTATE_badbit;
3579 os1.base_ios.width = 0xab;
3580 call_func1(p_ostream_osfx, &os1);
3581 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
3582 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3583 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3584 ok(fb1.base.pptr == fb1.base.base + 22, "wrong put pointer, expected %p got %p\n", fb1.base.base + 22, fb1.base.pptr);
3585 os1.base_ios.state = IOSTATE_goodbit;
3586 ret = (int) call_func1(p_ostream_opfx, &os1);
3587 ok(ret == 1, "expected 1 got %d\n", ret);
3588 os1.base_ios.sb = NULL;
3589 if (0) /* crashes on native */
3590 call_func1(p_ostream_osfx, &os1);
3591 os1.base_ios.sb = &fb1.base;
3592 os1.base_ios.flags = FLAGS_unitbuf;
3593 call_func1(p_ostream_osfx, &os1);
3594 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3595 ok(os1.base_ios.flags == FLAGS_unitbuf, "expected %d got %d\n", FLAGS_unitbuf, os1.base_ios.flags);
3596 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3597 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3599 /* put */
3600 ret = (int) call_func3(p_streambuf_xsputn, &fb2.base, "for so long", 11);
3601 ok(ret == 11, "expected 11 got %d\n", ret);
3602 os1.base_ios.state = IOSTATE_badbit;
3603 os1.base_ios.width = 2;
3604 pos = call_func2(p_ostream_put_char, &os1, 'a');
3605 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3606 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3607 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3608 ok(os1.base_ios.width == 2, "expected 2 got %d\n", os1.base_ios.width);
3609 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3610 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3611 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
3612 ok(fb2.base.pptr == fb2.base.base + 11, "wrong put pointer, expected %p got %p\n", fb2.base.base + 11, fb2.base.pptr);
3613 os1.base_ios.state = IOSTATE_goodbit;
3614 pos = call_func2(p_ostream_put_char, &os1, 'a');
3615 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3616 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3617 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3618 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3619 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3620 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
3621 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
3622 os1.base_ios.flags = 0;
3623 pos = call_func2(p_ostream_put_char, &os1, 'b');
3624 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3625 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3626 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3627 ok(fb1.base.pptr == fb1.base.base + 1, "wrong put pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.pptr);
3628 os1.base_ios.sb = NULL;
3629 if (0) /* crashes on native */
3630 pos = call_func2(p_ostream_put_char, &os1, 'c');
3631 os1.base_ios.sb = &fb1.base;
3632 os1.base_ios.width = 5;
3633 call_func1(p_filebuf_sync, &fb1);
3634 fd = fb1.fd;
3635 fb1.fd = -1;
3636 pos = call_func2(p_ostream_put_char, &os1, 'c');
3637 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3638 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3639 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3640 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3641 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3642 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3643 fb1.fd = fd;
3645 /* write */
3646 pos = call_func3(p_ostream_write_char, &os1, "Your", 4);
3647 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3648 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3649 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3650 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3651 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3652 os1.base_ios.state = IOSTATE_goodbit;
3653 os1.base_ios.width = 1;
3654 pos = call_func3(p_ostream_write_char, &os1, "heart's", 7);
3655 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3656 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3657 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3658 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3659 ok(fb1.base.pptr == fb1.base.base + 7, "wrong put pointer, expected %p got %p\n", fb1.base.base + 7, fb1.base.pptr);
3660 os1.base_ios.sb = NULL;
3661 if (0) /* crashes on native */
3662 pos = call_func3(p_ostream_write_char, &os1, "been", 4);
3663 os1.base_ios.sb = &fb1.base;
3664 os1.base_ios.width = 5;
3665 call_func1(p_filebuf_sync, &fb1);
3666 fd = fb1.fd;
3667 fb1.fd = -1;
3668 pos = call_func3(p_ostream_write_char, &os1, "aching,", 7);
3669 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3670 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3671 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3672 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
3673 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3674 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3675 fb1.fd = fd;
3677 /* seekp */
3678 os1.base_ios.state = IOSTATE_eofbit;
3679 pos = call_func3(p_ostream_seekp_offset, &os1, 0, SEEKDIR_beg);
3680 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3681 ok(os1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, os1.base_ios.state);
3682 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "but", 3);
3683 ok(ret == 3, "expected 3 got %d\n", ret);
3684 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3685 ok(fb1.base.pptr == fb1.base.base + 3, "wrong put pointer, expected %p got %p\n", fb1.base.base + 3, fb1.base.pptr);
3686 pos = call_func3(p_ostream_seekp_offset, &os1, 0, SEEKDIR_end);
3687 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3688 ok(os1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, os1.base_ios.state);
3689 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3690 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3691 pos = call_func3(p_ostream_seekp_offset, &os1, -1, SEEKDIR_beg);
3692 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3693 ok(os1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
3694 IOSTATE_eofbit|IOSTATE_failbit, os1.base_ios.state);
3695 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "You're too shy", 14);
3696 ok(ret == 14, "expected 14 got %d\n", ret);
3697 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3698 ok(fb1.base.pptr == fb1.base.base + 14, "wrong put pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.pptr);
3699 pos = call_func2(p_ostream_seekp, &os1, 0);
3700 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3701 ok(os1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
3702 IOSTATE_eofbit|IOSTATE_failbit, os1.base_ios.state);
3703 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3704 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3705 os1.base_ios.state = IOSTATE_badbit;
3706 pos = call_func2(p_ostream_seekp, &os1, -1);
3707 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3708 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3709 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3711 /* tellp */
3712 ret = (int) call_func1(p_ostream_tellp, &os1);
3713 ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
3714 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3715 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3716 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "to say it", 9);
3717 ok(ret == 9, "expected 9 got %d\n", ret);
3718 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
3719 ok(fb1.base.pptr == fb1.base.base + 9, "wrong put pointer, expected %p got %p\n", fb1.base.base + 9, fb1.base.pptr);
3720 ret = (int) call_func1(p_ostream_tellp, &os1);
3721 ok(ret == 9, "wrong return, expected 9 got %d\n", ret);
3722 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3723 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3724 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
3725 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
3726 os1.base_ios.state = IOSTATE_eofbit;
3727 fd = fb1.fd;
3728 fb1.fd = -1;
3729 ret = (int) call_func1(p_ostream_tellp, &os1);
3730 ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
3731 ok(os1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
3732 IOSTATE_eofbit|IOSTATE_failbit, os1.base_ios.state);
3733 fb1.fd = fd;
3735 /* writepad */
3736 os1.base_ios.state = IOSTATE_eofbit;
3737 os1.base_ios.flags =
3738 FLAGS_right|FLAGS_hex|FLAGS_showbase|FLAGS_showpoint|FLAGS_showpos|FLAGS_uppercase|FLAGS_fixed;
3739 os1.base_ios.fill = 'z';
3740 os1.base_ios.width = 9;
3741 pos = call_func3(p_ostream_writepad, &os1, "a", "b");
3742 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3743 ok(!strncmp(fb1.base.pptr - 9, "zzzzzzzab", 9), "expected 'zzzzzzzab' got '%s'\n", fb1.base.pptr - 9);
3744 pos = call_func3(p_ostream_writepad, &os1, "aa", "bb");
3745 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3746 ok(!strncmp(fb1.base.pptr - 9, "zzzzzaabb", 9), "expected 'zzzzzaabb' got '%s'\n", fb1.base.pptr - 9);
3747 pos = call_func3(p_ostream_writepad, &os1, "aaaaa", "bbbbb");
3748 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3749 ok(!strncmp(fb1.base.pptr - 10, "aaaaabbbbb", 10), "expected 'aaaaabbbbb' got '%s'\n", fb1.base.pptr - 10);
3750 os1.base_ios.flags |= FLAGS_internal;
3751 pos = call_func3(p_ostream_writepad, &os1, "aa", "bb");
3752 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3753 ok(!strncmp(fb1.base.pptr - 9, "aazzzzzbb", 9), "expected 'aazzzzzbb' got '%s'\n", fb1.base.pptr - 9);
3754 os1.base_ios.flags &= ~FLAGS_right;
3755 pos = call_func3(p_ostream_writepad, &os1, "a", "b");
3756 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3757 ok(!strncmp(fb1.base.pptr - 9, "azzzzzzzb", 9), "expected 'azzzzzzzb' got '%s'\n", fb1.base.pptr - 9);
3758 os1.base_ios.width = 6;
3759 pos = call_func3(p_ostream_writepad, &os1, "1", "2");
3760 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3761 ok(!strncmp(fb1.base.pptr - 6, "1zzzz2", 6), "expected '1zzzz2' got '%s'\n", fb1.base.pptr - 6);
3762 pos = call_func3(p_ostream_writepad, &os1, "12345678", "");
3763 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3764 ok(!strncmp(fb1.base.pptr - 8, "12345678", 8), "expected '12345678' got '%s'\n", fb1.base.pptr - 8);
3765 os1.base_ios.flags |= FLAGS_left;
3766 pos = call_func3(p_ostream_writepad, &os1, "z1", "2z");
3767 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3768 ok(!strncmp(fb1.base.pptr - 6, "z1zz2z", 6), "expected 'z1zz2z' got '%s'\n", fb1.base.pptr - 6);
3769 os1.base_ios.flags &= ~FLAGS_internal;
3770 pos = call_func3(p_ostream_writepad, &os1, "hell", "o");
3771 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3772 ok(!strncmp(fb1.base.pptr - 6, "helloz", 6), "expected 'helloz' got '%s'\n", fb1.base.pptr - 6);
3773 os1.base_ios.flags |= FLAGS_right;
3774 pos = call_func3(p_ostream_writepad, &os1, "a", "b");
3775 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3776 ok(!strncmp(fb1.base.pptr - 6, "abzzzz", 6), "expected 'abzzzz' got '%s'\n", fb1.base.pptr - 6);
3777 if (0) /* crashes on native */
3778 pos = call_func3(p_ostream_writepad, &os1, NULL, "o");
3779 pos = call_func3(p_ostream_writepad, &os1, "", "hello");
3780 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3781 ok(!strncmp(fb1.base.pptr - 6, "helloz", 6), "expected 'helloz' got '%s'\n", fb1.base.pptr - 6);
3782 os1.base_ios.fill = '*';
3783 pos = call_func3(p_ostream_writepad, &os1, "", "");
3784 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3785 ok(!strncmp(fb1.base.pptr - 6, "******", 6), "expected '******' got '%s'\n", fb1.base.pptr - 6);
3786 pos = call_func3(p_ostream_writepad, &os1, "aa", "");
3787 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3788 ok(!strncmp(fb1.base.pptr - 6, "aa****", 6), "expected 'aa****' got '%s'\n", fb1.base.pptr - 6);
3789 os1.base_ios.flags = 0;
3790 pos = call_func3(p_ostream_writepad, &os1, "a", "b");
3791 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3792 ok(!strncmp(fb1.base.pptr - 6, "****ab", 6), "expected '****ab' got '%s'\n", fb1.base.pptr - 6);
3793 call_func1(p_filebuf_sync, &fb1);
3794 fb1.fd = -1;
3795 pos = call_func3(p_ostream_writepad, &os1, "aa", "bb");
3796 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3797 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit), "expected %d got %d\n",
3798 IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit, os1.base_ios.state);
3799 os1.base_ios.state = IOSTATE_goodbit;
3800 pos = call_func3(p_ostream_writepad, &os1, "", "");
3801 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3802 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3803 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3804 os1.base_ios.state = IOSTATE_goodbit;
3805 os1.base_ios.width = 0;
3806 pos = call_func3(p_ostream_writepad, &os1, "", "");
3807 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3808 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
3809 pos = call_func3(p_ostream_writepad, &os1, "a", "");
3810 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
3811 ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
3812 IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
3813 fb1.fd = fd;
3815 call_func1(p_ostream_vbase_dtor, &os1);
3816 call_func1(p_ostream_vbase_dtor, &os2);
3817 call_func1(p_filebuf_dtor, &fb1);
3818 call_func1(p_filebuf_dtor, &fb2);
3819 ok(_unlink(filename1) == 0, "Couldn't unlink file named '%s'\n", filename1);
3820 ok(_unlink(filename2) == 0, "Couldn't unlink file named '%s'\n", filename2);
3823 static void test_ostream_print(void)
3825 const BOOL is_64 = (sizeof(void*) == 8);
3826 ostream os, *pos;
3827 strstreambuf ssb, ssb_test1, ssb_test2, ssb_test3, *pssb;
3828 LONG length, expected_length;
3829 int ret, i;
3831 char param_char[] = {'a', '9', 'e'};
3832 const char* param_str[] = {"Test", "800", "3.14159", " Test"};
3833 int param_int[] = {0, 7, 10, 24 ,55, 1024, 1023, 65536, 2147483647, 2147483648u, 4294967295u, -20};
3834 float param_float[] = {1.0f, 0.0f, 4.25f, 3.999f, 12.0005f, 15.33582f, 15.0f, 15.22f, 21.123f, 0.1f,
3835 13.14159f, 0.00013f, 0.000013f, INFINITY, -INFINITY, NAN};
3836 double param_double[] = {1.0, 3.141592653589793238, 314.1592653589793238, 314.159265358979,
3837 1231314.269811862199, 9.961472e6, 8.98846567431e307, DBL_MAX};
3838 void* param_ptr[] = {NULL, (void*) 0xdeadbeef, (void*) 0x1234cdef, (void*) 0x1, (void*) 0xffffffff};
3839 streambuf* param_streambuf[] = {NULL, &ssb_test1.base, &ssb_test2.base, &ssb_test3.base};
3840 struct ostream_print_test {
3841 enum { type_chr, type_str, type_int, type_flt, type_dbl, type_ptr, type_sbf } type;
3842 int param_index;
3843 ios_io_state state;
3844 ios_flags flags;
3845 int precision;
3846 int fill;
3847 int width;
3848 const char *expected_text;
3849 ios_io_state expected_flags;
3850 } tests[] = {
3851 /* char */
3852 {type_chr, /* 'a' */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3853 {type_chr, /* 'a' */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
3854 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, 0, 6, ' ', 0, "a", IOSTATE_goodbit},
3855 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, 0, 6, ' ', 4, " a", IOSTATE_goodbit},
3856 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, 0, 6, 'x', 3, "xxa", IOSTATE_goodbit},
3857 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, FLAGS_left, 6, ' ', 4, "a ", IOSTATE_goodbit},
3858 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, FLAGS_left|FLAGS_internal, 6, ' ', 4, " a", IOSTATE_goodbit},
3859 {type_chr, /* 'a' */ 0, IOSTATE_goodbit, FLAGS_internal|FLAGS_hex|FLAGS_showbase, 6, ' ', 4, " a", IOSTATE_goodbit},
3860 {type_chr, /* '9' */ 1, IOSTATE_goodbit, FLAGS_oct|FLAGS_showbase|FLAGS_uppercase, 6, 'i', 2, "i9", IOSTATE_goodbit},
3861 {type_chr, /* '9' */ 1, IOSTATE_goodbit, FLAGS_showpos|FLAGS_scientific, 0, 'i', 2, "i9", IOSTATE_goodbit},
3862 {type_chr, /* 'e' */ 2, IOSTATE_goodbit, FLAGS_left|FLAGS_right|FLAGS_uppercase, 0, '*', 8, "e*******", IOSTATE_goodbit},
3863 /* const char* */
3864 {type_str, /* "Test" */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3865 {type_str, /* "Test" */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
3866 {type_str, /* "Test" */ 0, IOSTATE_goodbit, 0, 6, ' ', 0, "Test", IOSTATE_goodbit},
3867 {type_str, /* "Test" */ 0, IOSTATE_goodbit, 0, 6, ' ', 6, " Test", IOSTATE_goodbit},
3868 {type_str, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_internal, 6, 'x', 6, "xxTest", IOSTATE_goodbit},
3869 {type_str, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_left, 6, ' ', 5, "Test ", IOSTATE_goodbit},
3870 {type_str, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showpoint, 6, '?', 6, "Test??", IOSTATE_goodbit},
3871 {type_str, /* "800" */ 1, IOSTATE_goodbit, FLAGS_showbase|FLAGS_showpos, 6, ' ', 4, " 800", IOSTATE_goodbit},
3872 {type_str, /* "3.14159" */ 2, IOSTATE_goodbit, FLAGS_scientific, 2, 'x', 2, "3.14159", IOSTATE_goodbit},
3873 {type_str, /* " Test" */ 3, IOSTATE_goodbit, FLAGS_skipws, 6, 'x', 2, " Test", IOSTATE_goodbit},
3874 /* int */
3875 {type_int, /* 0 */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3876 {type_int, /* 0 */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
3877 {type_int, /* 0 */ 0, IOSTATE_goodbit, 0, 6, ' ', 4, " 0", IOSTATE_goodbit},
3878 {type_int, /* 7 */ 1, IOSTATE_goodbit, 0, 6, '0', 3, "007", IOSTATE_goodbit},
3879 {type_int, /* 10 */ 2, IOSTATE_goodbit, FLAGS_left, 6, ' ', 5, "10 ", IOSTATE_goodbit},
3880 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_left|FLAGS_hex, 6, ' ', 0, "18", IOSTATE_goodbit},
3881 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showbase, 6, ' ', 0, "0x18", IOSTATE_goodbit},
3882 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_internal|FLAGS_hex|FLAGS_showbase, 6, '*', 8, "0x****18", IOSTATE_goodbit},
3883 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_oct|FLAGS_showbase, 6, '*', 4, "*030", IOSTATE_goodbit},
3884 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_oct|FLAGS_dec|FLAGS_showbase, 6, ' ', 0, "030", IOSTATE_goodbit},
3885 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_oct|FLAGS_dec|FLAGS_hex|FLAGS_showbase, 6, ' ', 0, "0x18", IOSTATE_goodbit},
3886 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_left|FLAGS_oct|FLAGS_hex, 6, ' ', 5, "18 ", IOSTATE_goodbit},
3887 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_dec|FLAGS_hex|FLAGS_showbase, 6, ' ', 0, "0x18", IOSTATE_goodbit},
3888 {type_int, /* 24 */ 3, IOSTATE_goodbit, FLAGS_dec|FLAGS_showbase, 6, ' ', 0, "24", IOSTATE_goodbit},
3889 {type_int, /* 55 */ 4, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase|FLAGS_uppercase, 6, ' ', 0, "0X37", IOSTATE_goodbit},
3890 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase|FLAGS_showpoint|FLAGS_uppercase, 6, ' ', 0, "0X400", IOSTATE_goodbit},
3891 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase|FLAGS_showpos, 6, ' ', 0, "0x400", IOSTATE_goodbit},
3892 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_hex|FLAGS_showpos, 6, ' ', 0, "400", IOSTATE_goodbit},
3893 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_oct|FLAGS_showpos, 6, ' ', 0, "2000", IOSTATE_goodbit},
3894 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_internal|FLAGS_oct|FLAGS_showbase, 6, 'x', 8, "0xxx2000", IOSTATE_goodbit},
3895 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_showbase|FLAGS_showpoint|FLAGS_showpos, 6, ' ', 0, "+1024", IOSTATE_goodbit},
3896 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_dec|FLAGS_showbase|FLAGS_showpos, 6, 'a', 6, "a+1024", IOSTATE_goodbit},
3897 {type_int, /* 1024 */ 5, IOSTATE_goodbit, FLAGS_internal|FLAGS_showbase|FLAGS_showpos, 6, ' ', 8, "+ 1024", IOSTATE_goodbit},
3898 {type_int, /* 1023 */ 6, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase|FLAGS_uppercase, 6, ' ', 0, "0X3FF", IOSTATE_goodbit},
3899 {type_int, /* 1023 */ 6, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase|FLAGS_scientific, 6, ' ', 0, "0x3ff", IOSTATE_goodbit},
3900 {type_int, /* 65536 */ 7, IOSTATE_goodbit, FLAGS_right|FLAGS_showpos|FLAGS_fixed, 6, ' ', 8, " +65536", IOSTATE_goodbit},
3901 {type_int, /* 2147483647 */ 8, IOSTATE_goodbit, FLAGS_hex|FLAGS_showbase, 6, ' ', 0, "0x7fffffff", IOSTATE_goodbit},
3902 {type_int, /* 2147483648 */ 9, IOSTATE_goodbit, FLAGS_dec, 6, ' ', 0, "-2147483648", IOSTATE_goodbit},
3903 {type_int, /* 4294967295 */ 10, IOSTATE_goodbit, FLAGS_internal, 6, ' ', 8, " -1", IOSTATE_goodbit},
3904 {type_int, /* -20 */ 11, IOSTATE_goodbit, FLAGS_internal|FLAGS_oct|FLAGS_showbase, 6, ' ', 8, "037777777754", IOSTATE_goodbit},
3905 {type_int, /* -20 */ 11, IOSTATE_goodbit, FLAGS_dec|FLAGS_showpos, 6, ' ', 0, "-20", IOSTATE_goodbit},
3906 {type_int, /* 0 */ 0, IOSTATE_goodbit, FLAGS_internal|FLAGS_showpos, 6, ' ', 8, " 0", IOSTATE_goodbit},
3907 /* float */
3908 {type_flt, /* 1.0f */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3909 {type_flt, /* 1.0f */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
3910 {type_flt, /* 1.0f */ 0, IOSTATE_goodbit, 0, 6, ' ', 0, "1", IOSTATE_goodbit},
3911 {type_flt, /* 0.0f */ 1, IOSTATE_goodbit, 0, 6, ' ', 0, "0", IOSTATE_goodbit},
3912 {type_flt, /* 4.25f */ 2, IOSTATE_goodbit, 0, 6, ' ', 0, "4.25", IOSTATE_goodbit},
3913 {type_flt, /* 3.999f */ 3, IOSTATE_goodbit, 0, 6, ' ', 0, "3.999", IOSTATE_goodbit},
3914 {type_flt, /* 3.999f */ 3, IOSTATE_goodbit, 0, 3, ' ', 0, "4", IOSTATE_goodbit},
3915 {type_flt, /* 12.0005f */ 4, IOSTATE_goodbit, 0, 6, ' ', 0, "12.0005", IOSTATE_goodbit},
3916 {type_flt, /* 12.0005f */ 4, IOSTATE_goodbit, 0, 5, ' ', 0, "12", IOSTATE_goodbit},
3917 {type_flt, /* 15.33582f */ 5, IOSTATE_goodbit, 0, 4, ' ', 0, "15.34", IOSTATE_goodbit},
3918 {type_flt, /* 15.0f */ 6, IOSTATE_goodbit, FLAGS_internal|FLAGS_hex|FLAGS_showbase, 6, ' ', 4, " 15", IOSTATE_goodbit},
3919 {type_flt, /* 15.22f */ 7, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showbase, 3, ' ', 6, "15.2 ", IOSTATE_goodbit},
3920 {type_flt, /* 15.22 */ 7, IOSTATE_goodbit, FLAGS_internal, 3, 'x', 6, "xx15.2", IOSTATE_goodbit},
3921 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_showpoint, 9, ' ', 0, "21.1230", IOSTATE_goodbit},
3922 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_showpos, 9, ' ', 0, "+21.123", IOSTATE_goodbit},
3923 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_internal|FLAGS_showpos, 9, ' ', 8, "+ 21.123", IOSTATE_goodbit},
3924 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_showpos, 0, ' ', 0, "+2e+001", IOSTATE_goodbit},
3925 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, 0, 1, ' ', 0, "2e+001", IOSTATE_goodbit},
3926 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_showpos, 2, ' ', 0, "+21", IOSTATE_goodbit},
3927 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, 0, 4, ' ', 0, "21.12", IOSTATE_goodbit},
3928 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_scientific, 2, ' ', 0, "2.11e+001", IOSTATE_goodbit},
3929 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_scientific, 4, ' ', 0, "2.1123e+001", IOSTATE_goodbit},
3930 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_scientific, 6, ' ', 0, "2.112300e+001", IOSTATE_goodbit},
3931 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_scientific|FLAGS_uppercase, 2, ' ', 0, "2.11E+001", IOSTATE_goodbit},
3932 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_scientific|FLAGS_uppercase, 2, '*', 10, "*2.11E+001", IOSTATE_goodbit},
3933 {type_flt, /* 21.123f */ 8, IOSTATE_goodbit, FLAGS_fixed, 6, ' ', 0, "21.122999", IOSTATE_goodbit},
3934 {type_flt, /* 0.1f */ 9, IOSTATE_goodbit, FLAGS_fixed, 6, ' ', 0, "0.100000", IOSTATE_goodbit},
3935 {type_flt, /* 0.1f */ 9, IOSTATE_goodbit, FLAGS_scientific, 6, ' ', 0, "1.000000e-001", IOSTATE_goodbit},
3936 {type_flt, /* 13.14159f */ 10, IOSTATE_goodbit, FLAGS_fixed, 3, ' ', 0, "13.142", IOSTATE_goodbit},
3937 {type_flt, /* 13.14159f */ 10, IOSTATE_goodbit, FLAGS_fixed, 8, ' ', 0, "13.141590", IOSTATE_goodbit},
3938 {type_flt, /* 13.14159f */ 10, IOSTATE_goodbit, FLAGS_fixed|FLAGS_showpoint, 8, ' ', 0, "13.141590", IOSTATE_goodbit},
3939 {type_flt, /* 13.14159f */ 10, IOSTATE_goodbit, FLAGS_scientific|FLAGS_fixed, 8, ' ', 0, "13.1416", IOSTATE_goodbit},
3940 {type_flt, /* 13.14159f */ 10, IOSTATE_goodbit, FLAGS_scientific|FLAGS_fixed, 2, ' ', 0, "13", IOSTATE_goodbit},
3941 {type_flt, /* 0.00013f */ 11, IOSTATE_goodbit, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit},
3942 {type_flt, /* 0.00013f */ 11, IOSTATE_goodbit, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit},
3943 {type_flt, /* 0.00013f */ 11, IOSTATE_goodbit, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit},
3944 {type_flt, /* 0.000013f */ 12, IOSTATE_goodbit, 0, 4, ' ', 0, "1.3e-005", IOSTATE_goodbit},
3945 {type_flt, /* 0.000013f */ 12, IOSTATE_goodbit, FLAGS_showpoint, 4, ' ', 0, "1.300e-005", IOSTATE_goodbit},
3946 {type_flt, /* 0.000013f */ 12, IOSTATE_goodbit, FLAGS_showpoint, 6, ' ', 0, "1.30000e-005", IOSTATE_goodbit},
3947 {type_flt, /* INFINITY */ 13, IOSTATE_goodbit, 0, 6, ' ', 0, "1.#INF", IOSTATE_goodbit},
3948 {type_flt, /* INFINITY */ 13, IOSTATE_goodbit, 0, 4, ' ', 0, "1.#IO", IOSTATE_goodbit},
3949 {type_flt, /* -INFINITY */ 14, IOSTATE_goodbit, 0, 6, ' ', 0, "-1.#INF", IOSTATE_goodbit},
3950 {type_flt, /* NAN */ 15, IOSTATE_goodbit, 0, 6, ' ', 0, "1.#QNAN", IOSTATE_goodbit},
3951 /* double */
3952 {type_dbl, /* 1.0 */ 0, IOSTATE_goodbit, 0, 6, ' ', 0, "1", IOSTATE_goodbit},
3953 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, 0, 6, ' ', 0, "3.14159", IOSTATE_goodbit},
3954 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, 0, 9, ' ', 0, "3.14159265", IOSTATE_goodbit},
3955 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, 0, 12, ' ', 0, "3.14159265359", IOSTATE_goodbit},
3956 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, 0, 15, ' ', 0, "3.14159265358979", IOSTATE_goodbit},
3957 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, 0, 16, ' ', 0, "3.14159265358979", IOSTATE_goodbit},
3958 {type_dbl, /* 314.1592653589793238 */ 2, IOSTATE_goodbit, 0, 16, ' ', 0, "314.159265358979", IOSTATE_goodbit},
3959 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, FLAGS_scientific, 16, ' ', 0, "3.141592653589793e+000", IOSTATE_goodbit},
3960 {type_dbl, /* 314.1592653589793238 */ 2, IOSTATE_goodbit, FLAGS_scientific, 16, ' ', 0, "3.141592653589793e+002", IOSTATE_goodbit},
3961 {type_dbl, /* 3.141592653589793238 */ 1, IOSTATE_goodbit, FLAGS_fixed, -1, ' ', 0, "3.141592653589793", IOSTATE_goodbit},
3962 {type_dbl, /* 314.159265358979 */ 3, IOSTATE_goodbit, FLAGS_fixed, 12, ' ', 0, "314.159265358979", IOSTATE_goodbit},
3963 {type_dbl, /* 1231314.269811862199 */ 4, IOSTATE_goodbit, FLAGS_fixed, 10, ' ', 0, "1231314.2698118621", IOSTATE_goodbit},
3964 {type_dbl, /* 9.961472e6 */ 5, IOSTATE_goodbit, FLAGS_fixed, 500, ' ', 0, "9961472.000000000000000", IOSTATE_goodbit},
3965 /* crashes on XP/2k3 {type_dbl, 8.98846567431e307 6, IOSTATE_goodbit, FLAGS_fixed, 500, ' ', 0, "", IOSTATE_goodbit}, */
3966 /* crashes on XP/2k3 {type_dbl, DBL_MAX 7, IOSTATE_goodbit, FLAGS_fixed|FLAGS_showpos, 500, ' ', 5, " ", IOSTATE_goodbit}, */
3967 {type_dbl, /* DBL_MAX */ 7, IOSTATE_goodbit, FLAGS_showpoint, 500, ' ', 0, "1.79769313486232e+308", IOSTATE_goodbit},
3968 /* void* */
3969 {type_ptr, /* NULL */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3970 {type_ptr, /* NULL */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
3971 {type_ptr, /* NULL */ 0, IOSTATE_goodbit, 0, 6, ' ', 0,
3972 is_64 ? "0x0000000000000000" : "0x00000000", IOSTATE_goodbit},
3973 {type_ptr, /* 0xdeadbeef */ 1, IOSTATE_goodbit, 0, 6, ' ', 0,
3974 is_64 ? "0x00000000DEADBEEF" : "0xDEADBEEF", IOSTATE_goodbit},
3975 {type_ptr, /* 0xdeadbeef */ 1, IOSTATE_goodbit, 0, 6, '*', 12,
3976 is_64 ? "0x00000000DEADBEEF" : "**0xDEADBEEF", IOSTATE_goodbit},
3977 {type_ptr, /* 0xdeadbeef */ 1, IOSTATE_goodbit, FLAGS_internal, 6, ' ', 14,
3978 is_64 ? "0x00000000DEADBEEF" : "0x DEADBEEF", IOSTATE_goodbit},
3979 {type_ptr, /* 0xdeadbeef */ 1, IOSTATE_goodbit, FLAGS_left, 6, 'x', 11,
3980 is_64 ? "0x00000000DEADBEEF" : "0xDEADBEEFx", IOSTATE_goodbit},
3981 {type_ptr, /* 0x1234cdef */ 2, IOSTATE_goodbit, FLAGS_dec|FLAGS_showpos, 6, ' ', 0,
3982 is_64 ? "0x000000001234CDEF" : "0x1234CDEF", IOSTATE_goodbit},
3983 {type_ptr, /* 0x1 */ 3, IOSTATE_goodbit, FLAGS_oct|FLAGS_showbase, 6, ' ', 0,
3984 is_64 ? "0x0000000000000001" : "0x00000001", IOSTATE_goodbit},
3985 {type_ptr, /* 0xffffffff */ 4, IOSTATE_goodbit, FLAGS_hex|FLAGS_showpoint, 6, ' ', 0,
3986 is_64 ? "0x00000000FFFFFFFF" : "0xFFFFFFFF", IOSTATE_goodbit},
3987 {type_ptr, /* 0xffffffff */ 4, IOSTATE_goodbit, FLAGS_uppercase|FLAGS_fixed, 6, ' ', 0,
3988 is_64 ? "0X00000000FFFFFFFF" : "0XFFFFFFFF", IOSTATE_goodbit},
3989 {type_ptr, /* 0x1 */ 3, IOSTATE_goodbit, FLAGS_uppercase, 6, ' ', 0,
3990 is_64 ? "0X0000000000000001" : "0X00000001", IOSTATE_goodbit},
3991 {type_ptr, /* NULL */ 0, IOSTATE_goodbit, FLAGS_uppercase, 6, ' ', 0,
3992 is_64 ? "0x0000000000000000" : "0x00000000", IOSTATE_goodbit},
3993 {type_ptr, /* NULL */ 0, IOSTATE_goodbit, FLAGS_uppercase|FLAGS_showbase, 12, 'x', 12,
3994 is_64 ? "0x0000000000000000" : "xx0x00000000", IOSTATE_goodbit},
3995 {type_ptr, /* NULL */ 0, IOSTATE_goodbit, FLAGS_internal|FLAGS_uppercase|FLAGS_showbase, 6, '?', 20,
3996 is_64 ? "0x??0000000000000000" : "0x??????????00000000", IOSTATE_goodbit},
3997 /* streambuf* */
3998 {type_sbf, /* NULL */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
3999 {type_sbf, /* NULL */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
4000 /* crashes on native {STREAMBUF, NULL 0, IOSTATE_goodbit, 0, 6, ' ', 0, "", IOSTATE_goodbit}, */
4001 {type_sbf, /* &ssb_test1.base */ 1, IOSTATE_goodbit, FLAGS_skipws|FLAGS_showpos|FLAGS_uppercase,
4002 6, ' ', 0, " we both know what's been going on ", IOSTATE_goodbit},
4003 {type_sbf, /* &ssb_test1.base */ 2, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showbase,
4004 6, '*', 50, "123 We know the game and", IOSTATE_goodbit},
4005 {type_sbf, /* &ssb_test1.base */ 3, IOSTATE_goodbit, FLAGS_internal|FLAGS_scientific|FLAGS_showpoint,
4006 6, '*', 50, "we're gonna play it 3.14159", IOSTATE_goodbit}
4009 pssb = call_func1(p_strstreambuf_ctor, &ssb);
4010 ok(pssb == &ssb, "wrong return, expected %p got %p\n", &ssb, pssb);
4011 pos = call_func3(p_ostream_sb_ctor, &os, &ssb.base, TRUE);
4012 ok(pos == &os, "wrong return, expected %p got %p\n", &os, pos);
4013 pssb = call_func1(p_strstreambuf_ctor, &ssb_test1);
4014 ok(pssb == &ssb_test1, "wrong return, expected %p got %p\n", &ssb_test1, pssb);
4015 ret = (int) call_func3(p_streambuf_xsputn, &ssb_test1.base, " we both know what's been going on ", 36);
4016 ok(ret == 36, "expected 36 got %d\n", ret);
4017 pssb = call_func1(p_strstreambuf_ctor, &ssb_test2);
4018 ok(pssb == &ssb_test2, "wrong return, expected %p got %p\n", &ssb_test2, pssb);
4019 ret = (int) call_func3(p_streambuf_xsputn, &ssb_test2.base, "123 We know the game and", 24);
4020 ok(ret == 24, "expected 24 got %d\n", ret);
4021 pssb = call_func1(p_strstreambuf_ctor, &ssb_test3);
4022 ok(pssb == &ssb_test3, "wrong return, expected %p got %p\n", &ssb_test3, pssb);
4023 ret = (int) call_func3(p_streambuf_xsputn, &ssb_test3.base, "we're gonna play it 3.14159", 27);
4024 ok(ret == 27, "expected 27 got %d\n", ret);
4026 for (i = 0; i < ARRAY_SIZE(tests); i++) {
4027 os.base_ios.state = tests[i].state;
4028 os.base_ios.flags = tests[i].flags;
4029 os.base_ios.precision = tests[i].precision;
4030 os.base_ios.fill = tests[i].fill;
4031 os.base_ios.width = tests[i].width;
4032 ssb.base.pptr = ssb.base.pbase;
4034 switch (tests[i].type) {
4035 case type_chr:
4036 pos = call_func2(p_ostream_print_char, &os, (int) param_char[tests[i].param_index]); break;
4037 case type_str:
4038 pos = call_func2(p_ostream_print_str, &os, param_str[tests[i].param_index]); break;
4039 case type_int:
4040 pos = call_func2(p_ostream_print_int, &os, param_int[tests[i].param_index]); break;
4041 case type_flt:
4042 pos = call_func2_ptr_flt(p_ostream_print_float, &os, param_float[tests[i].param_index]); break;
4043 case type_dbl:
4044 pos = call_func2_ptr_dbl(p_ostream_print_double, &os, param_double[tests[i].param_index]); break;
4045 case type_ptr:
4046 pos = call_func2(p_ostream_print_ptr, &os, param_ptr[tests[i].param_index]); break;
4047 case type_sbf:
4048 pos = call_func2(p_ostream_print_streambuf, &os, param_streambuf[tests[i].param_index]); break;
4051 length = ssb.base.pptr - ssb.base.pbase;
4052 expected_length = strlen(tests[i].expected_text);
4053 ok(pos == &os, "Test %d: wrong return, expected %p got %p\n", i, &os, pos);
4054 ok(os.base_ios.state == tests[i].expected_flags, "Test %d: expected %d got %d\n", i,
4055 tests[i].expected_flags, os.base_ios.state);
4056 ok(os.base_ios.width == 0, "Test %d: expected 0 got %d\n", i, os.base_ios.width);
4057 ok(expected_length == length, "Test %d: wrong output length, expected %ld got %ld\n", i, expected_length, length);
4058 ok(!strncmp(tests[i].expected_text, ssb.base.pbase, length),
4059 "Test %d: wrong output, expected '%s' got '%s'\n", i, tests[i].expected_text, ssb.base.pbase);
4062 call_func1(p_ostream_vbase_dtor, &os);
4063 call_func1(p_strstreambuf_dtor, &ssb);
4064 call_func1(p_strstreambuf_dtor, &ssb_test1);
4065 call_func1(p_strstreambuf_dtor, &ssb_test2);
4066 call_func1(p_strstreambuf_dtor, &ssb_test3);
4069 static void test_ostream_withassign(void)
4071 ostream osa1, osa2, *posa, *pos;
4072 streambuf sb, *psb;
4074 memset(&osa1, 0xab, sizeof(ostream));
4075 memset(&osa2, 0xab, sizeof(ostream));
4077 /* constructors/destructors */
4078 posa = call_func3(p_ostream_withassign_sb_ctor, &osa1, NULL, TRUE);
4079 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4080 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4081 ok(osa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa1.base_ios.sb);
4082 ok(osa1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, osa1.base_ios.state);
4083 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4084 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4085 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4086 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4087 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4088 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4089 ok(osa1.base_ios.do_lock == -1, "expected -1 got %d\n", osa1.base_ios.do_lock);
4090 call_func1(p_ostream_withassign_vbase_dtor, &osa1);
4091 osa1.unknown = 0xabababab;
4092 memset(&osa1.base_ios, 0xab, sizeof(ios));
4093 osa1.base_ios.delbuf = 0;
4094 posa = call_func3(p_ostream_withassign_sb_ctor, &osa1, NULL, FALSE);
4095 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4096 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4097 ok(osa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa1.base_ios.sb);
4098 ok(osa1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
4099 0xabababab|IOSTATE_badbit, osa1.base_ios.state);
4100 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4101 ok(osa1.base_ios.tie == osa2.base_ios.tie, "expected %p got %p\n", osa2.base_ios.tie, osa1.base_ios.tie);
4102 ok(osa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, osa1.base_ios.flags);
4103 ok(osa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.precision);
4104 ok(osa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", osa1.base_ios.fill);
4105 ok(osa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.width);
4106 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4107 call_func1(p_ostream_withassign_dtor, &osa1.base_ios);
4108 osa1.unknown = 0xabababab;
4109 osa1.base_ios.sb = (streambuf*) 0xabababab;
4110 posa = call_func3(p_ostream_withassign_sb_ctor, &osa1, &sb, TRUE);
4111 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4112 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4113 ok(osa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, osa1.base_ios.sb);
4114 ok(osa1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, osa1.base_ios.state);
4115 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4116 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4117 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4118 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4119 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4120 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4121 ok(osa1.base_ios.do_lock == -1, "expected -1 got %d\n", osa1.base_ios.do_lock);
4122 call_func1(p_ostream_withassign_vbase_dtor, &osa1);
4123 osa1.unknown = 0xabababab;
4124 memset(&osa1.base_ios, 0xab, sizeof(ios));
4125 osa1.base_ios.state |= IOSTATE_badbit;
4126 osa1.base_ios.delbuf = 0;
4127 posa = call_func3(p_ostream_withassign_sb_ctor, &osa1, &sb, FALSE);
4128 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4129 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4130 ok(osa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, osa1.base_ios.sb);
4131 ok(osa1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.state);
4132 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4133 ok(osa1.base_ios.tie == osa2.base_ios.tie, "expected %p got %p\n", osa2.base_ios.tie, osa1.base_ios.tie);
4134 ok(osa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, osa1.base_ios.flags);
4135 ok(osa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.precision);
4136 ok(osa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", osa1.base_ios.fill);
4137 ok(osa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.width);
4138 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4139 call_func1(p_ostream_withassign_dtor, &osa1.base_ios);
4140 posa = call_func2(p_ostream_withassign_ctor, &osa2, TRUE);
4141 ok(posa == &osa2, "wrong return, expected %p got %p\n", &osa2, posa);
4142 ok(osa2.unknown == 0, "expected 0 got %d\n", osa2.unknown);
4143 ok(osa2.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa2.base_ios.sb);
4144 ok(osa2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, osa2.base_ios.state);
4145 ok(osa2.base_ios.delbuf == 0, "expected 0 got %d\n", osa2.base_ios.delbuf);
4146 ok(osa2.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa2.base_ios.tie);
4147 ok(osa2.base_ios.flags == 0, "expected 0 got %x\n", osa2.base_ios.flags);
4148 ok(osa2.base_ios.precision == 6, "expected 6 got %d\n", osa2.base_ios.precision);
4149 ok(osa2.base_ios.fill == ' ', "expected 32 got %d\n", osa2.base_ios.fill);
4150 ok(osa2.base_ios.width == 0, "expected 0 got %d\n", osa2.base_ios.width);
4151 ok(osa2.base_ios.do_lock == -1, "expected -1 got %d\n", osa2.base_ios.do_lock);
4152 call_func1(p_ostream_withassign_vbase_dtor, &osa2);
4153 osa2.unknown = 0xcdcdcdcd;
4154 memset(&osa2.base_ios, 0xcd, sizeof(ios));
4155 osa2.base_ios.delbuf = 0;
4156 psb = osa2.base_ios.sb;
4157 pos = osa2.base_ios.tie;
4158 posa = call_func2(p_ostream_withassign_ctor, &osa2, FALSE);
4159 ok(posa == &osa2, "wrong return, expected %p got %p\n", &osa2, posa);
4160 ok(osa2.unknown == 0, "expected 0 got %d\n", osa2.unknown);
4161 ok(osa2.base_ios.sb == psb, "expected %p got %p\n", psb, osa2.base_ios.sb);
4162 ok(osa2.base_ios.state == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, osa2.base_ios.state);
4163 ok(osa2.base_ios.delbuf == 0, "expected 0 got %d\n", osa2.base_ios.delbuf);
4164 ok(osa2.base_ios.tie == pos, "expected %p got %p\n", pos, osa2.base_ios.tie);
4165 ok(osa2.base_ios.flags == 0xcdcdcdcd, "expected %d got %x\n", 0xcdcdcdcd, osa2.base_ios.flags);
4166 ok(osa2.base_ios.precision == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, osa2.base_ios.precision);
4167 ok(osa2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", osa2.base_ios.fill);
4168 ok(osa2.base_ios.width == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, osa2.base_ios.width);
4169 ok(osa2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, osa2.base_ios.do_lock);
4170 call_func1(p_ostream_withassign_dtor, &osa2.base_ios);
4171 osa1.unknown = 0xabababab;
4172 osa2.unknown = osa2.base_ios.delbuf = 0xcdcdcdcd;
4173 posa = call_func3(p_ostream_withassign_copy_ctor, &osa1, &osa2, TRUE);
4174 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4175 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4176 ok(osa1.base_ios.sb == osa2.base_ios.sb, "expected %p got %p\n", osa2.base_ios.sb, osa1.base_ios.sb);
4177 ok(osa1.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, osa1.base_ios.state);
4178 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4179 ok(osa1.base_ios.tie == osa2.base_ios.tie, "expected %p got %p\n", osa2.base_ios.tie, osa1.base_ios.tie);
4180 ok(osa1.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, osa1.base_ios.flags);
4181 ok(osa1.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.precision);
4182 ok(osa1.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.fill);
4183 ok(osa1.base_ios.width == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.width);
4184 ok(osa1.base_ios.do_lock == -1, "expected -1 got %d\n", osa1.base_ios.do_lock);
4185 call_func1(p_ostream_withassign_vbase_dtor, &osa1);
4186 osa1.unknown = 0xabababab;
4187 memset(&osa1.base_ios, 0xab, sizeof(ios));
4188 osa1.base_ios.state |= IOSTATE_badbit;
4189 osa1.base_ios.delbuf = 0;
4190 pos = osa1.base_ios.tie;
4191 posa = call_func3(p_ostream_withassign_copy_ctor, &osa1, &osa2, FALSE);
4192 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4193 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4194 ok(osa1.base_ios.sb == osa2.base_ios.sb, "expected %p got %p\n", osa2.base_ios.sb, osa1.base_ios.sb);
4195 ok(osa1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.state);
4196 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4197 ok(osa1.base_ios.tie == pos, "expected %p got %p\n", pos, osa1.base_ios.tie);
4198 ok(osa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, osa1.base_ios.flags);
4199 ok(osa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.precision);
4200 ok(osa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", osa1.base_ios.fill);
4201 ok(osa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.width);
4202 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4203 call_func1(p_ostream_withassign_dtor, &osa1.base_ios);
4204 osa1.unknown = 0xabababab;
4205 osa2.base_ios.sb = NULL;
4206 posa = call_func3(p_ostream_withassign_copy_ctor, &osa1, &osa2, TRUE);
4207 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4208 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4209 ok(osa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa1.base_ios.sb);
4210 ok(osa1.base_ios.state == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, osa1.base_ios.state);
4211 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4212 ok(osa1.base_ios.tie == osa2.base_ios.tie, "expected %p got %p\n", osa2.base_ios.tie, osa1.base_ios.tie);
4213 ok(osa1.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, osa1.base_ios.flags);
4214 ok(osa1.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.precision);
4215 ok(osa1.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.fill);
4216 ok(osa1.base_ios.width == (char) 0xcd, "expected -51 got %d\n", osa1.base_ios.width);
4217 ok(osa1.base_ios.do_lock == -1, "expected -1 got %d\n", osa1.base_ios.do_lock);
4218 call_func1(p_ostream_withassign_vbase_dtor, &osa1);
4219 osa1.unknown = 0xabababab;
4220 memset(&osa1.base_ios, 0xab, sizeof(ios));
4221 osa1.base_ios.delbuf = 0;
4222 posa = call_func3(p_ostream_withassign_copy_ctor, &osa1, &osa2, FALSE);
4223 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4224 ok(osa1.unknown == 0, "expected 0 got %d\n", osa1.unknown);
4225 ok(osa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa1.base_ios.sb);
4226 ok(osa1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
4227 0xabababab|IOSTATE_badbit, osa1.base_ios.state);
4228 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4229 ok(osa1.base_ios.tie == pos, "expected %p got %p\n", pos, osa1.base_ios.tie);
4230 ok(osa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, osa1.base_ios.flags);
4231 ok(osa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.precision);
4232 ok(osa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", osa1.base_ios.fill);
4233 ok(osa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.width);
4234 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4235 call_func1(p_ostream_withassign_dtor, &osa1.base_ios);
4237 /* assignment */
4238 osa1.unknown = 0xabababab;
4239 osa1.base_ios.sb = (streambuf*) 0xabababab;
4240 if (0) /* crashes on native */
4241 osa1.base_ios.delbuf = 0xabababab;
4242 posa = call_func2(p_ostream_withassign_assign_sb, &osa1, &sb);
4243 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4244 ok(osa1.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.unknown);
4245 ok(osa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, osa1.base_ios.sb);
4246 ok(osa1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, osa1.base_ios.state);
4247 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4248 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4249 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4250 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4251 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4252 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4253 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4254 memset(&osa1.base_ios, 0xab, sizeof(ios));
4255 osa1.base_ios.delbuf = 0;
4256 posa = call_func2(p_ostream_withassign_assign_sb, &osa1, NULL);
4257 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4258 ok(osa1.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.unknown);
4259 ok(osa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, osa1.base_ios.sb);
4260 ok(osa1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, osa1.base_ios.state);
4261 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4262 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4263 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4264 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4265 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4266 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4267 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4268 memset(&osa1.base_ios, 0xab, sizeof(ios));
4269 osa1.base_ios.delbuf = 0;
4270 osa2.base_ios.sb = &sb;
4271 posa = call_func2(p_ostream_withassign_assign_os, &osa1, &osa2);
4272 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4273 ok(osa1.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.unknown);
4274 ok(osa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, osa1.base_ios.sb);
4275 ok(osa1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, osa1.base_ios.state);
4276 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4277 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4278 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4279 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4280 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4281 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4282 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4283 memset(&osa1.base_ios, 0xab, sizeof(ios));
4284 osa1.base_ios.delbuf = 0;
4285 posa = call_func2(p_ostream_withassign_assign, &osa1, &osa2);
4286 ok(posa == &osa1, "wrong return, expected %p got %p\n", &osa1, posa);
4287 ok(osa1.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.unknown);
4288 ok(osa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, osa1.base_ios.sb);
4289 ok(osa1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, osa1.base_ios.state);
4290 ok(osa1.base_ios.delbuf == 0, "expected 0 got %d\n", osa1.base_ios.delbuf);
4291 ok(osa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, osa1.base_ios.tie);
4292 ok(osa1.base_ios.flags == 0, "expected 0 got %x\n", osa1.base_ios.flags);
4293 ok(osa1.base_ios.precision == 6, "expected 6 got %d\n", osa1.base_ios.precision);
4294 ok(osa1.base_ios.fill == ' ', "expected 32 got %d\n", osa1.base_ios.fill);
4295 ok(osa1.base_ios.width == 0, "expected 0 got %d\n", osa1.base_ios.width);
4296 ok(osa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, osa1.base_ios.do_lock);
4299 static void test_ostrstream(void)
4301 ostream os1, os2, *pos, *pos2;
4302 strstreambuf *pssb;
4303 char buffer[32];
4304 int ret;
4306 memset(&os1, 0xab, sizeof(ostream));
4307 memset(&os2, 0xab, sizeof(ostream));
4309 /* constructors/destructors */
4310 pos = call_func2(p_ostrstream_ctor, &os1, TRUE);
4311 pssb = (strstreambuf*) os1.base_ios.sb;
4312 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4313 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4314 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4315 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
4316 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4317 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
4318 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
4319 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
4320 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
4321 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
4322 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
4323 ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
4324 ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
4325 ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
4326 ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
4327 ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
4328 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4329 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4330 ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
4331 ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
4332 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4333 call_func1(p_ostrstream_vbase_dtor, &os1);
4334 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
4335 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
4336 os1.unknown = 0xabababab;
4337 memset(&os1.base_ios, 0xab, sizeof(ios));
4338 os1.base_ios.delbuf = 0;
4339 pos = call_func2(p_ostrstream_ctor, &os1, FALSE);
4340 pssb = (strstreambuf*) os1.base_ios.sb;
4341 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4342 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4343 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4344 ok(os1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.state);
4345 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4346 ok(os1.base_ios.tie == os2.base_ios.tie, "expected %p got %p\n", os2.base_ios.tie, os1.base_ios.tie);
4347 ok(os1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os1.base_ios.flags);
4348 ok(os1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.precision);
4349 ok(os1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os1.base_ios.fill);
4350 ok(os1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.width);
4351 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
4352 ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
4353 ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
4354 ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
4355 ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
4356 ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
4357 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4358 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4359 ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
4360 ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
4361 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4362 call_func1(p_ostrstream_dtor, &os1.base_ios);
4363 ok(os1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, os1.base_ios.sb);
4364 ok(os1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.state);
4365 call_func1(p_strstreambuf_dtor, pssb);
4366 p_operator_delete(pssb);
4368 memset(&os1, 0xab, sizeof(ostream));
4369 pos = call_func5(p_ostrstream_buffer_ctor, &os1, buffer, 32, OPENMODE_in|OPENMODE_out, TRUE);
4370 pssb = (strstreambuf*) os1.base_ios.sb;
4371 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4372 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4373 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4374 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
4375 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4376 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
4377 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
4378 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
4379 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
4380 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
4381 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
4382 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
4383 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
4384 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4385 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4386 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
4387 ok(pssb->base.ebuf == buffer + 32, "wrong buffer end, expected %p got %p\n", buffer + 32, pssb->base.ebuf);
4388 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
4389 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
4390 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
4391 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
4392 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
4393 ok(pssb->base.epptr == buffer + 32, "wrong put end, expected %p got %p\n", buffer + 32, pssb->base.epptr);
4394 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4395 call_func1(p_ostrstream_vbase_dtor, &os1);
4396 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
4397 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
4398 strcpy(buffer, "Test");
4399 memset(&os1, 0xab, sizeof(ostream));
4400 pos = call_func5(p_ostrstream_buffer_ctor, &os1, buffer, 16, OPENMODE_ate, TRUE);
4401 pssb = (strstreambuf*) os1.base_ios.sb;
4402 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4403 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4404 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4405 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
4406 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4407 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
4408 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
4409 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
4410 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
4411 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
4412 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
4413 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
4414 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
4415 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4416 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4417 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
4418 ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
4419 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
4420 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
4421 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
4422 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
4423 ok(pssb->base.pptr == buffer + 4, "wrong put pointer, expected %p got %p\n", buffer + 4, pssb->base.pptr);
4424 ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
4425 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4426 call_func1(p_ostrstream_vbase_dtor, &os1);
4427 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
4428 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
4429 os1.unknown = 0xabababab;
4430 memset(&os1.base_ios, 0xab, sizeof(ios));
4431 os1.base_ios.delbuf = 0;
4432 pos = call_func5(p_ostrstream_buffer_ctor, &os1, buffer, -1, OPENMODE_app, FALSE);
4433 pssb = (strstreambuf*) os1.base_ios.sb;
4434 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4435 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4436 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4437 ok(os1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.state);
4438 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4439 ok(os1.base_ios.tie == os2.base_ios.tie, "expected %p got %p\n", os2.base_ios.tie, os1.base_ios.tie);
4440 ok(os1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os1.base_ios.flags);
4441 ok(os1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.precision);
4442 ok(os1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os1.base_ios.fill);
4443 ok(os1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.width);
4444 ok(os1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.do_lock);
4445 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
4446 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
4447 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4448 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4449 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
4450 ok(pssb->base.ebuf == (char *)((ULONG_PTR)buffer + 0x7fffffff) || pssb->base.ebuf == (char*) -1,
4451 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.ebuf);
4452 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
4453 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
4454 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
4455 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
4456 ok(pssb->base.pptr == buffer + 4, "wrong put pointer, expected %p got %p\n", buffer + 4, pssb->base.pptr);
4457 ok(pssb->base.epptr == (char *)((ULONG_PTR)buffer + 0x7fffffff) || pssb->base.epptr == (char*) -1,
4458 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.epptr);
4459 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4460 call_func1(p_ostrstream_dtor, &os1.base_ios);
4461 ok(os1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, os1.base_ios.sb);
4462 ok(os1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os1.base_ios.state);
4463 call_func1(p_strstreambuf_dtor, pssb);
4464 p_operator_delete(pssb);
4465 memset(&os1, 0xab, sizeof(ostream));
4466 pos = call_func5(p_ostrstream_buffer_ctor, &os1, buffer, 0, OPENMODE_trunc, TRUE);
4467 pssb = (strstreambuf*) os1.base_ios.sb;
4468 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4469 ok(os1.unknown == 0, "expected 0 got %d\n", os1.unknown);
4470 ok(os1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, os1.base_ios.sb);
4471 ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
4472 ok(os1.base_ios.delbuf == 1, "expected 1 got %d\n", os1.base_ios.delbuf);
4473 ok(os1.base_ios.tie == NULL, "expected %p got %p\n", NULL, os1.base_ios.tie);
4474 ok(os1.base_ios.flags == 0, "expected 0 got %x\n", os1.base_ios.flags);
4475 ok(os1.base_ios.precision == 6, "expected 6 got %d\n", os1.base_ios.precision);
4476 ok(os1.base_ios.fill == ' ', "expected 32 got %d\n", os1.base_ios.fill);
4477 ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
4478 ok(os1.base_ios.do_lock == -1, "expected -1 got %d\n", os1.base_ios.do_lock);
4479 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
4480 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
4481 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
4482 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
4483 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
4484 ok(pssb->base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, pssb->base.ebuf);
4485 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
4486 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
4487 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
4488 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
4489 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
4490 ok(pssb->base.epptr == buffer + 4, "wrong put end, expected %p got %p\n", buffer + 4, pssb->base.epptr);
4491 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
4492 call_func1(p_ostrstream_vbase_dtor, &os1);
4493 ok(os1.base_ios.sb == NULL, "expected %p got %p\n", NULL, os1.base_ios.sb);
4494 ok(os1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os1.base_ios.state);
4496 os1.unknown = 0xcdcdcdcd;
4497 memset(&os1.base_ios, 0xcd, sizeof(ios));
4498 pos = call_func3(p_ostrstream_copy_ctor, &os2, &os1, TRUE);
4499 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
4500 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
4501 ok(os2.base_ios.sb == os1.base_ios.sb, "expected %p got %p\n", os1.base_ios.sb, os2.base_ios.sb);
4502 ok(os2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, os2.base_ios.state);
4503 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
4504 ok(os2.base_ios.tie == os1.base_ios.tie, "expected %p got %p\n", os1.base_ios.tie, os2.base_ios.tie);
4505 ok(os2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, os2.base_ios.flags);
4506 ok(os2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.precision);
4507 ok(os2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.fill);
4508 ok(os2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.width);
4509 ok(os2.base_ios.do_lock == -1, "expected -1 got %d\n", os2.base_ios.do_lock);
4510 call_func1(p_ostrstream_vbase_dtor, &os2);
4511 ok(os2.base_ios.sb == NULL, "expected %p got %p\n", NULL, os2.base_ios.sb);
4512 ok(os2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os2.base_ios.state);
4513 os2.unknown = 0xabababab;
4514 memset(&os2.base_ios, 0xab, sizeof(ios));
4515 os2.base_ios.delbuf = 0;
4516 pos2 = os2.base_ios.tie;
4517 pos = call_func3(p_ostrstream_copy_ctor, &os2, &os1, FALSE);
4518 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
4519 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
4520 ok(os2.base_ios.sb == os1.base_ios.sb, "expected %p got %p\n", os1.base_ios.sb, os2.base_ios.sb);
4521 ok(os2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.state);
4522 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
4523 ok(os2.base_ios.tie == pos2, "expected %p got %p\n", pos2, os2.base_ios.tie);
4524 ok(os2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, os2.base_ios.flags);
4525 ok(os2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.precision);
4526 ok(os2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", os2.base_ios.fill);
4527 ok(os2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.width);
4528 ok(os2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.do_lock);
4529 call_func1(p_ostrstream_dtor, &os2.base_ios);
4530 os1.base_ios.sb = NULL;
4531 memset(&os2, 0xab, sizeof(ostream));
4532 pos = call_func3(p_ostrstream_copy_ctor, &os2, &os1, TRUE);
4533 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
4534 ok(os2.unknown == 0, "expected 0 got %d\n", os2.unknown);
4535 ok(os2.base_ios.sb == NULL, "expected %p got %p\n", NULL, os2.base_ios.sb);
4536 ok(os2.base_ios.state == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, os2.base_ios.state);
4537 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
4538 ok(os2.base_ios.tie == os1.base_ios.tie, "expected %p got %p\n", os1.base_ios.tie, os2.base_ios.tie);
4539 ok(os2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, os2.base_ios.flags);
4540 ok(os2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.precision);
4541 ok(os2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.fill);
4542 ok(os2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", os2.base_ios.width);
4543 ok(os2.base_ios.do_lock == -1, "expected -1 got %d\n", os2.base_ios.do_lock);
4544 call_func1(p_ostrstream_vbase_dtor, &os2);
4546 /* assignment */
4547 os2.unknown = 0xabababab;
4548 memset(&os2.base_ios, 0xab, sizeof(ios));
4549 os2.base_ios.delbuf = 0;
4550 pos = call_func2(p_ostrstream_assign, &os2, &os1);
4551 ok(pos == &os2, "wrong return, expected %p got %p\n", &os2, pos);
4552 ok(os2.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, os2.unknown);
4553 ok(os2.base_ios.sb == NULL, "expected %p got %p\n", NULL, os2.base_ios.sb);
4554 ok(os2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, os2.base_ios.state);
4555 ok(os2.base_ios.delbuf == 0, "expected 0 got %d\n", os2.base_ios.delbuf);
4556 ok(os2.base_ios.tie == NULL, "expected %p got %p\n", NULL, os2.base_ios.tie);
4557 ok(os2.base_ios.flags == 0, "expected %x got %x\n", 0, os2.base_ios.flags);
4558 ok(os2.base_ios.precision == 6, "expected 6 got %d\n", os2.base_ios.precision);
4559 ok(os2.base_ios.fill == ' ', "expected 32 got %d\n", os2.base_ios.fill);
4560 ok(os2.base_ios.width == 0, "expected 0 got %d\n", os2.base_ios.width);
4561 ok(os2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, os2.base_ios.do_lock);
4563 /* pcount */
4564 pos = call_func2(p_ostrstream_ctor, &os1, TRUE);
4565 ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
4566 ret = (int) call_func1(p_ostrstream_pcount, &os1);
4567 ok(ret == 0, "expected 0 got %d\n", ret);
4568 pssb = (strstreambuf*) os1.base_ios.sb;
4569 pssb->base.pptr = (char*) 5;
4570 ret = (int) call_func1(p_ostrstream_pcount, &os1);
4571 ok(ret == 5, "expected 5 got %d\n", ret);
4572 pssb->base.pbase = (char*) 2;
4573 ret = (int) call_func1(p_ostrstream_pcount, &os1);
4574 ok(ret == 3, "expected 3 got %d\n", ret);
4575 pssb->base.pptr = NULL;
4576 ret = (int) call_func1(p_ostrstream_pcount, &os1);
4577 ok(ret == 0, "expected 0 got %d\n", ret);
4578 if (0) /* crashes on native */
4579 os1.base_ios.sb = NULL;
4580 pssb->base.pptr = (char*) 1;
4581 ret = (int) call_func1(p_ostrstream_pcount, &os1);
4582 ok(ret == 0, "expected 0 got %d\n", ret);
4583 call_func1(p_ostrstream_vbase_dtor, &os1);
4586 static void test_ofstream(void)
4588 const char *filename = "ofstream_test";
4589 ostream ofs, ofs_copy, *pofs;
4590 streambuf *psb;
4591 filebuf *pfb;
4592 char buffer[64];
4593 char st[8];
4594 int fd, ret;
4596 memset(&ofs, 0xab, sizeof(ostream));
4598 /* constructors/destructors */
4599 pofs = call_func2(p_ofstream_ctor, &ofs, TRUE);
4600 pfb = (filebuf*) ofs.base_ios.sb;
4601 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4602 ok(ofs.unknown == 0, "expected 0 got %d\n", ofs.unknown);
4603 ok(ofs.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ofs.base_ios.sb);
4604 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4605 ok(ofs.base_ios.delbuf == 1, "expected 1 got %d\n", ofs.base_ios.delbuf);
4606 ok(ofs.base_ios.tie == NULL, "expected %p got %p\n", NULL, ofs.base_ios.tie);
4607 ok(ofs.base_ios.flags == 0x0, "expected %x got %x\n", 0x0, ofs.base_ios.flags);
4608 ok(ofs.base_ios.precision == 6, "expected 6 got %d\n", ofs.base_ios.precision);
4609 ok(ofs.base_ios.fill == ' ', "expected 32 got %d\n", ofs.base_ios.fill);
4610 ok(ofs.base_ios.width == 0, "expected 0 got %d\n", ofs.base_ios.width);
4611 ok(ofs.base_ios.do_lock == -1, "expected -1 got %d\n", ofs.base_ios.do_lock);
4612 ok(pfb->fd == -1, "wrong fd, expected -1 got %d\n", pfb->fd);
4613 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
4614 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
4615 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
4616 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
4617 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
4618 ok(pfb->fd == -1, "wrong fd, expected 0 got %d\n", pfb->fd);
4619 call_func1(p_ofstream_vbase_dtor, &ofs);
4621 pofs = call_func3(p_ofstream_fd_ctor, &ofs, 42, TRUE);
4622 pfb = (filebuf*) ofs.base_ios.sb;
4623 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4624 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4625 ok(ofs.base_ios.delbuf == 1, "expected 1 got %d\n", ofs.base_ios.delbuf);
4626 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
4627 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
4628 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
4629 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
4630 ok(pfb->fd == 42, "wrong fd, expected 42 got %d\n", pfb->fd);
4631 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
4633 pofs = call_func3(p_ofstream_copy_ctor, &ofs_copy, &ofs, TRUE);
4634 pfb = (filebuf*) ofs_copy.base_ios.sb;
4635 ok(pofs == &ofs_copy, "wrong return, expected %p got %p\n", &ofs_copy, pofs);
4636 ok(ofs_copy.base_ios.sb == ofs.base_ios.sb, "expected shared streambuf\n");
4637 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4638 ok(ofs_copy.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs_copy.base_ios.state);
4640 call_func1(p_ofstream_vbase_dtor, &ofs_copy);
4641 call_func1(p_ofstream_dtor, &ofs.base_ios);
4643 pofs = call_func5(p_ofstream_buffer_ctor, &ofs, 53, buffer, ARRAY_SIZE(buffer), TRUE);
4644 pfb = (filebuf*) ofs.base_ios.sb;
4645 ok(ofs.base_ios.delbuf == 1, "expected 1 got %d\n", ofs.base_ios.delbuf);
4646 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4647 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4648 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
4649 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
4650 ok(pfb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pfb->base.base);
4651 ok(pfb->base.ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), pfb->base.ebuf);
4652 ok(pfb->fd == 53, "wrong fd, expected 53 got %d\n", pfb->fd);
4653 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
4654 call_func1(p_ofstream_dtor, &ofs.base_ios);
4656 pofs = call_func5(p_ofstream_buffer_ctor, &ofs, 64, NULL, 0, TRUE);
4657 pfb = (filebuf*) ofs.base_ios.sb;
4658 ok(ofs.base_ios.delbuf == 1, "expected 1 got %d\n", ofs.base_ios.delbuf);
4659 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4660 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4661 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4662 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
4663 ok(pfb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pfb->base.unbuffered);
4664 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
4665 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
4666 ok(pfb->fd == 64, "wrong fd, expected 64 got %d\n", pfb->fd);
4667 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
4668 call_func1(p_ofstream_vbase_dtor, &ofs);
4670 pofs = call_func5(p_ofstream_open_ctor, &ofs, filename, OPENMODE_out, filebuf_openprot, TRUE);
4671 pfb = (filebuf*) ofs.base_ios.sb;
4672 ok(ofs.base_ios.delbuf == 1, "expected 1 got %d\n", ofs.base_ios.delbuf);
4673 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4674 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4675 ok(pfb->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pfb->base.allocated);
4676 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
4677 ok(pfb->base.base != NULL, "wrong buffer, expected not %p got %p\n", NULL, pfb->base.base);
4678 ok(pfb->base.ebuf != NULL, "wrong ebuf, expected not %p got %p\n", NULL, pfb->base.ebuf);
4679 ok(pfb->fd != -1, "wrong fd, expected not -1 got %d\n", pfb->fd);
4680 fd = pfb->fd;
4681 ok(pfb->close == 1, "wrong value, expected 1 got %d\n", pfb->close);
4682 call_func1(p_ofstream_vbase_dtor, &ofs);
4683 ok(_close(fd) == -1, "expected ofstream to close opened file\n");
4684 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
4686 /* setbuf */
4687 call_func5(p_ofstream_buffer_ctor, &ofs, -1, NULL, 0, TRUE);
4688 ok(ofs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4689 ok(ofs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4690 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4691 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4693 psb = call_func3(p_ofstream_setbuf, &ofs, buffer, ARRAY_SIZE(buffer));
4694 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4695 ok(ofs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ofs.base_ios.sb->base);
4696 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4697 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4698 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4699 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4701 psb = call_func3(p_ofstream_setbuf, &ofs, NULL, 0);
4702 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4703 ok(ofs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ofs.base_ios.sb->base);
4704 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4705 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4706 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4707 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4708 call_func1(p_ofstream_vbase_dtor, &ofs);
4710 call_func2(p_ofstream_ctor, &ofs, TRUE);
4711 ok(ofs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4712 ok(ofs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4713 ok(ofs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ofs.base_ios.sb->unbuffered);
4714 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4715 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4717 psb = call_func3(p_ofstream_setbuf, &ofs, buffer, ARRAY_SIZE(buffer));
4718 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4719 ok(ofs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ofs.base_ios.sb->base);
4720 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4721 ok(ofs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ofs.base_ios.sb->unbuffered);
4722 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4723 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4725 psb = call_func3(p_ofstream_setbuf, &ofs, NULL, 0);
4726 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4727 ok(ofs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ofs.base_ios.sb->base);
4728 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4729 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4730 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4731 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4733 psb = call_func3(p_ofstream_setbuf, &ofs, buffer + 8, ARRAY_SIZE(buffer) - 8);
4734 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4735 ok(ofs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, ofs.base_ios.sb->base);
4736 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4737 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4738 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4739 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4741 psb = call_func3(p_ofstream_setbuf, &ofs, buffer + 8, 0);
4742 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4743 ok(ofs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, ofs.base_ios.sb->base);
4744 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4745 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4746 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4747 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4749 psb = call_func3(p_ofstream_setbuf, &ofs, buffer + 4, ARRAY_SIZE(buffer) - 4);
4750 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4751 ok(ofs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, ofs.base_ios.sb->base);
4752 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4753 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4754 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4755 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4757 psb = call_func3(p_ofstream_setbuf, &ofs, NULL, 5);
4758 ok(psb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, psb);
4759 ok(ofs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, ofs.base_ios.sb->base);
4760 ok(ofs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ofs.base_ios.sb->ebuf);
4761 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4762 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4763 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4764 call_func1(p_ofstream_vbase_dtor, &ofs);
4766 /* setbuf - seems to be a nop and always return NULL in those other cases */
4767 pofs = call_func5(p_ofstream_buffer_ctor, &ofs, 42, NULL, 0, TRUE);
4768 ok(ofs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4769 ok(ofs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4770 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4771 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4773 ofs.base_ios.state = IOSTATE_eofbit;
4774 psb = call_func3(p_ofstream_setbuf, &ofs, buffer, ARRAY_SIZE(buffer));
4775 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
4776 ok(ofs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4777 ok(ofs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4778 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4779 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4780 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
4782 ofs.base_ios.state = IOSTATE_eofbit;
4783 psb = call_func3(p_ofstream_setbuf, &ofs, NULL, 0);
4784 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
4785 ok(ofs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4786 ok(ofs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4787 ok(ofs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ofs.base_ios.sb->unbuffered);
4788 ok(ofs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ofs.base_ios.sb->allocated);
4789 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
4790 call_func1(p_ofstream_vbase_dtor, &ofs);
4792 pofs = call_func5(p_ofstream_open_ctor, &ofs, filename, OPENMODE_out, filebuf_openprot, TRUE);
4793 ofs.base_ios.state = IOSTATE_eofbit;
4794 psb = call_func3(p_ofstream_setbuf, &ofs, NULL, 0);
4795 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
4796 ok(ofs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4797 ok(ofs.base_ios.sb->ebuf != NULL, "wrong ebuf value, expected NULL got %p\n", ofs.base_ios.sb->ebuf);
4798 ok(ofs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ofs.base_ios.sb->unbuffered);
4799 ok(ofs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", ofs.base_ios.sb->allocated);
4800 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
4802 ofs.base_ios.state = IOSTATE_eofbit;
4803 psb = call_func3(p_ofstream_setbuf, &ofs, buffer, ARRAY_SIZE(buffer));
4804 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
4805 ok(ofs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", ofs.base_ios.sb->base);
4806 ok(ofs.base_ios.sb->base != buffer, "wrong base value, expected not %p got %p\n", buffer, ofs.base_ios.sb->base);
4807 ok(ofs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ofs.base_ios.sb->unbuffered);
4808 ok(ofs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", ofs.base_ios.sb->allocated);
4809 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
4810 call_func1(p_ofstream_vbase_dtor, &ofs);
4811 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
4813 /* attach */
4814 pofs = call_func2(p_ofstream_ctor, &ofs, TRUE);
4815 pfb = (filebuf*) ofs.base_ios.sb;
4816 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4817 call_func2(p_ofstream_attach, &ofs, 42);
4818 ok(ofs.base_ios.state == IOSTATE_goodbit, "attaching on vanilla stream set some state bits\n");
4819 fd = (int) call_func1(p_ofstream_fd, &ofs);
4820 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
4821 ok(pfb->close == 0, "wrong close value, expected 0 got %d\n", pfb->close);
4822 ofs.base_ios.state = IOSTATE_eofbit;
4823 call_func2(p_ofstream_attach, &ofs, 53);
4824 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
4825 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
4826 call_func1(p_ofstream_vbase_dtor, &ofs);
4828 /* fd */
4829 pofs = call_func2(p_ofstream_ctor, &ofs, TRUE);
4830 pfb = (filebuf*) ofs.base_ios.sb;
4831 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4832 fd = (int) call_func1(p_ofstream_fd, &ofs);
4833 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4834 ok(fd == -1, "wrong fd, expected -1 but got %d\n", fd);
4835 call_func1(p_ofstream_vbase_dtor, &ofs);
4837 pofs = call_func5(p_ofstream_open_ctor, &ofs, filename, OPENMODE_out, filebuf_openprot, TRUE);
4838 pfb = (filebuf*) ofs.base_ios.sb;
4839 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4840 fd = (int) call_func1(p_ofstream_fd, &ofs);
4841 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4842 ok(fd == pfb->fd, "wrong fd, expected %d but got %d\n", pfb->fd, fd);
4844 /* rdbuf */
4845 pfb = (filebuf*) call_func1(p_ofstream_rdbuf, &ofs);
4846 ok((streambuf*) pfb == ofs.base_ios.sb, "wrong return, expected %p got %p\n", ofs.base_ios.sb, pfb);
4847 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4849 /* setmode */
4850 ret = (int) call_func2(p_ofstream_setmode, &ofs, filebuf_binary);
4851 ok(ret == filebuf_text, "wrong return, expected %d got %d\n", filebuf_text, ret);
4852 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4853 ret = (int) call_func2(p_ofstream_setmode, &ofs, filebuf_binary);
4854 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
4855 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4856 ret = (int) call_func2(p_ofstream_setmode, &ofs, filebuf_text);
4857 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
4858 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4859 ret = (int) call_func2(p_ofstream_setmode, &ofs, 0x9000);
4860 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
4861 ok(ofs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ofs.base_ios.state);
4863 /* close && is_open */
4864 ok((int) call_func1(p_ofstream_is_open, &ofs) == 1, "expected ofstream to be open\n");
4865 ofs.base_ios.state = IOSTATE_eofbit | IOSTATE_failbit;
4866 call_func1(p_ofstream_close, &ofs);
4867 ok(ofs.base_ios.state == IOSTATE_goodbit, "close did not clear state = %d\n", ofs.base_ios.state);
4868 ofs.base_ios.state = IOSTATE_eofbit;
4869 call_func1(p_ofstream_close, &ofs);
4870 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "close on a closed stream did not set failbit\n");
4871 ok((int) call_func1(p_ofstream_is_open, &ofs) == 0, "expected ofstream to not be open\n");
4872 ok(_close(fd) == -1, "expected close to close the opened file\n");
4874 /* open */
4875 ofs.base_ios.state = IOSTATE_eofbit;
4876 call_func4(p_ofstream_open, &ofs, filename, OPENMODE_out, filebuf_openprot);
4877 fd = (int) call_func1(p_ofstream_fd, &ofs);
4878 ok(fd != -1, "wrong fd, expected not -1 got %d\n", fd);
4879 ok(ofs.base_ios.state == IOSTATE_eofbit, "open did not succeed\n");
4880 call_func4(p_ofstream_open, &ofs, filename, OPENMODE_out, filebuf_openprot);
4881 ok(ofs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "second open did not set failbit\n");
4882 call_func1(p_ofstream_close, &ofs);
4884 /* integration with parent ostream - writing */
4885 ofs.base_ios.state = IOSTATE_goodbit; /* open doesn't clear the state */
4886 call_func4(p_ofstream_open, &ofs, filename, OPENMODE_in, filebuf_openprot); /* make sure that OPENMODE_out is implicit */
4887 pofs = call_func2(p_ostream_print_str, &ofs, "test ");
4888 ok(pofs == &ofs, "stream operation returned wrong pointer, expected %p got %p\n", &ofs, pofs);
4889 pofs = call_func2(p_ostream_print_int, &ofs, 12);
4890 ok(pofs == &ofs, "stream operation returned wrong pointer, expected %p got %p\n", &ofs, pofs);
4891 call_func1(p_ofstream_close, &ofs);
4893 /* read what we wrote */
4894 memset(st, 'A', sizeof(st));
4895 st[7] = 0;
4896 fd = _open(filename, _O_RDONLY, _S_IREAD);
4897 ok(fd != -1, "_open failed\n");
4898 ok(_read(fd, st, 7) == 7, "_read failed\n");
4899 ok(_close(fd) == 0, "_close failed\n");
4900 ok(!strcmp(st, "test 12"), "expected 'test 12' got '%s'\n", st);
4901 call_func1(p_ofstream_vbase_dtor, &ofs);
4902 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
4904 /* make sure that OPENMODE_out is implicit with open_ctor */
4905 pofs = call_func5(p_ofstream_open_ctor, &ofs, filename, OPENMODE_in, filebuf_openprot, TRUE);
4906 ok(pofs == &ofs, "wrong return, expected %p got %p\n", &ofs, pofs);
4907 pofs = call_func2(p_ostream_print_str, &ofs, "test ");
4908 ok(pofs == &ofs, "stream operation returned wrong pointer, expected %p got %p\n", &ofs, pofs);
4909 pofs = call_func2(p_ostream_print_int, &ofs, 12);
4910 ok(pofs == &ofs, "stream operation returned wrong pointer, expected %p got %p\n", &ofs, pofs);
4911 call_func1(p_ofstream_close, &ofs);
4913 memset(st, 'A', sizeof(st));
4914 st[7] = 0;
4915 fd = _open(filename, _O_RDONLY, _S_IREAD);
4916 ok(fd != -1, "_open failed\n");
4917 ok(_read(fd, st, 7) == 7, "_read failed\n");
4918 ok(_close(fd) == 0, "_close failed\n");
4919 ok(!strcmp(st, "test 12"), "expected 'test 12' got '%s'\n", st);
4920 call_func1(p_ofstream_vbase_dtor, &ofs);
4921 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
4924 static void test_istream(void)
4926 istream is1, is2, *pis;
4927 ostream os, *pos;
4928 filebuf fb1, fb2, *pfb;
4929 const char filename1[] = "test1";
4930 const char filename2[] = "test2";
4931 int fd, ret;
4932 char buffer[32], c;
4934 memset(&is1, 0xab, sizeof(istream));
4935 memset(&is2, 0xab, sizeof(istream));
4936 memset(&fb1, 0xab, sizeof(filebuf));
4937 memset(&fb2, 0xab, sizeof(filebuf));
4939 /* constructors/destructors */
4940 pis = call_func3(p_istream_sb_ctor, &is1, NULL, TRUE);
4941 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
4942 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
4943 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
4944 ok(is1.base_ios.sb == NULL, "expected %p got %p\n", NULL, is1.base_ios.sb);
4945 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
4946 ok(is1.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is1.base_ios.flags);
4947 call_func1(p_istream_vbase_dtor, &is1);
4948 is1.extract_delim = is1.count = 0xabababab;
4949 memset(&is1.base_ios, 0xab, sizeof(ios));
4950 is1.base_ios.delbuf = 0;
4951 pis = call_func3(p_istream_sb_ctor, &is1, NULL, FALSE);
4952 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
4953 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
4954 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
4955 ok(is1.base_ios.sb == NULL, "expected %p got %p\n", NULL, is1.base_ios.sb);
4956 ok(is1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
4957 0xabababab|IOSTATE_badbit, is1.base_ios.state);
4958 ok(is1.base_ios.flags == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.flags);
4959 call_func1(p_istream_dtor, &is1.base_ios);
4960 pis = call_func3(p_istream_sb_ctor, &is1, &fb1.base, FALSE);
4961 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
4962 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
4963 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
4964 ok(is1.base_ios.sb == &fb1.base, "expected %p got %p\n", &fb1.base, is1.base_ios.sb);
4965 ok(is1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.state);
4966 ok(is1.base_ios.flags == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.flags);
4967 call_func1(p_istream_dtor, &is1.base_ios);
4968 call_func1(p_filebuf_ctor, &fb1);
4969 pfb = call_func4(p_filebuf_open, &fb1, filename1, OPENMODE_in|OPENMODE_out, filebuf_openprot);
4970 ok(pfb == &fb1, "wrong return, expected %p got %p\n", &fb1, pfb);
4971 ok(fb1.base.allocated == 1, "expected %d got %d\n", 1, fb1.base.allocated);
4972 pis = call_func3(p_istream_sb_ctor, &is1, &fb1.base, TRUE);
4973 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
4974 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
4975 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
4976 ok(is1.base_ios.sb == &fb1.base, "expected %p got %p\n", &fb1.base, is1.base_ios.sb);
4977 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
4978 ok(is1.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is1.base_ios.flags);
4979 pis = call_func2(p_istream_ctor, &is2, TRUE);
4980 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
4981 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
4982 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
4983 ok(is2.base_ios.sb == NULL, "expected %p got %p\n", NULL, is2.base_ios.sb);
4984 ok(is2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is2.base_ios.state);
4985 ok(is2.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is2.base_ios.flags);
4986 call_func1(p_istream_vbase_dtor, &is2);
4987 is2.extract_delim = is2.count = 0xabababab;
4988 memset(&is2.base_ios, 0xab, sizeof(ios));
4989 is2.base_ios.flags &= ~FLAGS_skipws;
4990 pis = call_func2(p_istream_ctor, &is2, FALSE);
4991 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
4992 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
4993 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
4994 ok(is2.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is2.base_ios.sb);
4995 ok(is2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.state);
4996 ok(is2.base_ios.flags == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.flags);
4997 call_func1(p_istream_dtor, &is2.base_ios);
4998 is1.extract_delim = is1.count = 0xcdcdcdcd;
4999 is1.base_ios.state = 0xcdcdcdcd;
5000 is1.base_ios.flags &= ~FLAGS_skipws;
5001 is2.extract_delim = is2.count = 0xabababab;
5002 memset(&is2.base_ios, 0xab, sizeof(ios));
5003 is2.base_ios.flags &= ~FLAGS_skipws;
5004 is2.base_ios.delbuf = 0;
5005 pis = call_func3(p_istream_copy_ctor, &is2, &is1, FALSE);
5006 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
5007 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
5008 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
5009 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
5010 ok(is2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.state);
5011 ok(is2.base_ios.flags == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.flags);
5012 call_func1(p_istream_dtor, &is2.base_ios);
5013 is2.extract_delim = is2.count = 0xabababab;
5014 memset(&is2.base_ios, 0xab, sizeof(ios));
5015 pis = call_func3(p_istream_copy_ctor, &is2, &is1, TRUE);
5016 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
5017 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
5018 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
5019 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
5020 ok(is2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is2.base_ios.state);
5021 ok(is2.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is2.base_ios.flags);
5023 /* assignment */
5024 is2.extract_delim = is2.count = 0xabababab;
5025 is2.base_ios.sb = (streambuf*) 0xabababab;
5026 is2.base_ios.state = 0xabababab;
5027 is2.base_ios.special[0] = 0xabababab;
5028 is2.base_ios.delbuf = 0;
5029 is2.base_ios.tie = (ostream*) 0xabababab;
5030 is2.base_ios.flags = 0xabababab;
5031 is2.base_ios.precision = 0xabababab;
5032 is2.base_ios.width = 0xabababab;
5033 pis = call_func2(p_istream_assign, &is2, &is1);
5034 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
5035 ok(is2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, is2.extract_delim);
5036 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
5037 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
5038 ok(is2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is2.base_ios.state);
5039 ok(is2.base_ios.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.fill);
5040 ok(is2.base_ios.delbuf == 0, "expected 0 got %d\n", is2.base_ios.delbuf);
5041 ok(is2.base_ios.tie == NULL, "expected %p got %p\n", NULL, is2.base_ios.tie);
5042 ok(is2.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is2.base_ios.flags);
5043 ok(is2.base_ios.precision == 6, "expected 6 got %d\n", is2.base_ios.precision);
5044 ok(is2.base_ios.width == 0, "expected 0 got %d\n", is2.base_ios.width);
5045 if (0) /* crashes on native */
5046 pis = call_func2(p_istream_assign, &is2, NULL);
5047 is2.extract_delim = is2.count = 0xabababab;
5048 is2.base_ios.sb = (streambuf*) 0xabababab;
5049 is2.base_ios.state = 0xabababab;
5050 is2.base_ios.special[0] = 0xabababab;
5051 is2.base_ios.delbuf = 0;
5052 is2.base_ios.tie = (ostream*) 0xabababab;
5053 is2.base_ios.flags = 0xabababab;
5054 is2.base_ios.precision = 0xabababab;
5055 is2.base_ios.width = 0xabababab;
5056 pis = call_func2(p_istream_assign_sb, &is2, NULL);
5057 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
5058 ok(is2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, is2.extract_delim);
5059 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
5060 ok(is2.base_ios.sb == NULL, "expected %p got %p\n", NULL, is2.base_ios.sb);
5061 ok(is2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is2.base_ios.state);
5062 ok(is2.base_ios.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.fill);
5063 ok(is2.base_ios.delbuf == 0, "expected 0 got %d\n", is2.base_ios.delbuf);
5064 ok(is2.base_ios.tie == NULL, "expected %p got %p\n", NULL, is2.base_ios.tie);
5065 ok(is2.base_ios.flags == FLAGS_skipws, "expected %d got %d\n", FLAGS_skipws, is2.base_ios.flags);
5066 ok(is2.base_ios.precision == 6, "expected 6 got %d\n", is2.base_ios.precision);
5067 ok(is2.base_ios.width == 0, "expected 0 got %d\n", is2.base_ios.width);
5068 call_func1(p_filebuf_ctor, &fb2);
5069 pfb = call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in|OPENMODE_out, filebuf_openprot);
5070 ok(pfb == &fb2, "wrong return, expected %p got %p\n", &fb2, pfb);
5071 ok(fb2.base.allocated == 1, "expected %d got %d\n", 1, fb2.base.allocated);
5072 pis = call_func2(p_istream_assign_sb, &is2, &fb2.base);
5073 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
5074 ok(is2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, is2.extract_delim);
5075 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
5076 ok(is2.base_ios.sb == &fb2.base, "expected %p got %p\n", &fb2.base, is2.base_ios.sb);
5077 ok(is2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is2.base_ios.state);
5079 /* eatwhite */
5080 is1.extract_delim = is1.count = 0;
5081 if (0) /* crashes on native */
5082 is1.base_ios.sb = NULL;
5083 is1.base_ios.state = IOSTATE_badbit;
5084 is1.base_ios.flags = 0;
5085 call_func1(p_istream_eatwhite, &is1);
5086 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_eofbit), "expected %d got %d\n",
5087 IOSTATE_badbit|IOSTATE_eofbit, is1.base_ios.state);
5088 is1.base_ios.state = IOSTATE_failbit;
5089 call_func1(p_istream_eatwhite, &is1);
5090 ok(is1.base_ios.state == (IOSTATE_failbit|IOSTATE_eofbit), "expected %d got %d\n",
5091 IOSTATE_failbit|IOSTATE_eofbit, is1.base_ios.state);
5092 is1.base_ios.state = IOSTATE_goodbit;
5093 ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "And if \tyou ask\n\v\f\r me", 23);
5094 ok(ret == 23, "expected 23 got %d\n", ret);
5095 ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
5096 ok(fb1.base.pptr == fb1.base.base + 23, "wrong put pointer, expected %p got %p\n", fb1.base.base + 23, fb1.base.pptr);
5097 call_func1(p_istream_eatwhite, &is1);
5098 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5099 ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
5100 ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
5101 ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
5102 is1.base_ios.state = IOSTATE_goodbit;
5103 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 0, SEEKDIR_beg, 0);
5104 ok(ret == 0, "expected 0 got %d\n", ret);
5105 call_func1(p_istream_eatwhite, &is1);
5106 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5107 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5108 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
5109 ok(fb1.base.egptr == fb1.base.base + 23, "wrong get end, expected %p got %p\n", fb1.base.base + 23, fb1.base.egptr);
5110 ret = (int) call_func4(p_filebuf_seekoff, &fb1, 3, SEEKDIR_beg, 0);
5111 ok(ret == 3, "expected 3 got %d\n", ret);
5112 call_func1(p_istream_eatwhite, &is1);
5113 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5114 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5115 ok(fb1.base.gptr == fb1.base.base + 1, "wrong get pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.gptr);
5116 ok(fb1.base.egptr == fb1.base.base + 20, "wrong get end, expected %p got %p\n", fb1.base.base + 20, fb1.base.egptr);
5117 fb1.base.gptr += 2;
5118 call_func1(p_istream_eatwhite, &is1);
5119 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5120 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5121 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5122 ok(fb1.base.egptr == fb1.base.base + 20, "wrong get end, expected %p got %p\n", fb1.base.base + 20, fb1.base.egptr);
5123 fb1.base.gptr += 7;
5124 call_func1(p_istream_eatwhite, &is1);
5125 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5126 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5127 ok(fb1.base.gptr == fb1.base.base + 18, "wrong get pointer, expected %p got %p\n", fb1.base.base + 18, fb1.base.gptr);
5128 ok(fb1.base.egptr == fb1.base.base + 20, "wrong get end, expected %p got %p\n", fb1.base.base + 20, fb1.base.egptr);
5129 fb1.base.gptr += 9;
5130 call_func1(p_istream_eatwhite, &is1);
5131 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5132 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5133 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5134 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5136 /* ipfx */
5137 is1.count = 0xabababab;
5138 ret = (int) call_func2(p_istream_ipfx, &is1, 0);
5139 ok(ret == 0, "expected 0 got %d\n", ret);
5140 ok(is1.count == 0xabababab, "expected %d got %d\n", 0xabababab, is1.count);
5141 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5142 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5143 is1.base_ios.state = IOSTATE_badbit;
5144 ret = (int) call_func2(p_istream_ipfx, &is1, 1);
5145 ok(ret == 0, "expected 0 got %d\n", ret);
5146 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5147 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5148 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5149 if (0) /* crashes on native */
5150 is1.base_ios.sb = NULL;
5151 is1.base_ios.state = IOSTATE_goodbit;
5152 is1.base_ios.tie = &os;
5153 pos = call_func3(p_ostream_sb_ctor, &os, &fb2.base, TRUE);
5154 ok(pos == &os, "wrong return, expected %p got %p\n", &os, pos);
5155 ret = (int) call_func3(p_streambuf_xsputn, &fb2.base, "how I'm feeling", 15);
5156 ok(ret == 15, "expected 15 got %d\n", ret);
5157 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5158 ok(fb2.base.pptr == fb2.base.base + 15, "wrong put pointer, expected %p got %p\n", fb2.base.base + 15, fb2.base.pptr);
5159 is1.count = -1;
5160 ret = (int) call_func2(p_istream_ipfx, &is1, 0);
5161 ok(ret == 1, "expected 1 got %d\n", ret);
5162 ok(is1.count == -1, "expected -1 got %d\n", is1.count);
5163 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5164 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5165 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5166 ret = (int) call_func3(p_streambuf_xsputn, &fb2.base, "Don't tell me", 13);
5167 ok(ret == 13, "expected 13 got %d\n", ret);
5168 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5169 ok(fb2.base.pptr == fb2.base.base + 13, "wrong put pointer, expected %p got %p\n", fb2.base.base + 13, fb2.base.pptr);
5170 ret = (int) call_func2(p_istream_ipfx, &is1, 1);
5171 ok(ret == 1, "expected 1 got %d\n", ret);
5172 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5173 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5174 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5175 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5176 ret = (int) call_func3(p_streambuf_xsputn, &fb2.base, "you're too blind to see", 23);
5177 ok(ret == 23, "expected 23 got %d\n", ret);
5178 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5179 ok(fb2.base.pptr == fb2.base.base + 23, "wrong put pointer, expected %p got %p\n", fb2.base.base + 23, fb2.base.pptr);
5180 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5181 fb1.base.egptr = fb1.base.base + 15;
5182 strcpy(fb1.base.eback, "Never \t gonna ");
5183 ret = (int) call_func2(p_istream_ipfx, &is1, 1);
5184 ok(ret == 1, "expected 1 got %d\n", ret);
5185 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5186 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5187 ok(fb2.base.pptr == fb2.base.base + 23, "wrong put pointer, expected %p got %p\n", fb2.base.base + 23, fb2.base.pptr);
5188 fb1.base.gptr = fb1.base.base + 4;
5189 is1.count = 10;
5190 ret = (int) call_func2(p_istream_ipfx, &is1, 11);
5191 ok(ret == 1, "expected 1 got %d\n", ret);
5192 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5193 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5194 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5195 ok(fb2.base.pptr == fb2.base.base + 23, "wrong put pointer, expected %p got %p\n", fb2.base.base + 23, fb2.base.pptr);
5196 fd = fb2.fd;
5197 fb2.fd = -1;
5198 ret = (int) call_func2(p_istream_ipfx, &is1, 12);
5199 ok(ret == 1, "expected 1 got %d\n", ret);
5200 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5201 ok(os.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, os.base_ios.state);
5202 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5203 ok(fb2.base.pptr == fb2.base.base + 23, "wrong put pointer, expected %p got %p\n", fb2.base.base + 23, fb2.base.pptr);
5204 os.base_ios.state = IOSTATE_goodbit;
5205 fb2.fd = fd;
5206 ret = (int) call_func2(p_istream_ipfx, &is1, 12);
5207 ok(ret == 1, "expected 1 got %d\n", ret);
5208 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5209 ok(os.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os.base_ios.state);
5210 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5211 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5212 is1.base_ios.flags = 0;
5213 fb1.base.gptr = fb1.base.base + 5;
5214 ret = (int) call_func2(p_istream_ipfx, &is1, 0);
5215 ok(ret == 1, "expected 1 got %d\n", ret);
5216 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5217 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5218 ret = (int) call_func2(p_istream_ipfx, &is1, 1);
5219 ok(ret == 1, "expected 1 got %d\n", ret);
5220 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5221 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5222 is1.base_ios.flags = FLAGS_skipws;
5223 ret = (int) call_func2(p_istream_ipfx, &is1, 1);
5224 ok(ret == 1, "expected 1 got %d\n", ret);
5225 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5226 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5227 ret = (int) call_func2(p_istream_ipfx, &is1, -1);
5228 ok(ret == 1, "expected 1 got %d\n", ret);
5229 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5230 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5231 ret = (int) call_func2(p_istream_ipfx, &is1, 0);
5232 ok(ret == 1, "expected 1 got %d\n", ret);
5233 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5234 ok(fb1.base.gptr == fb1.base.base + 9, "wrong get pointer, expected %p got %p\n", fb1.base.base + 9, fb1.base.gptr);
5235 fb1.base.gptr = fb1.base.base + 14;
5236 fb2.base.pbase = fb2.base.base;
5237 fb2.base.pptr = fb2.base.epptr = fb2.base.base + 23;
5238 ret = (int) call_func2(p_istream_ipfx, &is1, 0);
5239 ok(ret == 0, "expected 0 got %d\n", ret);
5240 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5241 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5242 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5243 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5244 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5246 /* get_str_delim */
5247 is1.extract_delim = is1.count = 0xabababab;
5248 is1.base_ios.state = IOSTATE_badbit;
5249 memset(buffer, 'A', sizeof(buffer));
5250 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 30, 0);
5251 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5252 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5253 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5254 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5255 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5256 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5257 is1.extract_delim = is1.count = 0xabababab;
5258 is1.base_ios.state = IOSTATE_goodbit;
5259 memset(buffer, 'A', sizeof(buffer));
5260 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 30, 0);
5261 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5262 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5263 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5264 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5265 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5266 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5267 is1.extract_delim = is1.count = 0xabababab;
5268 is1.base_ios.state = IOSTATE_goodbit;
5269 is1.base_ios.flags = 0;
5270 memset(buffer, 'A', sizeof(buffer));
5271 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 0, 0);
5272 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5273 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5274 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5275 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5276 ok(buffer[0] == 'A', "expected 65 got %d\n", buffer[0]);
5277 is1.extract_delim = is1.count = 0xabababab;
5278 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5279 fb1.base.egptr = fb1.base.base + 30;
5280 strcpy(fb1.base.base, " give \n you 11 ! up\t. ");
5281 memset(buffer, 'A', sizeof(buffer));
5282 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 30, 0);
5283 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5284 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5285 ok(is1.count == 29, "expected 29 got %d\n", is1.count);
5286 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5287 ok(fb1.base.gptr == fb1.base.base + 29, "wrong get pointer, expected %p got %p\n", fb1.base.base + 29, fb1.base.gptr);
5288 ok(!strncmp(buffer, fb1.base.base, 29), "unexpected buffer content, got '%s'\n", buffer);
5289 ok(buffer[29] == 0, "expected 0 got %d\n", buffer[29]);
5290 fb1.base.gptr = fb1.base.egptr;
5291 memset(buffer, 'A', sizeof(buffer));
5292 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 1, 0);
5293 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5294 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5295 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5296 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5297 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5298 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5299 is1.base_ios.flags = FLAGS_skipws;
5300 fb1.base.gptr = fb1.base.base;
5301 memset(buffer, 'A', sizeof(buffer));
5302 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, 0);
5303 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5304 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5305 ok(is1.count == 19, "expected 19 got %d\n", is1.count);
5306 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5307 ok(fb1.base.gptr == fb1.base.base + 19, "wrong get pointer, expected %p got %p\n", fb1.base.base + 19, fb1.base.gptr);
5308 ok(!strncmp(buffer, fb1.base.base, 19), "unexpected buffer content, got '%s'\n", buffer);
5309 ok(buffer[19] == 0, "expected 0 got %d\n", buffer[19]);
5310 fb1.base.gptr = fb1.base.base + 20;
5311 memset(buffer, 'A', sizeof(buffer));
5312 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, 0);
5313 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5314 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5315 ok(is1.count == 10, "expected 10 got %d\n", is1.count);
5316 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5317 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5318 ok(!strncmp(buffer, fb1.base.base + 20, 10), "unexpected buffer content, got '%s'\n", buffer);
5319 ok(buffer[10] == 0, "expected 0 got %d\n", buffer[10]);
5320 is1.extract_delim = 1;
5321 is1.base_ios.state = IOSTATE_goodbit;
5322 fb1.base.eback = fb1.base.base;
5323 fb1.base.gptr = fb1.base.base + 20;
5324 fb1.base.egptr = fb1.base.base + 30;
5325 memset(buffer, 'A', sizeof(buffer));
5326 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, -1);
5327 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5328 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5329 ok(is1.count == 10, "expected 10 got %d\n", is1.count);
5330 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5331 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5332 ok(!strncmp(buffer, fb1.base.base + 20, 10), "unexpected buffer content, got '%s'\n", buffer);
5333 ok(buffer[10] == 0, "expected 0 got %d\n", buffer[10]);
5334 is1.base_ios.state = IOSTATE_goodbit;
5335 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5336 fb1.base.egptr = fb1.base.base + 30;
5337 memset(buffer, 'A', sizeof(buffer));
5338 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, '\n');
5339 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5340 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5341 ok(is1.count == 9, "expected 9 got %d\n", is1.count);
5342 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5343 ok(fb1.base.gptr == fb1.base.base + 9, "wrong get pointer, expected %p got %p\n", fb1.base.base + 9, fb1.base.gptr);
5344 ok(!strncmp(buffer, fb1.base.base, 9), "unexpected buffer content, got '%s'\n", buffer);
5345 ok(buffer[9] == 0, "expected 0 got %d\n", buffer[9]);
5346 memset(buffer, 'A', sizeof(buffer));
5347 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, '\n');
5348 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5349 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5350 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5351 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5352 ok(fb1.base.gptr == fb1.base.base + 9, "wrong get pointer, expected %p got %p\n", fb1.base.base + 9, fb1.base.gptr);
5353 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5354 is1.extract_delim = 0xabababab;
5355 memset(buffer, 'A', sizeof(buffer));
5356 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, '\n');
5357 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5358 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5359 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5360 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5361 ok(fb1.base.gptr == fb1.base.base + 10, "wrong get pointer, expected %p got %p\n", fb1.base.base + 10, fb1.base.gptr);
5362 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5363 *fb1.base.gptr = -50;
5364 memset(buffer, 'A', sizeof(buffer));
5365 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 2, -50);
5366 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5367 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5368 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5369 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5370 ok(fb1.base.gptr == fb1.base.base + 11, "wrong get pointer, expected %p got %p\n", fb1.base.base + 11, fb1.base.gptr);
5371 ok((signed char)buffer[0] == -50, "expected 0 got %d\n", buffer[0]);
5372 ok(buffer[1] == 0, "expected 0 got %d\n", buffer[1]);
5373 *fb1.base.gptr = -50;
5374 memset(buffer, 'A', sizeof(buffer));
5375 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 2, 206);
5376 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5377 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5378 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5379 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5380 ok(fb1.base.gptr == fb1.base.base + 11, "wrong get pointer, expected %p got %p\n", fb1.base.base + 11, fb1.base.gptr);
5381 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5382 is1.extract_delim = 3;
5383 memset(buffer, 'A', sizeof(buffer));
5384 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 2, 206);
5385 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5386 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5387 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5388 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5389 ok(fb1.base.gptr == fb1.base.base + 12, "wrong get pointer, expected %p got %p\n", fb1.base.base + 12, fb1.base.gptr);
5390 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5391 memset(buffer, 'A', sizeof(buffer));
5392 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 20, '!');
5393 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5394 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5395 ok(is1.count == 6, "expected 6 got %d\n", is1.count);
5396 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5397 ok(fb1.base.gptr == fb1.base.base + 18, "wrong get pointer, expected %p got %p\n", fb1.base.base + 18, fb1.base.gptr);
5398 ok(!strncmp(buffer, fb1.base.base + 12, 6), "unexpected buffer content, got '%s'\n", buffer);
5399 ok(buffer[6] == 0, "expected 0 got %d\n", buffer[6]);
5400 pis = call_func4(p_istream_get_str_delim, &is1, NULL, 5, 0);
5401 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5402 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5403 ok(is1.count == 4, "expected 4 got %d\n", is1.count);
5404 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5405 ok(fb1.base.gptr == fb1.base.base + 22, "wrong get pointer, expected %p got %p\n", fb1.base.base + 22, fb1.base.gptr);
5406 fb1.base.gptr = fb1.base.egptr;
5407 memset(buffer, 'A', sizeof(buffer));
5408 pis = call_func4(p_istream_get_str_delim, &is1, buffer, 10, 0);
5409 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5410 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5411 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5412 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5413 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5414 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5415 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5416 if (0) /* crashes on native */
5417 pis = call_func4(p_istream_get_str_delim, &is1, (char*) 0x1, 5, 0);
5419 /* get_str */
5420 is1.extract_delim = is1.count = 0xabababab;
5421 is1.base_ios.state = IOSTATE_eofbit;
5422 memset(buffer, 'A', sizeof(buffer));
5423 pis = call_func4(p_istream_get_str, &is1, buffer, 10, 0);
5424 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5425 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5426 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5427 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5428 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5429 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5430 is1.base_ios.state = IOSTATE_goodbit;
5431 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5432 fb1.base.egptr = fb1.base.base + 30;
5433 memset(buffer, 'A', sizeof(buffer));
5434 pis = call_func4(p_istream_get_str, &is1, buffer, 20, 0);
5435 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5436 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5437 ok(is1.count == 19, "expected 19 got %d\n", is1.count);
5438 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5439 ok(fb1.base.gptr == fb1.base.base + 19, "wrong get pointer, expected %p got %p\n", fb1.base.base + 19, fb1.base.gptr);
5440 ok(!strncmp(buffer, fb1.base.base, 19), "unexpected buffer content, got '%s'\n", buffer);
5441 ok(buffer[19] == 0, "expected 0 got %d\n", buffer[19]);
5442 is1.extract_delim = -1;
5443 memset(buffer, 'A', sizeof(buffer));
5444 pis = call_func4(p_istream_get_str, &is1, buffer, 20, '\t');
5445 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5446 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5447 ok(is1.count == 4, "expected 4 got %d\n", is1.count);
5448 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5449 ok(fb1.base.gptr == fb1.base.base + 23, "wrong get pointer, expected %p got %p\n", fb1.base.base + 23, fb1.base.gptr);
5450 ok(!strncmp(buffer, fb1.base.base + 19, 3), "unexpected buffer content, got '%s'\n", buffer);
5451 ok(buffer[3] == 0, "expected 0 got %d\n", buffer[3]);
5452 *fb1.base.gptr = -50;
5453 memset(buffer, 'A', sizeof(buffer));
5454 pis = call_func4(p_istream_get_str, &is1, buffer, 5, -50);
5455 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5456 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5457 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5458 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5459 ok(fb1.base.gptr == fb1.base.base + 23, "wrong get pointer, expected %p got %p\n", fb1.base.base + 23, fb1.base.gptr);
5460 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5461 *(fb1.base.gptr + 1) = -40;
5462 *(fb1.base.gptr + 2) = -30;
5463 memset(buffer, 'A', sizeof(buffer));
5464 pis = call_func4(p_istream_get_str, &is1, buffer, 5, -30);
5465 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5466 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5467 ok(is1.count == 2, "expected 2 got %d\n", is1.count);
5468 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5469 ok(fb1.base.gptr == fb1.base.base + 25, "wrong get pointer, expected %p got %p\n", fb1.base.base + 25, fb1.base.gptr);
5470 ok((signed char)buffer[0] == -50, "expected -50 got %d\n", buffer[0]);
5471 ok((signed char)buffer[1] == -40, "expected -40 got %d\n", buffer[1]);
5472 ok(buffer[2] == 0, "expected 0 got %d\n", buffer[2]);
5474 /* get */
5475 is1.count = 0xabababab;
5476 is1.base_ios.state = IOSTATE_eofbit;
5477 ret = (int) call_func1(p_istream_get, &is1);
5478 ok(ret == EOF, "expected -1 got %d\n", ret);
5479 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5480 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5481 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5482 is1.base_ios.state = IOSTATE_badbit;
5483 ret = (int) call_func1(p_istream_get, &is1);
5484 ok(ret == EOF, "expected -1 got %d\n", ret);
5485 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5486 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5487 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5488 is1.base_ios.state = IOSTATE_goodbit;
5489 fb1.base.egptr = NULL;
5490 ret = (int) call_func1(p_istream_get, &is1);
5491 ok(ret == EOF, "expected -1 got %d\n", ret);
5492 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5493 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5494 is1.base_ios.state = IOSTATE_goodbit;
5495 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5496 fb1.base.egptr = fb1.base.base + 30;
5497 ret = (int) call_func1(p_istream_get, &is1);
5498 ok(ret == ' ', "expected %d got %d\n", ' ', ret);
5499 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5500 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5501 ok(fb1.base.gptr == fb1.base.base + 1, "wrong get pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.gptr);
5502 *fb1.base.gptr = '\n';
5503 ret = (int) call_func1(p_istream_get, &is1);
5504 ok(ret == '\n', "expected %d got %d\n", '\n', ret);
5505 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5506 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5507 ok(fb1.base.gptr == fb1.base.base + 2, "wrong get pointer, expected %p got %p\n", fb1.base.base + 2, fb1.base.gptr);
5508 *fb1.base.gptr = -50;
5509 ret = (int) call_func1(p_istream_get, &is1);
5510 ok(ret == 206, "expected 206 got %d\n", ret);
5511 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5512 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5513 ok(fb1.base.gptr == fb1.base.base + 3, "wrong get pointer, expected %p got %p\n", fb1.base.base + 3, fb1.base.gptr);
5514 fb1.base.gptr = fb1.base.base + 30;
5515 ret = (int) call_func1(p_istream_get, &is1);
5516 ok(ret == EOF, "expected -1 got %d\n", ret);
5517 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5518 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5519 ok(fb1.base.gptr == (char*) 1, "wrong get pointer, expected %p got %p\n", (char*) 1, fb1.base.gptr);
5521 /* get_char */
5522 is1.count = 0xabababab;
5523 is1.base_ios.state = IOSTATE_badbit;
5524 c = 0xab;
5525 pis = call_func2(p_istream_get_char, &is1, &c);
5526 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5527 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5528 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5529 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5530 ok(c == (char) 0xab, "expected %d got %d\n", (char) 0xab, c);
5531 is1.base_ios.state = IOSTATE_goodbit;
5532 pis = call_func2(p_istream_get_char, &is1, &c);
5533 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5534 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5535 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5536 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5537 ok((signed char)c == EOF, "expected -1 got %d\n", c);
5538 is1.base_ios.state = IOSTATE_goodbit;
5539 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5540 fb1.base.egptr = fb1.base.base + 30;
5541 pis = call_func2(p_istream_get_char, &is1, &c);
5542 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5543 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5544 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5545 ok(fb1.base.gptr == fb1.base.base + 1, "wrong get pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.gptr);
5546 ok(c == ' ', "expected %d got %d\n", ' ', c);
5547 fb1.base.gptr = fb1.base.base + 2;
5548 pis = call_func2(p_istream_get_char, &is1, &c);
5549 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5550 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5551 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5552 ok(fb1.base.gptr == fb1.base.base + 3, "wrong get pointer, expected %p got %p\n", fb1.base.base + 3, fb1.base.gptr);
5553 ok((signed char)c == -50, "expected %d got %d\n", -50, c);
5554 if (0) /* crashes on native */
5555 pis = call_func2(p_istream_get_char, &is1, NULL);
5556 fb1.base.gptr = fb1.base.base + 30;
5557 pis = call_func2(p_istream_get_char, &is1, &c);
5558 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5559 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5560 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5561 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5562 ok(fb1.base.gptr == (char*) 1, "wrong get pointer, expected %p got %p\n", (char*) 1, fb1.base.gptr);
5563 ok((signed char)c == EOF, "expected -1 got %d\n", c);
5564 is1.base_ios.state = IOSTATE_failbit;
5565 pis = call_func2(p_istream_get_char, &is1, NULL);
5566 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5567 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5568 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5569 ok(fb1.base.gptr == (char*) 1, "wrong get pointer, expected %p got %p\n", (char*) 1, fb1.base.gptr);
5571 /* get_sb */
5572 is1.count = 0xabababab;
5573 is1.base_ios.state = IOSTATE_badbit;
5574 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, 0);
5575 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5576 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5577 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5578 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5579 is1.base_ios.state = IOSTATE_goodbit;
5580 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, 0);
5581 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5582 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5583 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5584 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5585 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5586 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5587 is1.base_ios.state = IOSTATE_goodbit;
5588 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5589 fb1.base.egptr = fb1.base.base + 30;
5590 strcpy(fb1.base.base, " Never gonna \nlet you \r down?");
5591 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, 0);
5592 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5593 ok(is1.count == 30, "expected 30 got %d\n", is1.count);
5594 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5595 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5596 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5597 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5598 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5599 ok(fb2.base.pptr == fb2.base.base + 30, "wrong put pointer, expected %p got %p\n", fb2.base.base + 30, fb2.base.pptr);
5600 ok(fb2.base.epptr == fb2.base.ebuf, "wrong put end, expected %p got %p\n", fb2.base.ebuf, fb2.base.epptr);
5601 ok(!strncmp(fb2.base.pbase, " Never gonna \nlet you \r down?", 30), "unexpected sb content, got '%s'\n", fb2.base.pbase);
5602 is1.base_ios.state = IOSTATE_goodbit;
5603 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5604 fb1.base.egptr = fb1.base.base + 30;
5605 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, '\n');
5606 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5607 ok(is1.count == 14, "expected 14 got %d\n", is1.count);
5608 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5609 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5610 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5611 ok(fb1.base.egptr == fb1.base.base + 30, "wrong get end, expected %p got %p\n", fb1.base.base + 30, fb1.base.egptr);
5612 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5613 ok(fb2.base.pptr == fb2.base.base + 44, "wrong put pointer, expected %p got %p\n", fb2.base.base + 44, fb2.base.pptr);
5614 ok(fb2.base.epptr == fb2.base.ebuf, "wrong put end, expected %p got %p\n", fb2.base.ebuf, fb2.base.epptr);
5615 ok(!strncmp(fb2.base.base + 30, " Never gonna ", 14), "unexpected sb content, got '%s'\n", fb2.base.pbase);
5616 fd = fb2.fd;
5617 fb2.fd = -1;
5618 fb2.base.pbase = fb2.base.pptr = fb2.base.epptr = NULL;
5619 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, '\n');
5620 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5621 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5622 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5623 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5624 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5625 ok(fb1.base.egptr == fb1.base.base + 30, "wrong get end, expected %p got %p\n", fb1.base.base + 30, fb1.base.egptr);
5626 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5627 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5628 ok(fb2.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb2.base.epptr);
5629 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, 0);
5630 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5631 ok(is1.count == 16, "expected 16 got %d\n", is1.count);
5632 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5633 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5634 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5635 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5636 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5637 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5638 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5639 ok(fb2.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb2.base.epptr);
5640 is1.base_ios.state = IOSTATE_goodbit;
5641 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5642 fb1.base.egptr = fb1.base.base + 30;
5643 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, '\n');
5644 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5645 ok(is1.count == 14, "expected 14 got %d\n", is1.count);
5646 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5647 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5648 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5649 ok(fb1.base.egptr == fb1.base.base + 30, "wrong get end, expected %p got %p\n", fb1.base.base + 30, fb1.base.egptr);
5650 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5651 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5652 ok(fb2.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb2.base.epptr);
5653 fb2.fd = fd;
5654 is1.base_ios.state = IOSTATE_goodbit;
5655 pis = call_func3(p_istream_get_sb, &is1, NULL, '\n');
5656 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5657 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5658 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5659 ok(fb1.base.eback == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.eback);
5660 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5661 ok(fb1.base.egptr == fb1.base.base + 30, "wrong get end, expected %p got %p\n", fb1.base.base + 30, fb1.base.egptr);
5662 ok(fb2.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb2.base.pbase);
5663 ok(fb2.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb2.base.pptr);
5664 ok(fb2.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb2.base.epptr);
5665 is1.base_ios.state = IOSTATE_goodbit;
5666 if (0) /* crashes on native */
5667 pis = call_func3(p_istream_get_sb, &is1, NULL, '?');
5668 *fb1.base.gptr = -50;
5669 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, -50);
5670 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5671 ok(is1.count == 16, "expected 16 got %d\n", is1.count);
5672 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5673 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5674 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5675 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5676 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5677 ok(fb2.base.pptr == fb2.base.base + 16, "wrong put pointer, expected %p got %p\n", fb2.base.base + 16, fb2.base.pptr);
5678 ok(fb2.base.epptr == fb2.base.ebuf, "wrong put end, expected %p got %p\n", fb2.base.ebuf, fb2.base.epptr);
5679 is1.base_ios.state = IOSTATE_goodbit;
5680 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5681 fb1.base.egptr = fb1.base.base + 30;
5682 pis = call_func3(p_istream_get_sb, &is1, &fb2.base, (char)206);
5683 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5684 ok(is1.count == 30, "expected 30 got %d\n", is1.count);
5685 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5686 ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
5687 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5688 ok(fb1.base.egptr == NULL, "wrong get end, expected %p got %p\n", NULL, fb1.base.egptr);
5689 ok(fb2.base.pbase == fb2.base.base, "wrong put base, expected %p got %p\n", fb2.base.base, fb2.base.pbase);
5690 ok(fb2.base.pptr == fb2.base.base + 46, "wrong put pointer, expected %p got %p\n", fb2.base.base + 46, fb2.base.pptr);
5691 ok(fb2.base.epptr == fb2.base.ebuf, "wrong put end, expected %p got %p\n", fb2.base.ebuf, fb2.base.epptr);
5693 /* getline */
5694 is1.extract_delim = is1.count = 0xabababab;
5695 memset(buffer, 'A', sizeof(buffer));
5696 pis = call_func4(p_istream_getline, &is1, buffer, 10, 0);
5697 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5698 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5699 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5700 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5701 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5702 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5703 is1.extract_delim = is1.count = 0xabababab;
5704 is1.base_ios.state = IOSTATE_goodbit;
5705 memset(buffer, 'A', sizeof(buffer));
5706 pis = call_func4(p_istream_getline, &is1, buffer, 10, 0);
5707 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5708 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5709 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5710 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5711 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5712 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5713 is1.base_ios.state = IOSTATE_goodbit;
5714 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5715 fb1.base.egptr = fb1.base.base + 30;
5716 memset(buffer, 'A', sizeof(buffer));
5717 pis = call_func4(p_istream_getline, &is1, buffer, 10, 'r');
5718 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5719 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5720 ok(is1.count == 7, "expected 7 got %d\n", is1.count);
5721 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5722 ok(fb1.base.gptr == fb1.base.base + 7, "wrong get pointer, expected %p got %p\n", fb1.base.base + 7, fb1.base.gptr);
5723 ok(!strncmp(buffer, fb1.base.base, 6), "unexpected buffer content, got '%s'\n", buffer);
5724 ok(buffer[6] == 0, "expected 0 got %d\n", buffer[6]);
5725 is1.extract_delim = -1;
5726 memset(buffer, 'A', sizeof(buffer));
5727 pis = call_func4(p_istream_getline, &is1, buffer, 10, -50);
5728 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5729 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5730 ok(is1.count == 7, "expected 7 got %d\n", is1.count);
5731 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5732 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5733 ok(!strncmp(buffer, fb1.base.base + 7, 7), "unexpected buffer content, got '%s'\n", buffer);
5734 ok(buffer[7] == 0, "expected 0 got %d\n", buffer[7]);
5735 is1.extract_delim = -1;
5736 memset(buffer, 'A', sizeof(buffer));
5737 pis = call_func4(p_istream_getline, &is1, buffer, 10, (char)206);
5738 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5739 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5740 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5741 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5742 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5743 ok(buffer[0] == 0, "expected 0 got %d\n", buffer[0]);
5744 is1.extract_delim = -2;
5745 memset(buffer, 'A', sizeof(buffer));
5746 pis = call_func4(p_istream_getline, &is1, buffer, 20, '\r');
5747 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5748 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5749 ok(is1.count == 10, "expected 10 got %d\n", is1.count);
5750 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5751 ok(fb1.base.gptr == fb1.base.base + 24, "wrong get pointer, expected %p got %p\n", fb1.base.base + 24, fb1.base.gptr);
5752 ok(!strncmp(buffer, fb1.base.base + 14, 9), "unexpected buffer content, got '%s'\n", buffer);
5753 ok(buffer[9] == 0, "expected 0 got %d\n", buffer[9]);
5754 memset(buffer, 'A', sizeof(buffer));
5755 pis = call_func4(p_istream_getline, &is1, NULL, 20, '?');
5756 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5757 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5758 ok(is1.count == 6, "expected 6 got %d\n", is1.count);
5759 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5760 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5761 memset(buffer, 'A', sizeof(buffer));
5762 pis = call_func4(p_istream_getline, &is1, buffer, 0, 0);
5763 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5764 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5765 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5766 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5767 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5768 ok(buffer[0] == 'A', "expected 'A' got %d\n", buffer[0]);
5770 /* ignore */
5771 is1.count = is1.extract_delim = 0xabababab;
5772 is1.base_ios.state = IOSTATE_badbit;
5773 pis = call_func3(p_istream_ignore, &is1, 10, 0);
5774 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5775 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5776 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5777 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5778 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5779 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5780 is1.count = is1.extract_delim = 0xabababab;
5781 is1.base_ios.state = IOSTATE_goodbit;
5782 pis = call_func3(p_istream_ignore, &is1, 0, 0);
5783 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5784 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5785 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5786 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5787 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5788 pis = call_func3(p_istream_ignore, &is1, 1, 0);
5789 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5790 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5791 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5792 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5793 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5794 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5795 is1.base_ios.state = IOSTATE_goodbit;
5796 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5797 fb1.base.egptr = fb1.base.base + 30;
5798 pis = call_func3(p_istream_ignore, &is1, 5, -1);
5799 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5800 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5801 ok(is1.count == 5, "expected 5 got %d\n", is1.count);
5802 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5803 ok(fb1.base.gptr == fb1.base.base + 5, "wrong get pointer, expected %p got %p\n", fb1.base.base + 5, fb1.base.gptr);
5804 is1.extract_delim = 0;
5805 pis = call_func3(p_istream_ignore, &is1, 10, 'g');
5806 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5807 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5808 ok(is1.count == 4, "expected 4 got %d\n", is1.count);
5809 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5810 ok(fb1.base.gptr == fb1.base.base + 9, "wrong get pointer, expected %p got %p\n", fb1.base.base + 9, fb1.base.gptr);
5811 is1.extract_delim = -1;
5812 pis = call_func3(p_istream_ignore, &is1, 10, 'a');
5813 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5814 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5815 ok(is1.count == 3, "expected 3 got %d\n", is1.count);
5816 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5817 ok(fb1.base.gptr == fb1.base.base + 12, "wrong get pointer, expected %p got %p\n", fb1.base.base + 12, fb1.base.gptr);
5818 is1.extract_delim = -1;
5819 pis = call_func3(p_istream_ignore, &is1, 10, 206);
5820 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5821 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5822 ok(is1.count == 2, "expected 2 got %d\n", is1.count);
5823 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5824 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5825 pis = call_func3(p_istream_ignore, &is1, 10, -50);
5826 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5827 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5828 ok(is1.count == 10, "expected 10 got %d\n", is1.count);
5829 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5830 ok(fb1.base.gptr == fb1.base.base + 24, "wrong get pointer, expected %p got %p\n", fb1.base.base + 24, fb1.base.gptr);
5831 is1.extract_delim = -1;
5832 pis = call_func3(p_istream_ignore, &is1, 10, -1);
5833 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5834 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
5835 ok(is1.count == 6, "expected 6 got %d\n", is1.count);
5836 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5837 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5839 /* peek */
5840 is1.count = 0xabababab;
5841 ret = (int) call_func1(p_istream_peek, &is1);
5842 ok(ret == EOF, "expected -1 got %d\n", ret);
5843 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5844 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5845 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5846 is1.count = 0xabababab;
5847 is1.base_ios.state = IOSTATE_goodbit;
5848 ret = (int) call_func1(p_istream_peek, &is1);
5849 ok(ret == EOF, "expected -1 got %d\n", ret);
5850 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5851 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5852 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5853 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5854 fb1.base.egptr = fb1.base.base + 30;
5855 ret = (int) call_func1(p_istream_peek, &is1);
5856 ok(ret == ' ', "expected ' ' got %d\n", ret);
5857 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5858 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5859 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
5860 if (0) /* crashes on native */
5861 is1.base_ios.sb = NULL;
5862 fb1.base.gptr = fb1.base.base + 14;
5863 ret = (int) call_func1(p_istream_peek, &is1);
5864 ok(ret == 206, "expected 206 got %d\n", ret);
5865 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5866 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5867 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5868 fb1.base.gptr = fb1.base.base + 30;
5869 ret = (int) call_func1(p_istream_peek, &is1);
5870 ok(ret == EOF, "expected -1 got %d\n", ret);
5871 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5872 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5873 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5875 /* putback */
5876 is1.base_ios.state = IOSTATE_goodbit;
5877 pis = call_func2(p_istream_putback, &is1, 'a');
5878 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5879 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5880 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5881 fd = fb1.fd;
5882 fb1.fd = -1;
5883 pis = call_func2(p_istream_putback, &is1, 'a');
5884 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5885 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5886 fb1.fd = fd;
5887 fb1.base.eback = fb1.base.base;
5888 fb1.base.gptr = fb1.base.base + 15;
5889 fb1.base.egptr = fb1.base.base + 30;
5890 pis = call_func2(p_istream_putback, &is1, -40);
5891 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5892 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5893 ok(fb1.base.gptr == fb1.base.base + 15, "wrong get pointer, expected %p got %p\n", fb1.base.base + 15, fb1.base.gptr);
5894 is1.base_ios.state = IOSTATE_badbit;
5895 pis = call_func2(p_istream_putback, &is1, -40);
5896 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5897 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
5898 ok(fb1.base.gptr == fb1.base.base + 15, "wrong get pointer, expected %p got %p\n", fb1.base.base + 15, fb1.base.gptr);
5899 is1.base_ios.state = IOSTATE_eofbit;
5900 pis = call_func2(p_istream_putback, &is1, -40);
5901 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5902 ok(is1.base_ios.state == IOSTATE_eofbit, "expected %d got %d\n", IOSTATE_eofbit, is1.base_ios.state);
5903 ok(fb1.base.gptr == fb1.base.base + 15, "wrong get pointer, expected %p got %p\n", fb1.base.base + 15, fb1.base.gptr);
5904 is1.base_ios.state = IOSTATE_goodbit;
5905 if (0) /* crashes on native */
5906 is1.base_ios.sb = NULL;
5907 pis = call_func2(p_istream_putback, &is1, -40);
5908 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5909 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5910 ok(fb1.base.gptr == fb1.base.base + 14, "wrong get pointer, expected %p got %p\n", fb1.base.base + 14, fb1.base.gptr);
5911 ok((signed char)*fb1.base.gptr == -40, "expected -40 got %d\n", *fb1.base.gptr);
5913 /* read */
5914 is1.extract_delim = is1.count = 0xabababab;
5915 is1.base_ios.state = IOSTATE_badbit;
5916 memset(buffer, 'A', sizeof(buffer));
5917 pis = call_func3(p_istream_read, &is1, buffer, 10);
5918 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5919 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5920 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
5921 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
5922 ok(buffer[0] == 'A', "expected 'A' got %d\n", buffer[0]);
5923 is1.base_ios.state = IOSTATE_goodbit;
5924 fb1.base.gptr = fb1.base.base;
5925 memset(buffer, 'A', sizeof(buffer));
5926 pis = call_func3(p_istream_read, &is1, buffer, 10);
5927 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5928 ok(is1.count == 10, "expected 10 got %d\n", is1.count);
5929 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5930 ok(fb1.base.gptr == fb1.base.base + 10, "wrong get pointer, expected %p got %p\n", fb1.base.base + 10, fb1.base.gptr);
5931 ok(!strncmp(buffer, fb1.base.base, 10), "unexpected buffer content, got '%s'\n", buffer);
5932 ok(buffer[10] == 'A', "expected 'A' got %d\n", buffer[10]);
5933 memset(buffer, 'A', sizeof(buffer));
5934 pis = call_func3(p_istream_read, &is1, buffer, 20);
5935 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5936 ok(is1.count == 20, "expected 20 got %d\n", is1.count);
5937 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5938 ok(fb1.base.gptr == fb1.base.base + 30, "wrong get pointer, expected %p got %p\n", fb1.base.base + 30, fb1.base.gptr);
5939 ok(!strncmp(buffer, fb1.base.base + 10, 20), "unexpected buffer content, got '%s'\n", buffer);
5940 ok((signed char)buffer[4] == -40, "expected -40 got %d\n", buffer[4]);
5941 ok(buffer[20] == 'A', "expected 'A' got %d\n", buffer[20]);
5942 memset(buffer, 'A', sizeof(buffer));
5943 pis = call_func3(p_istream_read, &is1, buffer, 5);
5944 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5945 ok(is1.count == 1, "expected 1 got %d\n", is1.count);
5946 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5947 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5948 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5949 ok(buffer[0] == 'e', "expected 'e' got %d\n", buffer[0]);
5950 ok(buffer[1] == 'A', "expected 'A' got %d\n", buffer[1]);
5951 is1.base_ios.state = IOSTATE_goodbit;
5952 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5953 fb1.base.egptr = fb1.base.base + 30;
5954 memset(buffer, 'A', sizeof(buffer));
5955 pis = call_func3(p_istream_read, &is1, buffer, 35);
5956 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5957 ok(is1.count == 30, "expected 30 got %d\n", is1.count);
5958 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
5959 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
5960 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5961 ok(!strncmp(buffer, fb1.base.base, 30), "unexpected buffer content, got '%s'\n", buffer);
5962 ok(buffer[30] == 'A', "expected 'A' got %d\n", buffer[30]);
5963 if (0) /* crashes on native */
5964 is1.base_ios.sb = NULL;
5965 is1.base_ios.state = IOSTATE_goodbit;
5966 fb1.base.eback = fb1.base.gptr = fb1.base.base;
5967 fb1.base.egptr = fb1.base.base + 30;
5968 memset(buffer, 'A', sizeof(buffer));
5969 if (0) /* crashes on native */
5970 pis = call_func3(p_istream_read, &is1, buffer, -1);
5971 pis = call_func3(p_istream_read, &is1, buffer, 0);
5972 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5973 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
5974 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
5975 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
5976 ok(buffer[0] == 'A', "expected 'A' got %d\n", buffer[0]);
5977 fb1.base.gptr = fb1.base.egptr;
5979 /* seekg */
5980 is1.extract_delim = is1.count = 0xabababab;
5981 pis = call_func2(p_istream_seekg, &is1, 0);
5982 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5983 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5984 ok(_tell(fb1.fd) == 0, "expected 0 got %ld\n", _tell(fb1.fd));
5985 if (0) /* crashes on native */
5986 is1.base_ios.sb = NULL;
5987 pis = call_func2(p_istream_seekg, &is1, -5);
5988 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5989 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5990 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5991 ok(_tell(fb1.fd) == 0, "expected 0 got %ld\n", _tell(fb1.fd));
5992 fb1.base.epptr = fb1.base.ebuf;
5993 pis = call_func2(p_istream_seekg, &is1, 5);
5994 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
5995 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
5996 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
5997 ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
5998 ok(_tell(fb1.fd) == 5, "expected 5 got %ld\n", _tell(fb1.fd));
5999 is1.base_ios.state = IOSTATE_goodbit;
6000 fd = fb1.fd;
6001 fb1.fd = -1;
6002 pis = call_func2(p_istream_seekg, &is1, 0);
6003 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6004 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6005 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
6006 fb1.base.eback = fb1.base.gptr = fb1.base.base;
6007 fb1.base.egptr = fb1.base.base + 30;
6008 pis = call_func3(p_istream_seekg_offset, &is1, 0, SEEKDIR_end);
6009 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6010 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6011 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
6012 is1.base_ios.state = IOSTATE_goodbit;
6013 fb1.fd = fd;
6014 pis = call_func3(p_istream_seekg_offset, &is1, 0, SEEKDIR_end);
6015 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6016 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6017 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
6018 if (0) /* crashes on native */
6019 is1.base_ios.sb = NULL;
6020 fb1.base.gptr = fb1.base.egptr;
6021 pis = call_func3(p_istream_seekg_offset, &is1, 0, SEEKDIR_end);
6022 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6023 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6024 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
6025 ok(_tell(fb1.fd) == 24, "expected 24 got %ld\n", _tell(fb1.fd));
6027 /* sync */
6028 ret = (int) call_func1(p_istream_sync, &is1);
6029 ok(ret == 0, "expected 0 got %d\n", ret);
6030 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6031 is1.base_ios.state = IOSTATE_badbit;
6032 ret = (int) call_func1(p_istream_sync, &is1);
6033 ok(ret == 0, "expected 0 got %d\n", ret);
6034 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
6035 is1.base_ios.state = IOSTATE_goodbit;
6036 ret = (int) call_func1(p_istream_sync, &is1);
6037 ok(ret == 0, "expected 0 got %d\n", ret);
6038 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
6039 if (0) /* crashes on native */
6040 is1.base_ios.sb = NULL;
6041 fb1.base.eback = fb1.base.gptr = fb1.base.base;
6042 fb1.base.egptr = fb1.base.base + 30;
6043 ret = (int) call_func1(p_istream_sync, &is1);
6044 ok(ret == EOF, "expected -1 got %d\n", ret);
6045 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
6046 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
6047 ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
6048 fb1.base.gptr = fb1.base.egptr;
6049 ret = (int) call_func1(p_istream_sync, &is1);
6050 ok(ret == 0, "expected 0 got %d\n", ret);
6051 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
6052 IOSTATE_badbit|IOSTATE_failbit, is1.base_ios.state);
6053 ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
6054 is1.base_ios.state = IOSTATE_eofbit;
6055 fd = fb1.fd;
6056 fb1.fd = -1;
6057 ret = (int) call_func1(p_istream_sync, &is1);
6058 ok(ret == EOF, "expected -1 got %d\n", ret);
6059 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit), "expected %d got %d\n",
6060 IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit, is1.base_ios.state);
6061 fb1.fd = fd;
6063 /* tellg */
6064 ret = (int) call_func1(p_istream_tellg, &is1);
6065 ok(ret == 24, "expected 24 got %d\n", ret);
6066 ok(is1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit), "expected %d got %d\n",
6067 IOSTATE_badbit|IOSTATE_failbit|IOSTATE_eofbit, is1.base_ios.state);
6068 is1.base_ios.state = IOSTATE_goodbit;
6069 ret = (int) call_func1(p_istream_tellg, &is1);
6070 ok(ret == 24, "expected 24 got %d\n", ret);
6071 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
6072 if (0) /* crashes on native */
6073 is1.base_ios.sb = NULL;
6074 fb1.base.eback = fb1.base.gptr = fb1.base.base;
6075 fb1.base.egptr = fb1.base.base + 30;
6076 ret = (int) call_func1(p_istream_tellg, &is1);
6077 ok(ret == EOF, "expected -1 got %d\n", ret);
6078 ok(is1.base_ios.state == IOSTATE_failbit, "expected %d got %d\n", IOSTATE_failbit, is1.base_ios.state);
6079 is1.base_ios.state = IOSTATE_eofbit;
6080 ret = (int) call_func1(p_istream_tellg, &is1);
6081 ok(ret == EOF, "expected -1 got %d\n", ret);
6082 ok(is1.base_ios.state == (IOSTATE_eofbit|IOSTATE_failbit), "expected %d got %d\n",
6083 IOSTATE_eofbit|IOSTATE_failbit, is1.base_ios.state);
6084 fb1.base.eback = fb1.base.gptr = fb1.base.egptr = NULL;
6086 call_func1(p_istream_vbase_dtor, &is1);
6087 call_func1(p_istream_vbase_dtor, &is2);
6088 call_func1(p_ostream_vbase_dtor, &os);
6089 call_func1(p_filebuf_dtor, &fb1);
6090 call_func1(p_filebuf_dtor, &fb2);
6091 ok(_unlink(filename1) == 0, "Couldn't unlink file named '%s'\n", filename1);
6092 ok(_unlink(filename2) == 0, "Couldn't unlink file named '%s'\n", filename2);
6095 static void test_istream_getint(void)
6097 istream is, *pis;
6098 strstreambuf ssb, *pssb;
6099 int i, len, ret;
6100 char buffer[32];
6102 struct istream_getint_test {
6103 const char *stream_content;
6104 ios_io_state initial_state;
6105 ios_flags flags;
6106 int expected_return;
6107 ios_io_state expected_state;
6108 int expected_offset;
6109 const char *expected_buffer;
6110 } tests[] = {
6111 {"", IOSTATE_badbit, FLAGS_skipws, 0, IOSTATE_badbit|IOSTATE_failbit, 0, ""},
6112 {"", IOSTATE_eofbit, FLAGS_skipws, 0, IOSTATE_eofbit|IOSTATE_failbit, 0, ""},
6113 {"", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit|IOSTATE_failbit, 0, ""},
6114 {" 0 ", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 2, "0"},
6115 {" \n0", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit, 3, "0"},
6116 {"-0", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit, 2, "-0"},
6117 {"000\n", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 3, "000"},
6118 {"015 16", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 3, "015"},
6119 {"099", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 1, "0"},
6120 {" 12345", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit, 6, "12345"},
6121 {"12345\r", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 5, "12345"},
6122 {"0xab ", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_goodbit, 4, "0xab"},
6123 {" 0xefg", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_goodbit, 5, "0xef"},
6124 {"0XABc", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_eofbit, 5, "0XABc"},
6125 {"0xzzz", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_failbit, 0, ""},
6126 {"0y123", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 1, "0"},
6127 {"\t+42 ", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 4, "+42"},
6128 {"+\t42", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, ""},
6129 {"+4\t2", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 2, "+4"},
6130 {"+0xc", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_eofbit, 4, "+0xc"},
6131 {" -1 ", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 3, "-1"},
6132 {" -005 ", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 5, "-005"},
6133 {" 2-0 ", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 2, "2"},
6134 {"--3 ", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, ""},
6135 {"+-7", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, ""},
6136 {"+", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, ""},
6137 {"-0x123abc", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_eofbit, 9, "-0x123abc"},
6138 {"0-x123abc", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 1, "0"},
6139 {"0x-123abc", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_failbit, 0, ""},
6140 {"2147483648", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit, 10, "2147483648"},
6141 {"99999999999999", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit, 14, "99999999999999"},
6142 {"999999999999999", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 15, "999999999999999"},
6143 {"123456789123456789", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 15, "123456789123456"},
6144 {"000000000000000000", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 15, "000000000000000"},
6145 {"-0xffffffffffffffffff", IOSTATE_goodbit, FLAGS_skipws, 16, IOSTATE_goodbit, 15, "-0xffffffffffff"},
6146 {"3.14159", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 1, "3"},
6147 {"deadbeef", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, ""},
6148 {"0deadbeef", IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 1, "0"},
6149 {"98765L", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 5, "98765"},
6150 {"9999l", IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_goodbit, 4, "9999"},
6151 {" 1", IOSTATE_goodbit, 0, 0, IOSTATE_failbit, 0, ""},
6152 {"1 ", IOSTATE_goodbit, 0, 0, IOSTATE_goodbit, 1, "1"},
6153 {"010", IOSTATE_goodbit, FLAGS_dec, 10, IOSTATE_eofbit, 3, "010"},
6154 {"0x123", IOSTATE_goodbit, FLAGS_dec, 10, IOSTATE_goodbit, 1, "0"},
6155 {"x1", IOSTATE_goodbit, FLAGS_dec, 10, IOSTATE_failbit, 0, ""},
6156 {"33", IOSTATE_goodbit, FLAGS_dec|FLAGS_oct, 10, IOSTATE_eofbit, 2, "33"},
6157 {"abc", IOSTATE_goodbit, FLAGS_dec|FLAGS_hex, 10, IOSTATE_failbit, 0, ""},
6158 {"33", IOSTATE_goodbit, FLAGS_oct, 8, IOSTATE_eofbit, 2, "33"},
6159 {"9", IOSTATE_goodbit, FLAGS_oct, 8, IOSTATE_failbit, 0, ""},
6160 {"0", IOSTATE_goodbit, FLAGS_oct, 8, IOSTATE_eofbit, 1, "0"},
6161 {"x1", IOSTATE_goodbit, FLAGS_oct, 8, IOSTATE_failbit, 0, ""},
6162 {"9", IOSTATE_goodbit, FLAGS_oct|FLAGS_hex, 16, IOSTATE_eofbit, 1, "9"},
6163 {"abc", IOSTATE_goodbit, FLAGS_oct|FLAGS_hex, 16, IOSTATE_eofbit, 3, "abc"},
6164 {"123 ", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_goodbit, 3, "123"},
6165 {"x123 ", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_failbit, 0, ""},
6166 {"0x123 ", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_goodbit, 5, "0x123"},
6167 {"-a", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_eofbit, 2, "-a"},
6168 {"-j", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_failbit, 0, ""},
6169 {"-0x-1", IOSTATE_goodbit, FLAGS_hex, 16, IOSTATE_failbit, 0, ""},
6170 {"0", IOSTATE_goodbit, FLAGS_dec|FLAGS_oct|FLAGS_hex, 10, IOSTATE_eofbit, 1, "0"},
6171 {"0z", IOSTATE_goodbit, FLAGS_dec|FLAGS_oct|FLAGS_hex, 10, IOSTATE_goodbit, 1, "0"}
6174 pssb = call_func2(p_strstreambuf_dynamic_ctor, &ssb, 64);
6175 ok(pssb == &ssb, "wrong return, expected %p got %p\n", &ssb, pssb);
6176 ret = (int) call_func1(p_streambuf_allocate, &ssb.base);
6177 ok(ret == 1, "expected 1 got %d\n", ret);
6178 pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
6179 ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
6181 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6182 len = strlen(tests[i].stream_content);
6183 is.base_ios.state = tests[i].initial_state;
6184 is.base_ios.flags = tests[i].flags;
6185 ssb.base.eback = ssb.base.gptr = ssb.base.base;
6186 ssb.base.egptr = ssb.base.base + len;
6187 memcpy(ssb.base.base, tests[i].stream_content, len);
6189 ret = (int) call_func2(p_istream_getint, &is, buffer);
6190 ok(ret == tests[i].expected_return, "Test %d: wrong return, expected %d got %d\n", i,
6191 tests[i].expected_return, ret);
6192 ok(is.base_ios.state == tests[i].expected_state, "Test %d: expected %d got %d\n", i,
6193 tests[i].expected_state, is.base_ios.state);
6194 ok(ssb.base.gptr == ssb.base.base + tests[i].expected_offset, "Test %d: expected %p got %p\n", i,
6195 ssb.base.base + tests[i].expected_offset, ssb.base.gptr);
6196 ok(!strncmp(buffer, tests[i].expected_buffer, strlen(tests[i].expected_buffer)),
6197 "Test %d: unexpected buffer content, got '%s'\n", i, buffer);
6200 call_func1(p_istream_vbase_dtor, &is);
6201 call_func1(p_strstreambuf_dtor, &ssb);
6204 static void test_istream_getdouble(void)
6206 istream is, *pis;
6207 strstreambuf ssb, *pssb;
6208 int i, len, ret;
6209 char buffer[32];
6211 struct istream_getdouble_test {
6212 const char *stream_content;
6213 int count;
6214 ios_io_state initial_state;
6215 ios_flags flags;
6216 int expected_return;
6217 ios_io_state expected_state;
6218 int expected_offset;
6219 const char *expected_buffer;
6220 BOOL broken;
6221 } tests[] = {
6222 {"", 32, IOSTATE_badbit, FLAGS_skipws, 0, IOSTATE_badbit|IOSTATE_failbit, 0, "", FALSE},
6223 {"", 0, IOSTATE_badbit, FLAGS_skipws, 0, IOSTATE_badbit|IOSTATE_failbit, 0, "", FALSE},
6224 {"", 32, IOSTATE_eofbit, FLAGS_skipws, 0, IOSTATE_eofbit|IOSTATE_failbit, 0, "", FALSE},
6225 {"", 32, IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit|IOSTATE_failbit, 0, "", FALSE},
6226 {" ", 32, IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_eofbit|IOSTATE_failbit, 1, "", FALSE},
6227 {" 0", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_eofbit, 2, "0", FALSE},
6228 {"156", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_eofbit, 3, "156", FALSE},
6229 {"123 ", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_goodbit, 3, "123", FALSE},
6230 {"+4 5", 32, IOSTATE_goodbit, FLAGS_skipws, 2, IOSTATE_goodbit, 2, "+4", FALSE},
6231 {"-88a", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_goodbit, 3, "-88", FALSE},
6232 {"-+5", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_failbit, 1, "-", FALSE},
6233 {"++7", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_failbit, 1, "+", FALSE},
6234 {"+", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_eofbit|IOSTATE_failbit, 1, "+", FALSE},
6235 {"abc", 32, IOSTATE_goodbit, FLAGS_skipws, 0, IOSTATE_failbit, 0, "", FALSE},
6236 {"0xabc", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_goodbit, 1, "0", FALSE},
6237 {"01", 32, IOSTATE_goodbit, FLAGS_skipws, 2, IOSTATE_eofbit, 2, "01", FALSE},
6238 {"10000000000000000000", 32, IOSTATE_goodbit, FLAGS_skipws, 20, IOSTATE_eofbit, 20, "10000000000000000000", FALSE},
6239 {"1.2", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_eofbit, 3, "1.2", FALSE},
6240 {"\t-0.4444f", 32, IOSTATE_goodbit, FLAGS_skipws, 7, IOSTATE_goodbit, 8, "-0.4444", FALSE},
6241 {"3.-14159", 32, IOSTATE_goodbit, FLAGS_skipws, 2, IOSTATE_goodbit, 2, "3.", FALSE},
6242 {"3.14.159", 32, IOSTATE_goodbit, FLAGS_skipws, 4, IOSTATE_goodbit, 4, "3.14", FALSE},
6243 {"3.000", 32, IOSTATE_goodbit, FLAGS_skipws, 5, IOSTATE_eofbit, 5, "3.000", FALSE},
6244 {".125f", 32, IOSTATE_goodbit, FLAGS_skipws, 4, IOSTATE_goodbit, 4, ".125", FALSE},
6245 {"-.125f", 32, IOSTATE_goodbit, FLAGS_skipws, 5, IOSTATE_goodbit, 5, "-.125", FALSE},
6246 {"5L", 32, IOSTATE_goodbit, FLAGS_skipws, 1, IOSTATE_goodbit, 1, "5", FALSE},
6247 {"1.", 32, IOSTATE_goodbit, FLAGS_skipws, 2, IOSTATE_eofbit, 2, "1.", FALSE},
6248 {"55.!", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_goodbit, 3, "55.", FALSE},
6249 {"99.99999999999", 32, IOSTATE_goodbit, FLAGS_skipws, 14, IOSTATE_eofbit, 14, "99.99999999999", FALSE},
6250 {"9.9999999999999999999", 32, IOSTATE_goodbit, FLAGS_skipws, 21, IOSTATE_eofbit, 21, "9.9999999999999999999", FALSE},
6251 {"0.0000000000000f", 32, IOSTATE_goodbit, FLAGS_skipws, 15, IOSTATE_goodbit, 15, "0.0000000000000", FALSE},
6252 {"1.0000e5 ", 32, IOSTATE_goodbit, FLAGS_skipws, 8, IOSTATE_goodbit, 8, "1.0000e5", FALSE},
6253 {"-2.12345e1000 ", 32, IOSTATE_goodbit, FLAGS_skipws, 13, IOSTATE_goodbit, 13, "-2.12345e1000", FALSE},
6254 {" 8E1", 32, IOSTATE_goodbit, FLAGS_skipws, 3, IOSTATE_eofbit, 5, "8E1", FALSE},
6255 {"99.99E-99E5", 32, IOSTATE_goodbit, FLAGS_skipws, 9, IOSTATE_goodbit, 9, "99.99E-99", FALSE},
6256 {"0e0", 32, IOSTATE_goodbit, FLAGS_skipws|FLAGS_uppercase, 3, IOSTATE_eofbit, 3, "0e0", FALSE},
6257 {"1.e8.5", 32, IOSTATE_goodbit, 0, 4, IOSTATE_goodbit, 4, "1.e8", FALSE},
6258 {"1.0e-1000000000000000000 ", 32, IOSTATE_goodbit, 0, 24, IOSTATE_goodbit, 24, "1.0e-1000000000000000000", FALSE},
6259 {"1.e+f", 32, IOSTATE_goodbit, 0, 3, IOSTATE_goodbit, 3, "1.e", FALSE},
6260 {"1.ef", 32, IOSTATE_goodbit, 0, 2, IOSTATE_goodbit, 2, "1.", FALSE},
6261 {"1.E-z", 32, IOSTATE_goodbit, 0, 3, IOSTATE_goodbit, 3, "1.E", FALSE},
6262 {".", 32, IOSTATE_goodbit, 0, 1, IOSTATE_eofbit|IOSTATE_failbit, 1, ".", FALSE},
6263 {".e", 32, IOSTATE_goodbit, 0, 1, IOSTATE_failbit, 1, ".", FALSE},
6264 {".e.", 32, IOSTATE_goodbit, 0, 1, IOSTATE_failbit, 1, ".", FALSE},
6265 {".e5", 32, IOSTATE_goodbit, 0, 3, IOSTATE_eofbit|IOSTATE_failbit, 3, ".e5", FALSE},
6266 {".2e5", 32, IOSTATE_goodbit, 0, 4, IOSTATE_eofbit, 4, ".2e5", FALSE},
6267 {"9.e", 32, IOSTATE_goodbit, 0, 2, IOSTATE_goodbit, 2, "9.", FALSE},
6268 {"0.0e-0", 32, IOSTATE_goodbit, 0, 6, IOSTATE_eofbit, 6, "0.0e-0", FALSE},
6269 {"e5.2", 32, IOSTATE_goodbit, 0, 2, IOSTATE_failbit, 2, "e5", FALSE},
6270 {"1.0000", 5, IOSTATE_goodbit, 0, 4, IOSTATE_failbit, 5, "1.00", TRUE},
6271 {"-123456", 5, IOSTATE_goodbit, 0, 4, IOSTATE_failbit, 5, "-123", TRUE},
6272 {"3.5e2", 5, IOSTATE_goodbit, 0, 4, IOSTATE_failbit, 5, "3.5e", TRUE},
6273 {"3.e25", 5, IOSTATE_goodbit, 0, 4, IOSTATE_failbit, 5, "3.e2", TRUE},
6274 {"1.11f", 5, IOSTATE_goodbit, 0, 4, IOSTATE_goodbit, 4, "1.11", FALSE},
6275 {".5e-5", 5, IOSTATE_goodbit, 0, 4, IOSTATE_failbit, 5, ".5e-", TRUE},
6276 {".5e-", 5, IOSTATE_goodbit, 0, 3, IOSTATE_goodbit, 3, ".5e", FALSE},
6277 {".5e2", 5, IOSTATE_goodbit, 0, 4, IOSTATE_eofbit, 4, ".5e2", FALSE},
6278 {"1", 0, IOSTATE_goodbit, 0, -1, IOSTATE_failbit, 0, "", TRUE},
6279 {"x", 0, IOSTATE_goodbit, 0, -1, IOSTATE_failbit, 0, "", TRUE},
6280 {"", 0, IOSTATE_goodbit, 0, -1, IOSTATE_failbit, 0, "", TRUE},
6281 {"", 1, IOSTATE_goodbit, 0, 0, IOSTATE_eofbit|IOSTATE_failbit, 0, "", FALSE},
6282 {"1.0", 1, IOSTATE_goodbit, 0, 0, IOSTATE_failbit, 1, "", TRUE},
6283 {"1.0", 2, IOSTATE_goodbit, 0, 1, IOSTATE_failbit, 2, "1", TRUE}
6286 pssb = call_func2(p_strstreambuf_dynamic_ctor, &ssb, 64);
6287 ok(pssb == &ssb, "wrong return, expected %p got %p\n", &ssb, pssb);
6288 ret = (int) call_func1(p_streambuf_allocate, &ssb.base);
6289 ok(ret == 1, "expected 1 got %d\n", ret);
6290 pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
6291 ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
6293 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6294 len = strlen(tests[i].stream_content);
6295 is.base_ios.state = tests[i].initial_state;
6296 is.base_ios.flags = tests[i].flags;
6297 ssb.base.eback = ssb.base.gptr = ssb.base.base;
6298 ssb.base.egptr = ssb.base.base + len;
6299 memcpy(ssb.base.base, tests[i].stream_content, len);
6301 ret = (int) call_func3(p_istream_getdouble, &is, buffer, tests[i].count);
6302 ok(ret == tests[i].expected_return ||
6303 /* xp, 2k3 */ broken(tests[i].broken && ret == tests[i].expected_return + 1),
6304 "Test %d: wrong return, expected %d got %d\n", i, tests[i].expected_return, ret);
6305 ok(is.base_ios.state == tests[i].expected_state, "Test %d: expected %d got %d\n", i,
6306 tests[i].expected_state, is.base_ios.state);
6307 ok(ssb.base.gptr == ssb.base.base + tests[i].expected_offset, "Test %d: expected %p got %p\n",
6308 i, ssb.base.base + tests[i].expected_offset, ssb.base.gptr);
6309 ok(!strncmp(buffer, tests[i].expected_buffer, strlen(tests[i].expected_buffer)),
6310 "Test %d: unexpected buffer content, got '%s'\n", i, buffer);
6313 call_func1(p_istream_vbase_dtor, &is);
6314 call_func1(p_strstreambuf_dtor, &ssb);
6317 static void test_istream_read(void)
6319 istream is, *pis;
6320 strstreambuf ssb, ssb_test, *pssb;
6321 int len, ret, i;
6323 /* makes tables narrower */
6324 const ios_io_state IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
6326 char c, st[8], char_out[] = {-85, ' ', 'a', -50};
6327 const char *str_out[] = {"AAAAAAA", "abc", "a", "abc", "ab", "abcde"};
6328 short s, short_out[] = {32767, -32768};
6329 unsigned short us, ushort_out[] = {65535u, 65534u, 32768u};
6330 int n, int_out[] = {123456789, 0, 1, -500, 0x8000, 2147483646, 2147483647, -2147483647, -2147483647-1, -1};
6331 unsigned un, uint_out[] = {4294967295u, 4294967294u, 2147483648u, 1u};
6332 LONG l, long_out[] = {2147483647l, -2147483647l-1};
6333 ULONG ul, ulong_out[] = {4294967295ul, 4294967294ul, 2147483648ul, 1ul};
6334 float f, float_out[] = {123.456f, 0.0f, 1.0f, 0.1f, -1.0f, -0.1f, FLT_MIN, -FLT_MIN, FLT_MAX, -FLT_MAX};
6335 double d, double_out[] = {1.0, 0.1, 0.0, INFINITY, -INFINITY};
6336 const char *sbf_out[] = {"", "abcd\n", "abcdef"};
6337 struct istream_read_test {
6338 enum { type_chr, type_str, type_shrt, type_ushrt, type_int, type_uint,
6339 type_long, type_ulong, type_flt, type_dbl, type_ldbl, type_sbf } type;
6340 const char *stream_content;
6341 ios_flags flags;
6342 int width;
6343 int expected_val;
6344 ios_io_state expected_state;
6345 int expected_width;
6346 int expected_offset;
6347 BOOL broken;
6348 } tests[] = {
6349 /* char */
6350 {type_chr, "", FLAGS_skipws, 6, /* -85 */ 0, IOSTATE_faileof, 6, 0, FALSE},
6351 {type_chr, " ", FLAGS_skipws, 6, /* -85 */ 0, IOSTATE_faileof, 6, 2, FALSE},
6352 {type_chr, " abc ", 0, 6, /* ' ' */ 1, IOSTATE_goodbit, 6, 1, FALSE},
6353 {type_chr, " abc ", FLAGS_skipws, 6, /* 'a' */ 2, IOSTATE_goodbit, 6, 2, FALSE},
6354 {type_chr, " a", FLAGS_skipws, 0, /* 'a' */ 2, IOSTATE_goodbit, 0, 2, FALSE},
6355 {type_chr, "\xce", 0, 6, /* -50 */ 3, IOSTATE_goodbit, 6, 1, FALSE},
6356 /* str */
6357 {type_str, "", FLAGS_skipws, 6, /* "AAAAAAA" */ 0, IOSTATE_faileof, 6, 0, FALSE},
6358 {type_str, " ", FLAGS_skipws, 6, /* "AAAAAAA" */ 0, IOSTATE_faileof, 6, 1, FALSE},
6359 {type_str, " abc", FLAGS_skipws, 6, /* "abc" */ 1, IOSTATE_eofbit, 0, 4, FALSE},
6360 {type_str, " abc ", FLAGS_skipws, 6, /* "abc" */ 1, IOSTATE_goodbit, 0, 4, FALSE},
6361 {type_str, " a\tc", FLAGS_skipws, 6, /* "a" */ 2, IOSTATE_goodbit, 0, 2, FALSE},
6362 {type_str, " a\tc", 0, 6, /* "AAAAAAA" */ 0, IOSTATE_failbit, 0, 0, FALSE},
6363 {type_str, "abcde\n", 0, 4, /* "abc" */ 3, IOSTATE_goodbit, 0, 3, FALSE},
6364 {type_str, "abc\n", 0, 4, /* "abc" */ 3, IOSTATE_goodbit, 0, 3, FALSE},
6365 {type_str, "ab\r\n", 0, 3, /* "ab" */ 4, IOSTATE_goodbit, 0, 2, FALSE},
6366 {type_str, "abc", 0, 4, /* "abc" */ 3, IOSTATE_goodbit, 0, 3, FALSE},
6367 {type_str, "abc", 0, 1, /* "AAAAAAA" */ 0, IOSTATE_failbit, 0, 0, FALSE},
6368 {type_str, "\n", 0, 1, /* "AAAAAAA" */ 0, IOSTATE_failbit, 0, 0, FALSE},
6369 {type_str, "abcde\n", 0, 0, /* "abcde" */ 5, IOSTATE_goodbit, 0, 5, FALSE},
6370 {type_str, "\n", 0, 0, /* "AAAAAAA" */ 0, IOSTATE_failbit, 0, 0, FALSE},
6371 {type_str, "abcde", 0, -1, /* "abcde" */ 5, IOSTATE_eofbit, 0, 5, FALSE},
6372 /* short */
6373 {type_shrt, "32767", 0, 6, /* 32767 */ 0, IOSTATE_eofbit, 6, 5, FALSE},
6374 {type_shrt, "32768", 0, 6, /* 32767 */ 0, IOSTATE_faileof, 6, 5, FALSE},
6375 {type_shrt, "2147483648", 0, 6, /* 32767 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6376 {type_shrt, "4294967296", 0, 6, /* 32767 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6377 {type_shrt, "-32768", 0, 6, /* -32768 */ 1, IOSTATE_eofbit, 6, 6, FALSE},
6378 {type_shrt, "-32769", 0, 6, /* -32768 */ 1, IOSTATE_faileof, 6, 6, FALSE},
6379 {type_shrt, "-2147483648", 0, 6, /* -32768 */ 1, IOSTATE_faileof, 6, 11, FALSE},
6380 /* unsigned short */
6381 {type_ushrt, "65535", 0, 6, /* 65535 */ 0, IOSTATE_eofbit, 6, 5, FALSE},
6382 {type_ushrt, "65536", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 5, FALSE},
6383 {type_ushrt, "12345678", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 8, FALSE},
6384 {type_ushrt, "2147483648", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6385 {type_ushrt, "4294967296", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6386 {type_ushrt, "99999999999999", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 14, FALSE},
6387 {type_ushrt, "-1", 0, 6, /* 65535 */ 0, IOSTATE_eofbit, 6, 2, TRUE},
6388 {type_ushrt, "-2", 0, 6, /* 65534 */ 1, IOSTATE_eofbit, 6, 2, FALSE},
6389 {type_ushrt, "-32768", 0, 6, /* 32768 */ 2, IOSTATE_eofbit, 6, 6, FALSE},
6390 {type_ushrt, "-32769", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 6, FALSE},
6391 {type_ushrt, "-2147483648", 0, 6, /* 65535 */ 0, IOSTATE_faileof, 6, 11, FALSE},
6392 /* int */
6393 {type_int, "", FLAGS_skipws, 6, /* 123456789 */ 0, IOSTATE_faileof, 6, 0, FALSE},
6394 {type_int, " 0", FLAGS_skipws, 6, /* 0 */ 1, IOSTATE_eofbit, 6, 2, FALSE},
6395 {type_int, " 0", 0, 6, /* 0 */ 1, IOSTATE_failbit, 6, 0, FALSE},
6396 {type_int, "+1 ", 0, 6, /* 1 */ 2, IOSTATE_goodbit, 6, 2, FALSE},
6397 {type_int, "1L", 0, 6, /* 1 */ 2, IOSTATE_goodbit, 6, 1, FALSE},
6398 {type_int, "-500.0", 0, 6, /* -500 */ 3, IOSTATE_goodbit, 6, 4, FALSE},
6399 {type_int, "0x8000", 0, 6, /* 0x8000 */ 4, IOSTATE_eofbit, 6, 6, FALSE},
6400 {type_int, "0xtest", 0, 6, /* 0 */ 1, IOSTATE_failbit, 6, 0, FALSE},
6401 {type_int, "0test", 0, 6, /* 0 */ 1, IOSTATE_goodbit, 6, 1, FALSE},
6402 {type_int, "0x7ffffffe", 0, 6, /* 2147483646 */ 5, IOSTATE_eofbit, 6, 10, FALSE},
6403 {type_int, "0x7fffffff", 0, 6, /* 2147483647 */ 6, IOSTATE_eofbit, 6, 10, FALSE},
6404 {type_int, "0x80000000", 0, 6, /* 2147483647 */ 6, IOSTATE_eofbit, 6, 10, FALSE},
6405 {type_int, "0xdeadbeef", 0, 6, /* 2147483647 */ 6, IOSTATE_eofbit, 6, 10, FALSE},
6406 {type_int, "2147483648", 0, 6, /* 2147483647 */ 6, IOSTATE_eofbit, 6, 10, FALSE},
6407 {type_int, "4294967295", 0, 6, /* 2147483647 */ 6, IOSTATE_eofbit, 6, 10, FALSE},
6408 {type_int, "-2147483647", 0, 6, /* -2147483647 */ 7, IOSTATE_eofbit, 6, 11, FALSE},
6409 {type_int, "-2147483648", 0, 6, /* -2147483648 */ 8, IOSTATE_eofbit, 6, 11, FALSE},
6410 {type_int, "-2147483649", 0, 6, /* -2147483648 */ 8, IOSTATE_eofbit, 6, 11, FALSE},
6411 {type_int, "-1f", FLAGS_dec, 6, /* -1 */ 9, IOSTATE_goodbit, 6, 2, FALSE},
6412 /* unsigned int */
6413 {type_uint, "4294967295", 0, 6, /* 4294967295 */ 0, IOSTATE_eofbit, 6, 10, TRUE},
6414 {type_uint, "4294967296", 0, 6, /* 4294967295 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6415 {type_uint, "99999999999999", 0, 6, /* 4294967295 */ 0, IOSTATE_faileof, 6, 14, FALSE},
6416 {type_uint, "-1", 0, 6, /* 4294967295 */ 0, IOSTATE_eofbit, 6, 2, TRUE},
6417 {type_uint, "-2", 0, 6, /* 4294967294 */ 1, IOSTATE_eofbit, 6, 2, FALSE},
6418 {type_uint, "-2147483648", 0, 6, /* 2147483648 */ 2, IOSTATE_eofbit, 6, 11, FALSE},
6419 {type_uint, "-4294967295", 0, 6, /* 1 */ 3, IOSTATE_eofbit, 6, 11, FALSE},
6420 {type_uint, "-9999999999999", 0, 6, /* 1 */ 3, IOSTATE_eofbit, 6, 14, FALSE},
6421 /* long */
6422 {type_long, "2147483647", 0, 6, /* 2147483647 */ 0, IOSTATE_eofbit, 6, 10, TRUE},
6423 {type_long, "2147483648", 0, 6, /* 2147483647 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6424 {type_long, "4294967295", 0, 6, /* 2147483647 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6425 {type_long, "-2147483648", 0, 6, /* -2147483648 */ 1, IOSTATE_eofbit, 6, 11, TRUE},
6426 {type_long, "-2147483649", 0, 6, /* -2147483648 */ 1, IOSTATE_faileof, 6, 11, FALSE},
6427 {type_long, "-9999999999999", 0, 6, /* -2147483648 */ 1, IOSTATE_faileof, 6, 14, FALSE},
6428 /* unsigned long */
6429 {type_ulong, "4294967295", 0, 6, /* 4294967295 */ 0, IOSTATE_eofbit, 6, 10, TRUE},
6430 {type_ulong, "4294967296", 0, 6, /* 4294967295 */ 0, IOSTATE_faileof, 6, 10, FALSE},
6431 {type_ulong, "99999999999999", 0, 6, /* 4294967295 */ 0, IOSTATE_faileof, 6, 14, FALSE},
6432 {type_ulong, "-1", 0, 6, /* 4294967295 */ 0, IOSTATE_eofbit, 6, 2, TRUE},
6433 {type_ulong, "-2", 0, 6, /* 4294967294 */ 1, IOSTATE_eofbit, 6, 2, FALSE},
6434 {type_ulong, "-2147483648", 0, 6, /* 2147483648 */ 2, IOSTATE_eofbit, 6, 11, FALSE},
6435 {type_ulong, "-4294967295", 0, 6, /* 1 */ 3, IOSTATE_eofbit, 6, 11, FALSE},
6436 {type_ulong, "-9999999999999", 0, 6, /* 1 */ 3, IOSTATE_eofbit, 6, 14, FALSE},
6437 /* float */
6438 {type_flt, "", FLAGS_skipws, 6, /* 123.456 */ 0, IOSTATE_faileof, 6, 0, FALSE},
6439 {type_flt, "", 0, 6, /* 123.456 */ 0, IOSTATE_faileof, 6, 0, FALSE},
6440 {type_flt, " 0", 0, 6, /* 123.456 */ 0, IOSTATE_failbit, 6, 0, FALSE},
6441 {type_flt, " 0", FLAGS_skipws, 6, /* 0.0 */ 1, IOSTATE_eofbit, 6, 2, FALSE},
6442 {type_flt, "-0 ", 0, 6, /* 0.0 */ 1, IOSTATE_goodbit, 6, 2, FALSE},
6443 {type_flt, "+1.0", 0, 6, /* 1.0 */ 2, IOSTATE_eofbit, 6, 4, FALSE},
6444 {type_flt, "1.#INF", 0, 6, /* 1.0 */ 2, IOSTATE_goodbit, 6, 2, FALSE},
6445 {type_flt, "0.100000000000000e1", 0, 6, /* 1.0 */ 2, IOSTATE_eofbit, 6, 19, FALSE},
6446 /* crashes on xp
6447 {type_flt, "0.1000000000000000e1", 0, 6, 0.1 3, IOSTATE_failbit, 6, 20, FALSE}, */
6448 {type_flt, "0.10000000000000000e1", 0, 6, /* 0.1 */ 3, IOSTATE_failbit, 6, 20, TRUE},
6449 {type_flt, "-0.10000000000000e1", 0, 6, /* -1.0 */ 4, IOSTATE_eofbit, 6, 19, FALSE},
6450 /* crashes on xp
6451 {type_flt, "-0.100000000000000e1 ", 0, 6, -0.1 5, IOSTATE_failbit, 6, 20, FALSE}, */
6452 {type_flt, "-0.1000000000000000e1", 0, 6, /* -0.1 */ 5, IOSTATE_failbit, 6, 20, TRUE},
6453 {type_flt, "5.1691126e-77", 0, 6, /* FLT_MIN */ 6, IOSTATE_eofbit, 6, 13, FALSE},
6454 {type_flt, "-2.49873e-41f", 0, 6, /* -FLT_MIN */ 7, IOSTATE_goodbit, 6, 12, FALSE},
6455 {type_flt, "1.23456789e1234", 0, 6, /* FLT_MAX */ 8, IOSTATE_eofbit, 6, 15, FALSE},
6456 {type_flt, "-1.23456789e1234", 0, 6, /* -FLT_MAX */ 9, IOSTATE_eofbit, 6, 16, FALSE},
6457 /* double */
6458 {type_dbl, "0.10000000000000000000000e1", 0, 6, /* 1.0 */ 0, IOSTATE_eofbit, 6, 27, FALSE},
6459 /* crashes on xp
6460 {type_dbl, "0.100000000000000000000000e1", 0, 6, 0.1 1, IOSTATE_failbit, 6, 28, FALSE}, */
6461 {type_dbl, "0.1000000000000000000000000e1", 0, 6, /* 0.1 */ 1, IOSTATE_failbit, 6, 28, TRUE},
6462 {type_dbl, "3.698124698114778e-6228", 0, 6, /* 0.0 */ 2, IOSTATE_eofbit, 6, 23, FALSE},
6463 {type_dbl, "-3.698124698114778e-6228", 0, 6, /* 0.0 */ 2, IOSTATE_eofbit, 6, 24, FALSE},
6464 {type_dbl, "3.698124698114778e6228", 0, 6, /* INF */ 3, IOSTATE_eofbit, 6, 22, FALSE},
6465 {type_dbl, "-3.698124698114778e6228A", 0, 6, /* -INF */ 4, IOSTATE_goodbit, 6, 23, FALSE},
6466 /* long double */
6467 {type_ldbl, "0.100000000000000000000000000e1", 0, 6, /* 1.0 */ 0, IOSTATE_eofbit, 6, 31, FALSE},
6468 /* crashes on xp
6469 {type_ldbl, "0.1000000000000000000000000000e1", 0, 6, 0.1 1, IOSTATE_failbit, 6, 32, FALSE}, */
6470 {type_ldbl, "0.10000000000000000000000000000e1", 0, 6, /* 0.1 */ 1, IOSTATE_failbit, 6, 32, TRUE},
6471 {type_ldbl, "1.69781699841e-1475", 0, 6, /* 0.0 */ 2, IOSTATE_eofbit, 6, 19, FALSE},
6472 {type_ldbl, "-1.69781699841e-1475l", 0, 6, /* 0.0 */ 2, IOSTATE_goodbit, 6, 20, FALSE},
6473 {type_ldbl, "1.69781699841e1475", 0, 6, /* INF */ 3, IOSTATE_eofbit, 6, 18, FALSE},
6474 {type_ldbl, "-1.69781699841e1475", 0, 6, /* -INF */ 4, IOSTATE_eofbit, 6, 19, FALSE},
6475 /* streambuf */
6476 {type_sbf, "", FLAGS_skipws, 6, /* "" */ 0, IOSTATE_faileof, 6, 0, FALSE},
6477 {type_sbf, " ", FLAGS_skipws, 6, /* "" */ 0, IOSTATE_faileof, 6, 2, FALSE},
6478 {type_sbf, "\r\nabcd\n", FLAGS_skipws, 6, /* "abc\n" */ 1, IOSTATE_goodbit, 6, 8, FALSE},
6479 {type_sbf, "abcdefg\n", 0, 6, /* "abcde" */ 2, IOSTATE_failbit, 6, 9, FALSE},
6480 {type_sbf, "abcdefg\n", 0, 0, /* "" */ 0, IOSTATE_failbit, 0, 9, FALSE}
6483 pssb = call_func2(p_strstreambuf_dynamic_ctor, &ssb_test, 64);
6484 ok(pssb == &ssb_test, "wrong return, expected %p got %p\n", &ssb_test, pssb);
6485 ret = (int) call_func1(p_streambuf_allocate, &ssb_test.base);
6486 ok(ret == 1, "expected 1 got %d\n", ret);
6487 ssb_test.dynamic = 0;
6488 pssb = call_func2(p_strstreambuf_dynamic_ctor, &ssb, 64);
6489 ok(pssb == &ssb, "wrong return, expected %p got %p\n", &ssb, pssb);
6490 ret = (int) call_func1(p_streambuf_allocate, &ssb.base);
6491 ok(ret == 1, "expected 1 got %d\n", ret);
6492 pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
6493 ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
6495 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6496 len = strlen(tests[i].stream_content);
6497 is.base_ios.state = IOSTATE_goodbit;
6498 is.base_ios.flags = tests[i].flags;
6499 is.base_ios.width = tests[i].width;
6500 ssb.base.eback = ssb.base.gptr = ssb.base.base;
6501 ssb.base.egptr = ssb.base.base + len;
6502 memcpy(ssb.base.base, tests[i].stream_content, len);
6504 switch (tests[i].type) {
6505 case type_chr:
6506 c = -85;
6507 pis = call_func2(p_istream_read_char, &is, &c);
6508 ok(c == char_out[tests[i].expected_val], "Test %d: expected %d got %d\n", i,
6509 char_out[tests[i].expected_val], c);
6510 break;
6511 case type_str:
6512 memset(st, 'A', sizeof(st));
6513 st[7] = 0;
6514 pis = call_func2(p_istream_read_str, &is, st);
6515 ok(!strcmp(st, str_out[tests[i].expected_val]), "Test %d: expected %s got %s\n", i,
6516 str_out[tests[i].expected_val], st);
6517 break;
6518 case type_shrt:
6519 s = 12345;
6520 pis = call_func2(p_istream_read_short, &is, &s);
6521 ok(s == short_out[tests[i].expected_val], "Test %d: expected %hd got %hd\n", i,
6522 short_out[tests[i].expected_val], s);
6523 break;
6524 case type_ushrt:
6525 us = 12345u;
6526 pis = call_func2(p_istream_read_unsigned_short, &is, &us);
6527 ok(us == ushort_out[tests[i].expected_val], "Test %d: expected %hu got %hu\n", i,
6528 ushort_out[tests[i].expected_val], us);
6529 break;
6530 case type_int:
6531 n = 123456789;
6532 pis = call_func2(p_istream_read_int, &is, &n);
6533 ok(n == int_out[tests[i].expected_val], "Test %d: expected %d got %d\n", i,
6534 int_out[tests[i].expected_val], n);
6535 break;
6536 case type_uint:
6537 un = 123456789u;
6538 pis = call_func2(p_istream_read_unsigned_int, &is, &un);
6539 ok(un == uint_out[tests[i].expected_val], "Test %d: expected %u got %u\n", i,
6540 uint_out[tests[i].expected_val], un);
6541 break;
6542 case type_long:
6543 l = 123456789l;
6544 pis = call_func2(p_istream_read_long, &is, &l);
6545 ok(l == long_out[tests[i].expected_val], "Test %d: expected %ld got %ld\n", i,
6546 long_out[tests[i].expected_val], l);
6547 break;
6548 case type_ulong:
6549 ul = 123456789ul;
6550 pis = call_func2(p_istream_read_unsigned_long, &is, &ul);
6551 ok(ul == ulong_out[tests[i].expected_val], "Test %d: expected %lu got %lu\n", i,
6552 ulong_out[tests[i].expected_val], ul);
6553 break;
6554 case type_flt:
6555 f = 123.456f;
6556 pis = call_func2(p_istream_read_float, &is, &f);
6557 ok(f == float_out[tests[i].expected_val], "Test %d: expected %f got %f\n", i,
6558 float_out[tests[i].expected_val], f);
6559 break;
6560 case type_dbl:
6561 d = 123.456;
6562 pis = call_func2(p_istream_read_double, &is, &d);
6563 ok(d == double_out[tests[i].expected_val], "Test %d: expected %f got %f\n", i,
6564 double_out[tests[i].expected_val], d);
6565 break;
6566 case type_ldbl:
6567 d = 123.456;
6568 pis = call_func2(p_istream_read_long_double, &is, &d);
6569 ok(d == double_out[tests[i].expected_val], "Test %d: expected %f got %f\n", i,
6570 double_out[tests[i].expected_val], d);
6571 break;
6572 case type_sbf:
6573 ssb_test.base.pbase = ssb_test.base.pptr = ssb_test.base.base;
6574 ssb_test.base.epptr = ssb_test.base.base + tests[i].width;
6575 pis = call_func2(p_istream_read_streambuf, &is, &ssb_test.base);
6576 len = strlen(sbf_out[tests[i].expected_val]);
6577 ok(ssb_test.base.pptr == ssb_test.base.pbase + len, "Test %d: wrong put pointer, expected %p got %p\n",
6578 i, ssb_test.base.pbase + len, ssb_test.base.pptr);
6579 ok(!strncmp(ssb_test.base.pbase, sbf_out[tests[i].expected_val], len),
6580 "Test %d: expected %s got %s\n", i, sbf_out[tests[i].expected_val], ssb_test.base.pbase);
6581 break;
6584 ok(pis == &is, "Test %d: wrong return, expected %p got %p\n", i, &is, pis);
6585 ok(is.base_ios.state == tests[i].expected_state || /* xp, 2k3 */ broken(tests[i].broken),
6586 "Test %d: expected %d got %d\n", i, tests[i].expected_state, is.base_ios.state);
6587 ok(is.base_ios.width == tests[i].expected_width, "Test %d: expected %d got %d\n", i,
6588 tests[i].expected_width, is.base_ios.width);
6589 ok(ssb.base.gptr == ssb.base.base + tests[i].expected_offset ||
6590 /* xp, 2k3 */ broken(tests[i].broken), "Test %d: expected %p got %p\n", i,
6591 ssb.base.base + tests[i].expected_offset, ssb.base.gptr);
6594 ssb_test.dynamic = 1;
6595 call_func1(p_istream_vbase_dtor, &is);
6596 call_func1(p_strstreambuf_dtor, &ssb);
6597 call_func1(p_strstreambuf_dtor, &ssb_test);
6600 static void test_istream_withassign(void)
6602 istream isa1, isa2, *pisa;
6603 ostream *pos;
6604 streambuf sb;
6606 memset(&isa1, 0xab, sizeof(istream));
6607 memset(&isa2, 0xab, sizeof(istream));
6609 /* constructors/destructors */
6610 pisa = call_func3(p_istream_withassign_sb_ctor, &isa1, NULL, TRUE);
6611 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6612 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6613 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6614 ok(isa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa1.base_ios.sb);
6615 ok(isa1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, isa1.base_ios.state);
6616 ok(isa1.base_ios.delbuf == 0, "expected 0 got %d\n", isa1.base_ios.delbuf);
6617 ok(isa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa1.base_ios.tie);
6618 ok(isa1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa1.base_ios.flags);
6619 ok(isa1.base_ios.precision == 6, "expected 6 got %d\n", isa1.base_ios.precision);
6620 ok(isa1.base_ios.fill == ' ', "expected 32 got %d\n", isa1.base_ios.fill);
6621 ok(isa1.base_ios.width == 0, "expected 0 got %d\n", isa1.base_ios.width);
6622 ok(isa1.base_ios.do_lock == -1, "expected -1 got %d\n", isa1.base_ios.do_lock);
6623 call_func1(p_istream_withassign_vbase_dtor, &isa1);
6624 isa1.extract_delim = isa1.count = 0xabababab;
6625 memset(&isa1.base_ios, 0xab, sizeof(ios));
6626 isa1.base_ios.delbuf = 0;
6627 pisa = call_func3(p_istream_withassign_sb_ctor, &isa1, NULL, FALSE);
6628 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6629 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6630 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6631 ok(isa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa1.base_ios.sb);
6632 ok(isa1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
6633 0xabababab|IOSTATE_badbit, isa1.base_ios.state);
6634 ok(isa1.base_ios.delbuf == 0, "expected 0 got %d\n", isa1.base_ios.delbuf);
6635 ok(isa1.base_ios.tie == isa2.base_ios.tie, "expected %p got %p\n", isa2.base_ios.tie, isa1.base_ios.tie);
6636 ok(isa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, isa1.base_ios.flags);
6637 ok(isa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.precision);
6638 ok(isa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", isa1.base_ios.fill);
6639 ok(isa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.width);
6640 ok(isa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.do_lock);
6641 call_func1(p_istream_withassign_dtor, &isa1.base_ios);
6642 isa1.extract_delim = isa1.count = 0xabababab;
6643 memset(&isa1.base_ios, 0xab, sizeof(ios));
6644 pisa = call_func3(p_istream_withassign_sb_ctor, &isa1, &sb, TRUE);
6645 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6646 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6647 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6648 ok(isa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, isa1.base_ios.sb);
6649 ok(isa1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, isa1.base_ios.state);
6650 ok(isa1.base_ios.delbuf == 0, "expected 0 got %d\n", isa1.base_ios.delbuf);
6651 ok(isa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa1.base_ios.tie);
6652 ok(isa1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa1.base_ios.flags);
6653 ok(isa1.base_ios.precision == 6, "expected 6 got %d\n", isa1.base_ios.precision);
6654 ok(isa1.base_ios.fill == ' ', "expected 32 got %d\n", isa1.base_ios.fill);
6655 ok(isa1.base_ios.width == 0, "expected 0 got %d\n", isa1.base_ios.width);
6656 ok(isa1.base_ios.do_lock == -1, "expected -1 got %d\n", isa1.base_ios.do_lock);
6657 call_func1(p_istream_withassign_vbase_dtor, &isa1);
6658 isa1.extract_delim = isa1.count = 0xabababab;
6659 memset(&isa1.base_ios, 0xab, sizeof(ios));
6660 isa1.base_ios.delbuf = 0;
6661 isa1.base_ios.state = 0xabababab | IOSTATE_badbit;
6662 pisa = call_func3(p_istream_withassign_sb_ctor, &isa1, &sb, FALSE);
6663 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6664 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6665 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6666 ok(isa1.base_ios.sb == &sb, "expected %p got %p\n", &sb, isa1.base_ios.sb);
6667 ok(isa1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.state);
6668 ok(isa1.base_ios.delbuf == 0, "expected 0 got %d\n", isa1.base_ios.delbuf);
6669 ok(isa1.base_ios.tie == isa2.base_ios.tie, "expected %p got %p\n", isa2.base_ios.tie, isa1.base_ios.tie);
6670 ok(isa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, isa1.base_ios.flags);
6671 ok(isa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.precision);
6672 ok(isa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", isa1.base_ios.fill);
6673 ok(isa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.width);
6674 ok(isa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.do_lock);
6675 call_func1(p_istream_withassign_dtor, &isa1.base_ios);
6676 isa1.extract_delim = isa1.count = 0xabababab;
6677 pisa = call_func2(p_istream_withassign_ctor, &isa1, TRUE);
6678 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6679 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6680 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6681 ok(isa1.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa1.base_ios.sb);
6682 ok(isa1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, isa1.base_ios.state);
6683 ok(isa1.base_ios.delbuf == 0, "expected 0 got %d\n", isa1.base_ios.delbuf);
6684 ok(isa1.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa1.base_ios.tie);
6685 ok(isa1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa1.base_ios.flags);
6686 ok(isa1.base_ios.precision == 6, "expected 6 got %d\n", isa1.base_ios.precision);
6687 ok(isa1.base_ios.fill == ' ', "expected 32 got %d\n", isa1.base_ios.fill);
6688 ok(isa1.base_ios.width == 0, "expected 0 got %d\n", isa1.base_ios.width);
6689 ok(isa1.base_ios.do_lock == -1, "expected -1 got %d\n", isa1.base_ios.do_lock);
6690 call_func1(p_istream_withassign_vbase_dtor, &isa1);
6691 isa1.extract_delim = isa1.count = 0xabababab;
6692 memset(&isa1.base_ios, 0xab, sizeof(ios));
6693 pisa = call_func2(p_istream_withassign_ctor, &isa1, FALSE);
6694 ok(pisa == &isa1, "wrong return, expected %p got %p\n", &isa1, pisa);
6695 ok(isa1.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6696 ok(isa1.count == 0, "expected 0 got %d\n", isa1.count);
6697 ok(isa1.base_ios.sb == isa2.base_ios.sb, "expected %p got %p\n", isa2.base_ios.sb, isa1.base_ios.sb);
6698 ok(isa1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.state);
6699 ok(isa1.base_ios.delbuf == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.delbuf);
6700 ok(isa1.base_ios.tie == isa2.base_ios.tie, "expected %p got %p\n", isa2.base_ios.tie, isa1.base_ios.tie);
6701 ok(isa1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, isa1.base_ios.flags);
6702 ok(isa1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.precision);
6703 ok(isa1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", isa1.base_ios.fill);
6704 ok(isa1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.width);
6705 ok(isa1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa1.base_ios.do_lock);
6706 call_func1(p_istream_withassign_dtor, &isa1.base_ios);
6707 isa1.extract_delim = isa1.count = 0xcdcdcdcd;
6708 memset(&isa1.base_ios, 0xcd, sizeof(ios));
6709 pisa = call_func3(p_istream_withassign_copy_ctor, &isa2, &isa1, TRUE);
6710 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6711 ok(isa2.extract_delim == 0, "expected 0 got %d\n", isa1.extract_delim);
6712 ok(isa2.count == 0, "expected 0 got %d\n", isa1.count);
6713 ok(isa2.base_ios.sb == isa1.base_ios.sb, "expected %p got %p\n", isa1.base_ios.sb, isa2.base_ios.sb);
6714 ok(isa2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, isa2.base_ios.state);
6715 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6716 ok(isa2.base_ios.tie == isa1.base_ios.tie, "expected %p got %p\n", isa1.base_ios.tie, isa2.base_ios.tie);
6717 ok(isa2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, isa2.base_ios.flags);
6718 ok(isa2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", isa2.base_ios.precision);
6719 ok(isa2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", isa2.base_ios.fill);
6720 ok(isa2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", isa2.base_ios.width);
6721 ok(isa2.base_ios.do_lock == -1, "expected -1 got %d\n", isa2.base_ios.do_lock);
6722 call_func1(p_istream_withassign_vbase_dtor, &isa2);
6723 isa1.base_ios.sb = NULL;
6724 isa2.extract_delim = isa2.count = 0xabababab;
6725 memset(&isa2.base_ios, 0xab, sizeof(ios));
6726 isa2.base_ios.delbuf = 0;
6727 isa2.base_ios.flags &= ~FLAGS_skipws;
6728 pos = isa2.base_ios.tie;
6729 pisa = call_func3(p_istream_withassign_copy_ctor, &isa2, &isa1, FALSE);
6730 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6731 ok(isa2.extract_delim == 0, "expected 0 got %d\n", isa2.extract_delim);
6732 ok(isa2.count == 0, "expected 0 got %d\n", isa2.count);
6733 ok(isa2.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa2.base_ios.sb);
6734 ok(isa2.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
6735 0xabababab|IOSTATE_badbit, isa2.base_ios.state);
6736 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6737 ok(isa2.base_ios.tie == pos, "expected %p got %p\n", pos, isa2.base_ios.tie);
6738 ok(isa2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, isa2.base_ios.flags);
6739 ok(isa2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.precision);
6740 ok(isa2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", isa2.base_ios.fill);
6741 ok(isa2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.width);
6742 ok(isa2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.do_lock);
6743 call_func1(p_istream_withassign_dtor, &isa2.base_ios);
6745 /* assignment */
6746 isa2.extract_delim = isa2.count = 0xabababab;
6747 isa2.base_ios.delbuf = 0xabababab;
6748 pisa = call_func2(p_istream_withassign_assign_sb, &isa2, &sb);
6749 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6750 ok(isa2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.extract_delim);
6751 ok(isa2.count == 0, "expected 0 got %d\n", isa2.count);
6752 ok(isa2.base_ios.sb == &sb, "expected %p got %p\n", &sb, isa2.base_ios.sb);
6753 ok(isa2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, isa2.base_ios.state);
6754 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6755 ok(isa2.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa2.base_ios.tie);
6756 ok(isa2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa2.base_ios.flags);
6757 ok(isa2.base_ios.precision == 6, "expected 6 got %d\n", isa2.base_ios.precision);
6758 ok(isa2.base_ios.fill == ' ', "expected 32 got %d\n", isa2.base_ios.fill);
6759 ok(isa2.base_ios.width == 0, "expected 0 got %d\n", isa2.base_ios.width);
6760 ok(isa2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.do_lock);
6761 isa2.count = 0xabababab;
6762 memset(&isa2.base_ios, 0xab, sizeof(ios));
6763 isa2.base_ios.delbuf = 0;
6764 pisa = call_func2(p_istream_withassign_assign_sb, &isa2, NULL);
6765 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6766 ok(isa2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.extract_delim);
6767 ok(isa2.count == 0, "expected 0 got %d\n", isa2.count);
6768 ok(isa2.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa2.base_ios.sb);
6769 ok(isa2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, isa2.base_ios.state);
6770 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6771 ok(isa2.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa2.base_ios.tie);
6772 ok(isa2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa2.base_ios.flags);
6773 ok(isa2.base_ios.precision == 6, "expected 6 got %d\n", isa2.base_ios.precision);
6774 ok(isa2.base_ios.fill == ' ', "expected 32 got %d\n", isa2.base_ios.fill);
6775 ok(isa2.base_ios.width == 0, "expected 0 got %d\n", isa2.base_ios.width);
6776 ok(isa2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.do_lock);
6777 isa2.count = 0xabababab;
6778 memset(&isa2.base_ios, 0xab, sizeof(ios));
6779 isa2.base_ios.delbuf = 0;
6780 pisa = call_func2(p_istream_withassign_assign_is, &isa2, &isa1);
6781 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6782 ok(isa2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.extract_delim);
6783 ok(isa2.count == 0, "expected 0 got %d\n", isa2.count);
6784 ok(isa2.base_ios.sb == NULL, "expected %p got %p\n", NULL, isa2.base_ios.sb);
6785 ok(isa2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, isa2.base_ios.state);
6786 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6787 ok(isa2.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa2.base_ios.tie);
6788 ok(isa2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa2.base_ios.flags);
6789 ok(isa2.base_ios.precision == 6, "expected 6 got %d\n", isa2.base_ios.precision);
6790 ok(isa2.base_ios.fill == ' ', "expected 32 got %d\n", isa2.base_ios.fill);
6791 ok(isa2.base_ios.width == 0, "expected 0 got %d\n", isa2.base_ios.width);
6792 ok(isa2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.do_lock);
6793 isa1.base_ios.sb = &sb;
6794 isa2.count = 0xabababab;
6795 memset(&isa2.base_ios, 0xab, sizeof(ios));
6796 isa2.base_ios.delbuf = 0;
6797 pisa = call_func2(p_istream_withassign_assign, &isa2, &isa1);
6798 ok(pisa == &isa2, "wrong return, expected %p got %p\n", &isa2, pisa);
6799 ok(isa2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.extract_delim);
6800 ok(isa2.count == 0, "expected 0 got %d\n", isa2.count);
6801 ok(isa2.base_ios.sb == &sb, "expected %p got %p\n", &sb, isa2.base_ios.sb);
6802 ok(isa2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, isa2.base_ios.state);
6803 ok(isa2.base_ios.delbuf == 0, "expected 0 got %d\n", isa2.base_ios.delbuf);
6804 ok(isa2.base_ios.tie == NULL, "expected %p got %p\n", NULL, isa2.base_ios.tie);
6805 ok(isa2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, isa2.base_ios.flags);
6806 ok(isa2.base_ios.precision == 6, "expected 6 got %d\n", isa2.base_ios.precision);
6807 ok(isa2.base_ios.fill == ' ', "expected 32 got %d\n", isa2.base_ios.fill);
6808 ok(isa2.base_ios.width == 0, "expected 0 got %d\n", isa2.base_ios.width);
6809 ok(isa2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, isa2.base_ios.do_lock);
6812 static void test_istrstream(void)
6814 istream is1, is2, *pis;
6815 ostream *pos;
6816 strstreambuf *pssb;
6817 char buffer[32];
6819 memset(&is1, 0xab, sizeof(istream));
6820 memset(&is2, 0xab, sizeof(istream));
6822 /* constructors/destructors */
6823 pis = call_func4(p_istrstream_buffer_ctor, &is1, buffer, 32, TRUE);
6824 pssb = (strstreambuf*) is1.base_ios.sb;
6825 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6826 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
6827 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
6828 ok(is1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is1.base_ios.sb);
6829 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
6830 ok(is1.base_ios.delbuf == 1, "expected 1 got %d\n", is1.base_ios.delbuf);
6831 ok(is1.base_ios.tie == NULL, "expected %p got %p\n", NULL, is1.base_ios.tie);
6832 ok(is1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, is1.base_ios.flags);
6833 ok(is1.base_ios.precision == 6, "expected 6 got %d\n", is1.base_ios.precision);
6834 ok(is1.base_ios.fill == ' ', "expected 32 got %d\n", is1.base_ios.fill);
6835 ok(is1.base_ios.width == 0, "expected 0 got %d\n", is1.base_ios.width);
6836 ok(is1.base_ios.do_lock == -1, "expected -1 got %d\n", is1.base_ios.do_lock);
6837 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
6838 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
6839 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
6840 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
6841 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
6842 ok(pssb->base.ebuf == buffer + 32, "wrong buffer end, expected %p got %p\n", buffer + 32, pssb->base.ebuf);
6843 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
6844 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
6845 ok(pssb->base.egptr == buffer + 32, "wrong get end, expected %p got %p\n", buffer + 32, pssb->base.egptr);
6846 ok(pssb->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pssb->base.pbase);
6847 ok(pssb->base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, pssb->base.pptr);
6848 ok(pssb->base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, pssb->base.epptr);
6849 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
6850 call_func1(p_istrstream_vbase_dtor, &is1);
6851 ok(is1.base_ios.sb == NULL, "expected %p got %p\n", NULL, is1.base_ios.sb);
6852 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
6853 memset(&is1, 0xab, sizeof(istream));
6854 pis = call_func4(p_istrstream_buffer_ctor, &is1, NULL, -1, TRUE);
6855 pssb = (strstreambuf*) is1.base_ios.sb;
6856 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6857 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
6858 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
6859 ok(is1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is1.base_ios.sb);
6860 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
6861 ok(is1.base_ios.delbuf == 1, "expected 1 got %d\n", is1.base_ios.delbuf);
6862 ok(is1.base_ios.tie == NULL, "expected %p got %p\n", NULL, is1.base_ios.tie);
6863 ok(is1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, is1.base_ios.flags);
6864 ok(is1.base_ios.precision == 6, "expected 6 got %d\n", is1.base_ios.precision);
6865 ok(is1.base_ios.fill == ' ', "expected 32 got %d\n", is1.base_ios.fill);
6866 ok(is1.base_ios.width == 0, "expected 0 got %d\n", is1.base_ios.width);
6867 ok(is1.base_ios.do_lock == -1, "expected -1 got %d\n", is1.base_ios.do_lock);
6868 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
6869 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
6870 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
6871 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
6872 ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
6873 ok(pssb->base.ebuf == (char*) 0x7fffffff || pssb->base.ebuf == (char*) -1,
6874 "wrong buffer end, expected 0x7fffffff or -1, got %p\n", pssb->base.ebuf);
6875 ok(pssb->base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, pssb->base.eback);
6876 ok(pssb->base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, pssb->base.gptr);
6877 ok(pssb->base.egptr == (char*) 0x7fffffff || pssb->base.egptr == (char*) -1,
6878 "wrong get end, expected 0x7fffffff or -1, got %p\n", pssb->base.egptr);
6879 ok(pssb->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pssb->base.pbase);
6880 ok(pssb->base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, pssb->base.pptr);
6881 ok(pssb->base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, pssb->base.epptr);
6882 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
6883 call_func1(p_istrstream_vbase_dtor, &is1);
6884 ok(is1.base_ios.sb == NULL, "expected %p got %p\n", NULL, is1.base_ios.sb);
6885 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
6886 is1.extract_delim = is1.count = 0xabababab;
6887 memset(&is1.base_ios, 0xab, sizeof(ios));
6888 is1.base_ios.delbuf = 0;
6889 strcpy(buffer, "Test");
6890 pis = call_func4(p_istrstream_buffer_ctor, &is1, buffer, 0, FALSE);
6891 pssb = (strstreambuf*) is1.base_ios.sb;
6892 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6893 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
6894 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
6895 ok(is1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is1.base_ios.sb);
6896 ok(is1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.state);
6897 ok(is1.base_ios.delbuf == 1, "expected 1 got %d\n", is1.base_ios.delbuf);
6898 ok(is1.base_ios.tie == is2.base_ios.tie, "expected %p got %p\n", is2.base_ios.tie, is1.base_ios.tie);
6899 ok(is1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, is1.base_ios.flags);
6900 ok(is1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.precision);
6901 ok(is1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", is1.base_ios.fill);
6902 ok(is1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.width);
6903 ok(is1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.do_lock);
6904 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
6905 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
6906 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
6907 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
6908 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
6909 ok(pssb->base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, pssb->base.ebuf);
6910 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
6911 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
6912 ok(pssb->base.egptr == buffer + 4, "wrong get end, expected %p got %p\n", buffer + 4, pssb->base.egptr);
6913 ok(pssb->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pssb->base.pbase);
6914 ok(pssb->base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, pssb->base.pptr);
6915 ok(pssb->base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, pssb->base.epptr);
6916 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
6917 call_func1(p_istrstream_dtor, &is1.base_ios);
6918 ok(is1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, is1.base_ios.sb);
6919 ok(is1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.state);
6920 call_func1(p_strstreambuf_dtor, pssb);
6921 p_operator_delete(pssb);
6923 memset(&is1, 0xab, sizeof(istream));
6924 buffer[0] = 0;
6925 pis = call_func3(p_istrstream_str_ctor, &is1, buffer, TRUE);
6926 pssb = (strstreambuf*) is1.base_ios.sb;
6927 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6928 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
6929 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
6930 ok(is1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is1.base_ios.sb);
6931 ok(is1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is1.base_ios.state);
6932 ok(is1.base_ios.delbuf == 1, "expected 1 got %d\n", is1.base_ios.delbuf);
6933 ok(is1.base_ios.tie == NULL, "expected %p got %p\n", NULL, is1.base_ios.tie);
6934 ok(is1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, is1.base_ios.flags);
6935 ok(is1.base_ios.precision == 6, "expected 6 got %d\n", is1.base_ios.precision);
6936 ok(is1.base_ios.fill == ' ', "expected 32 got %d\n", is1.base_ios.fill);
6937 ok(is1.base_ios.width == 0, "expected 0 got %d\n", is1.base_ios.width);
6938 ok(is1.base_ios.do_lock == -1, "expected -1 got %d\n", is1.base_ios.do_lock);
6939 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
6940 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
6941 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
6942 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
6943 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
6944 ok(pssb->base.ebuf == buffer, "wrong buffer end, expected %p got %p\n", buffer, pssb->base.ebuf);
6945 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
6946 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
6947 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
6948 ok(pssb->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pssb->base.pbase);
6949 ok(pssb->base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, pssb->base.pptr);
6950 ok(pssb->base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, pssb->base.epptr);
6951 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
6952 call_func1(p_istrstream_vbase_dtor, &is1);
6953 ok(is1.base_ios.sb == NULL, "expected %p got %p\n", NULL, is1.base_ios.sb);
6954 ok(is1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is1.base_ios.state);
6955 if (0) /* crashes on native */
6956 pis = call_func3(p_istrstream_str_ctor, &is1, NULL, TRUE);
6957 is1.extract_delim = is1.count = 0xabababab;
6958 memset(&is1.base_ios, 0xab, sizeof(ios));
6959 is1.base_ios.delbuf = 0;
6960 pis = call_func3(p_istrstream_str_ctor, &is1, buffer, FALSE);
6961 pssb = (strstreambuf*) is1.base_ios.sb;
6962 ok(pis == &is1, "wrong return, expected %p got %p\n", &is1, pis);
6963 ok(is1.extract_delim == 0, "expected 0 got %d\n", is1.extract_delim);
6964 ok(is1.count == 0, "expected 0 got %d\n", is1.count);
6965 ok(is1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, is1.base_ios.sb);
6966 ok(is1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.state);
6967 ok(is1.base_ios.delbuf == 1, "expected 1 got %d\n", is1.base_ios.delbuf);
6968 ok(is1.base_ios.tie == is2.base_ios.tie, "expected %p got %p\n", is2.base_ios.tie, is1.base_ios.tie);
6969 ok(is1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, is1.base_ios.flags);
6970 ok(is1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.precision);
6971 ok(is1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", is1.base_ios.fill);
6972 ok(is1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.width);
6973 ok(is1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.do_lock);
6974 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
6975 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
6976 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
6977 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
6978 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
6979 ok(pssb->base.ebuf == buffer, "wrong buffer end, expected %p got %p\n", buffer, pssb->base.ebuf);
6980 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
6981 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
6982 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
6983 ok(pssb->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pssb->base.pbase);
6984 ok(pssb->base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, pssb->base.pptr);
6985 ok(pssb->base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, pssb->base.epptr);
6986 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
6987 call_func1(p_istrstream_dtor, &is1.base_ios);
6988 ok(is1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, is1.base_ios.sb);
6989 ok(is1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is1.base_ios.state);
6990 call_func1(p_strstreambuf_dtor, pssb);
6991 p_operator_delete(pssb);
6993 is1.extract_delim = is1.count = 0xcdcdcdcd;
6994 memset(&is1.base_ios, 0xcd, sizeof(ios));
6995 pis = call_func3(p_istrstream_copy_ctor, &is2, &is1, TRUE);
6996 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
6997 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
6998 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
6999 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
7000 ok(is2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, is2.base_ios.state);
7001 ok(is2.base_ios.delbuf == 0, "expected 0 got %d\n", is2.base_ios.delbuf);
7002 ok(is2.base_ios.tie == is1.base_ios.tie, "expected %p got %p\n", is1.base_ios.tie, is2.base_ios.tie);
7003 ok(is2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, is2.base_ios.flags);
7004 ok(is2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", is2.base_ios.precision);
7005 ok(is2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", is2.base_ios.fill);
7006 ok(is2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", is2.base_ios.width);
7007 ok(is2.base_ios.do_lock == -1, "expected -1 got %d\n", is2.base_ios.do_lock);
7008 call_func1(p_istrstream_vbase_dtor, &is2);
7009 ok(is2.base_ios.sb == NULL, "expected %p got %p\n", NULL, is2.base_ios.sb);
7010 ok(is2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, is2.base_ios.state);
7011 is2.extract_delim = is2.count = 0xabababab;
7012 memset(&is2.base_ios, 0xab, sizeof(ios));
7013 is2.base_ios.delbuf = 0;
7014 pos = is2.base_ios.tie;
7015 pis = call_func3(p_istrstream_copy_ctor, &is2, &is1, FALSE);
7016 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
7017 ok(is2.extract_delim == 0, "expected 0 got %d\n", is2.extract_delim);
7018 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
7019 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
7020 ok(is2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.state);
7021 ok(is2.base_ios.delbuf == 0, "expected 0 got %d\n", is2.base_ios.delbuf);
7022 ok(is2.base_ios.tie == pos, "expected %p got %p\n", pos, is2.base_ios.tie);
7023 ok(is2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, is2.base_ios.flags);
7024 ok(is2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.precision);
7025 ok(is2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", is2.base_ios.fill);
7026 ok(is2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.width);
7027 ok(is2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.do_lock);
7028 call_func1(p_istrstream_dtor, &is2.base_ios);
7030 /* assignment */
7031 is2.extract_delim = is2.count = 0xabababab;
7032 memset(&is2.base_ios, 0xab, sizeof(ios));
7033 is2.base_ios.delbuf = 0;
7034 pis = call_func2(p_istrstream_assign, &is2, &is1);
7035 ok(pis == &is2, "wrong return, expected %p got %p\n", &is2, pis);
7036 ok(is2.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, is2.extract_delim);
7037 ok(is2.count == 0, "expected 0 got %d\n", is2.count);
7038 ok(is2.base_ios.sb == is1.base_ios.sb, "expected %p got %p\n", is1.base_ios.sb, is2.base_ios.sb);
7039 ok(is2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, is2.base_ios.state);
7040 ok(is2.base_ios.delbuf == 0, "expected 0 got %d\n", is2.base_ios.delbuf);
7041 ok(is2.base_ios.tie == NULL, "expected %p got %p\n", NULL, is2.base_ios.tie);
7042 ok(is2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, is2.base_ios.flags);
7043 ok(is2.base_ios.precision == 6, "expected 6 got %d\n", is2.base_ios.precision);
7044 ok(is2.base_ios.fill == ' ', "expected 32 got %d\n", is2.base_ios.fill);
7045 ok(is2.base_ios.width == 0, "expected 0 got %d\n", is2.base_ios.width);
7046 ok(is2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, is2.base_ios.do_lock);
7049 static void test_iostream(void)
7051 iostream ios1, ios2, *pios;
7052 ostream *pos;
7053 streambuf sb;
7055 memset(&ios1, 0xab, sizeof(iostream));
7056 memset(&ios2, 0xab, sizeof(iostream));
7058 /* constructors/destructors */
7059 pios = call_func3(p_iostream_sb_ctor, &ios1, NULL, TRUE);
7060 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7061 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7062 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7063 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7064 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7065 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7066 ok(ios1.base_ios.delbuf == 0, "expected 0 got %d\n", ios1.base_ios.delbuf);
7067 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7068 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7069 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7070 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7071 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7072 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7073 call_func1(p_iostream_vbase_dtor, &ios1);
7074 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7075 ios1.base2.unknown = 0xabababab;
7076 memset(&ios1.base_ios, 0xab, sizeof(ios));
7077 ios1.base_ios.delbuf = 0;
7078 pios = call_func3(p_iostream_sb_ctor, &ios1, NULL, FALSE);
7079 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7080 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7081 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7082 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7083 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7084 ok(ios1.base_ios.state == (0xabababab|IOSTATE_badbit), "expected %d got %d\n",
7085 0xabababab|IOSTATE_badbit, ios1.base_ios.state);
7086 ok(ios1.base_ios.delbuf == 0, "expected 0 got %d\n", ios1.base_ios.delbuf);
7087 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7088 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7089 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7090 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7091 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7092 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
7093 call_func1(p_iostream_dtor, &ios1.base_ios);
7094 memset(&ios1, 0xab, sizeof(iostream));
7095 pios = call_func3(p_iostream_sb_ctor, &ios1, &sb, TRUE);
7096 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7097 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7098 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7099 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7100 ok(ios1.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios1.base_ios.sb);
7101 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7102 ok(ios1.base_ios.delbuf == 0, "expected 0 got %d\n", ios1.base_ios.delbuf);
7103 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7104 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7105 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7106 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7107 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7108 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7109 call_func1(p_iostream_vbase_dtor, &ios1);
7110 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7111 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7112 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7113 ios1.base2.unknown = 0xabababab;
7114 memset(&ios1.base_ios, 0xab, sizeof(ios));
7115 ios1.base_ios.delbuf = 0;
7116 pios = call_func3(p_iostream_sb_ctor, &ios1, &sb, FALSE);
7117 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7118 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7119 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7120 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7121 ok(ios1.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios1.base_ios.sb);
7122 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7123 ok(ios1.base_ios.delbuf == 0, "expected 0 got %d\n", ios1.base_ios.delbuf);
7124 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7125 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7126 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7127 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7128 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7129 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
7130 call_func1(p_iostream_dtor, &ios1.base_ios);
7131 memset(&ios1, 0xab, sizeof(iostream));
7132 pios = call_func2(p_iostream_ctor, &ios1, TRUE);
7133 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7134 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7135 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7136 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7137 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7138 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7139 ok(ios1.base_ios.delbuf == 0, "expected 0 got %d\n", ios1.base_ios.delbuf);
7140 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7141 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7142 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7143 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7144 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7145 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7146 call_func1(p_iostream_vbase_dtor, &ios1);
7147 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7148 ios1.base2.unknown = 0xabababab;
7149 memset(&ios1.base_ios, 0xab, sizeof(ios));
7150 pios = call_func2(p_iostream_ctor, &ios1, FALSE);
7151 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7152 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7153 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7154 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7155 ok(ios1.base_ios.sb == ios2.base_ios.sb, "expected %p got %p\n", ios2.base_ios.sb, ios1.base_ios.sb);
7156 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7157 ok(ios1.base_ios.delbuf == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.delbuf);
7158 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7159 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7160 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7161 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7162 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7163 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
7164 call_func1(p_iostream_dtor, &ios1.base_ios);
7165 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7166 ios1.base2.unknown = 0xabababab;
7167 memset(&ios2, 0xcd, sizeof(iostream));
7168 pios = call_func3(p_iostream_copy_ctor, &ios2, &ios1, TRUE);
7169 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7170 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
7171 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7172 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
7173 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
7174 ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
7175 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7176 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7177 ok(ios2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios2.base_ios.flags);
7178 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7179 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7180 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7181 ok(ios2.base_ios.do_lock == -1, "expected -1 got %d\n", ios2.base_ios.do_lock);
7182 call_func1(p_iostream_vbase_dtor, &ios2);
7183 ios1.base_ios.sb = NULL;
7184 memset(&ios2, 0xcd, sizeof(iostream));
7185 pios = call_func3(p_iostream_copy_ctor, &ios2, &ios1, TRUE);
7186 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7187 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
7188 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7189 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
7190 ok(ios2.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios2.base_ios.sb);
7191 ok(ios2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios2.base_ios.state);
7192 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7193 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7194 ok(ios2.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios2.base_ios.flags);
7195 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7196 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7197 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7198 ok(ios2.base_ios.do_lock == -1, "expected -1 got %d\n", ios2.base_ios.do_lock);
7199 call_func1(p_iostream_vbase_dtor, &ios2);
7200 ios1.base_ios.sb = &sb;
7201 ios2.base1.extract_delim = ios2.base1.count = 0xcdcdcdcd;
7202 ios2.base2.unknown = 0xcdcdcdcd;
7203 memset(&ios2.base_ios, 0xcd, sizeof(ios));
7204 ios2.base_ios.delbuf = 0;
7205 pos = ios2.base_ios.tie;
7206 pios = call_func3(p_iostream_copy_ctor, &ios2, &ios1, FALSE);
7207 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7208 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
7209 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7210 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
7211 ok(ios2.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios2.base_ios.sb);
7212 ok(ios2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, ios2.base_ios.state);
7213 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7214 ok(ios2.base_ios.tie == pos, "expected %p got %p\n", pos, ios2.base_ios.tie);
7215 ok(ios2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, ios2.base_ios.flags);
7216 ok(ios2.base_ios.precision == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.precision);
7217 ok(ios2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.fill);
7218 ok(ios2.base_ios.width == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.width);
7219 ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
7220 call_func1(p_iostream_dtor, &ios2.base_ios);
7222 /* assignment */
7223 ios2.base1.extract_delim = ios2.base1.count = 0xcdcdcdcd;
7224 ios2.base2.unknown = 0xcdcdcdcd;
7225 ios2.base_ios.sb = (streambuf*) 0xcdcdcdcd;
7226 ios2.base_ios.state = 0xcdcdcdcd;
7227 pios = call_func2(p_iostream_assign_sb, &ios2, &sb);
7228 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7229 ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
7230 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7231 ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
7232 ok(ios2.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios2.base_ios.sb);
7233 ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
7234 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7235 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7236 ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
7237 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7238 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7239 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7240 ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
7241 ios2.base1.count = 0xcdcdcdcd;
7242 memset(&ios2.base_ios, 0xcd, sizeof(ios));
7243 ios2.base_ios.delbuf = 0;
7244 pios = call_func2(p_iostream_assign_sb, &ios2, NULL);
7245 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7246 ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
7247 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7248 ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
7249 ok(ios2.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios2.base_ios.sb);
7250 ok(ios2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios2.base_ios.state);
7251 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7252 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7253 ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
7254 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7255 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7256 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7257 ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
7258 ios2.base1.count = 0xcdcdcdcd;
7259 memset(&ios2.base_ios, 0xcd, sizeof(ios));
7260 ios2.base_ios.delbuf = 0;
7261 if (0) /* crashes on native */
7262 pios = call_func2(p_iostream_assign, &ios2, NULL);
7263 pios = call_func2(p_iostream_assign, &ios2, &ios1);
7264 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7265 ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
7266 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7267 ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
7268 ok(ios2.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios2.base_ios.sb);
7269 ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
7270 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7271 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7272 ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
7273 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7274 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7275 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7276 ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
7279 static void test_ifstream(void)
7281 const char *filename = "ifstream_test";
7282 istream ifs, ifs_copy, *pifs;
7283 streambuf *psb;
7284 filebuf *pfb;
7285 char buffer[64];
7286 char st[8];
7287 int fd, ret, i;
7289 memset(&ifs, 0xab, sizeof(istream));
7291 /* constructors/destructors */
7292 pifs = call_func2(p_ifstream_ctor, &ifs, TRUE);
7293 pfb = (filebuf*) ifs.base_ios.sb;
7294 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7295 ok(ifs.extract_delim == 0, "expected 0 got %d\n", ifs.extract_delim);
7296 ok(ifs.count == 0, "expected 0 got %d\n", ifs.count);
7297 ok(ifs.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ifs.base_ios.sb);
7298 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7299 ok(ifs.base_ios.delbuf == 1, "expected 1 got %d\n", ifs.base_ios.delbuf);
7300 ok(ifs.base_ios.tie == NULL, "expected %p got %p\n", NULL, ifs.base_ios.tie);
7301 ok(ifs.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ifs.base_ios.flags);
7302 ok(ifs.base_ios.precision == 6, "expected 6 got %d\n", ifs.base_ios.precision);
7303 ok(ifs.base_ios.fill == ' ', "expected 32 got %d\n", ifs.base_ios.fill);
7304 ok(ifs.base_ios.width == 0, "expected 0 got %d\n", ifs.base_ios.width);
7305 ok(ifs.base_ios.do_lock == -1, "expected -1 got %d\n", ifs.base_ios.do_lock);
7306 ok(pfb->fd == -1, "wrong fd, expected -1 got %d\n", pfb->fd);
7307 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
7308 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
7309 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
7310 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
7311 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
7312 ok(pfb->fd == -1, "wrong fd, expected 0 got %d\n", pfb->fd);
7313 call_func1(p_ifstream_vbase_dtor, &ifs);
7315 pifs = call_func3(p_ifstream_fd_ctor, &ifs, 42, TRUE);
7316 pfb = (filebuf*) ifs.base_ios.sb;
7317 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7318 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7319 ok(ifs.base_ios.delbuf == 1, "expected 1 got %d\n", ifs.base_ios.delbuf);
7320 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
7321 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
7322 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
7323 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
7324 ok(pfb->fd == 42, "wrong fd, expected 42 got %d\n", pfb->fd);
7325 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
7327 pifs = call_func3(p_ifstream_copy_ctor, &ifs_copy, &ifs, TRUE);
7328 pfb = (filebuf*) ifs_copy.base_ios.sb;
7329 ok(pifs == &ifs_copy, "wrong return, expected %p got %p\n", &ifs_copy, pifs);
7330 ok(ifs_copy.base_ios.sb == ifs.base_ios.sb, "expected shared streambuf\n");
7331 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7332 ok(ifs_copy.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs_copy.base_ios.state);
7334 call_func1(p_ifstream_vbase_dtor, &ifs_copy);
7335 call_func1(p_ifstream_dtor, &ifs.base_ios);
7337 pifs = call_func5(p_ifstream_buffer_ctor, &ifs, 53, buffer, ARRAY_SIZE(buffer), TRUE);
7338 pfb = (filebuf*) ifs.base_ios.sb;
7339 ok(ifs.base_ios.delbuf == 1, "expected 1 got %d\n", ifs.base_ios.delbuf);
7340 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7341 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7342 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
7343 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
7344 ok(pfb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pfb->base.base);
7345 ok(pfb->base.ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), pfb->base.ebuf);
7346 ok(pfb->fd == 53, "wrong fd, expected 53 got %d\n", pfb->fd);
7347 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
7348 call_func1(p_ifstream_dtor, &ifs.base_ios);
7350 pifs = call_func5(p_ifstream_buffer_ctor, &ifs, 64, NULL, 0, TRUE);
7351 pfb = (filebuf*) ifs.base_ios.sb;
7352 ok(ifs.base_ios.delbuf == 1, "expected 1 got %d\n", ifs.base_ios.delbuf);
7353 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7354 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7355 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7356 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
7357 ok(pfb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pfb->base.unbuffered);
7358 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
7359 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
7360 ok(pfb->fd == 64, "wrong fd, expected 64 got %d\n", pfb->fd);
7361 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
7362 call_func1(p_ifstream_vbase_dtor, &ifs);
7364 pifs = call_func5(p_ifstream_open_ctor, &ifs, filename, OPENMODE_in, filebuf_openprot, TRUE);
7365 pfb = (filebuf*) ifs.base_ios.sb;
7366 ok(ifs.base_ios.delbuf == 1, "expected 1 got %d\n", ifs.base_ios.delbuf);
7367 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7368 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7369 ok(pfb->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pfb->base.allocated);
7370 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
7371 ok(pfb->base.base != NULL, "wrong buffer, expected not %p got %p\n", NULL, pfb->base.base);
7372 ok(pfb->base.ebuf != NULL, "wrong ebuf, expected not %p got %p\n", NULL, pfb->base.ebuf);
7373 ok(pfb->fd != -1, "wrong fd, expected not -1 got %d\n", pfb->fd);
7374 fd = pfb->fd;
7375 ok(pfb->close == 1, "wrong value, expected 1 got %d\n", pfb->close);
7376 call_func1(p_ifstream_vbase_dtor, &ifs);
7377 ok(_close(fd) == -1, "expected ifstream to close opened file\n");
7379 /* setbuf */
7380 call_func5(p_ifstream_buffer_ctor, &ifs, -1, NULL, 0, TRUE);
7381 ok(ifs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7382 ok(ifs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7383 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pfb->base.unbuffered);
7384 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7386 psb = call_func3(p_ifstream_setbuf, &ifs, buffer, ARRAY_SIZE(buffer));
7387 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7388 ok(ifs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ifs.base_ios.sb->base);
7389 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7390 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7391 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7392 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7394 psb = call_func3(p_ifstream_setbuf, &ifs, NULL, 0);
7395 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7396 ok(ifs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ifs.base_ios.sb->base);
7397 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7398 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7399 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7400 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7401 call_func1(p_ifstream_vbase_dtor, &ifs);
7403 call_func2(p_ifstream_ctor, &ifs, TRUE);
7404 ok(ifs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7405 ok(ifs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7406 ok(ifs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ifs.base_ios.sb->unbuffered);
7407 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7408 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7410 psb = call_func3(p_ifstream_setbuf, &ifs, buffer, ARRAY_SIZE(buffer));
7411 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7412 ok(ifs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ifs.base_ios.sb->base);
7413 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7414 ok(ifs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ifs.base_ios.sb->unbuffered);
7415 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7416 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7418 psb = call_func3(p_ifstream_setbuf, &ifs, NULL, 0);
7419 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7420 ok(ifs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, ifs.base_ios.sb->base);
7421 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7422 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7423 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7424 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7426 psb = call_func3(p_ifstream_setbuf, &ifs, buffer + 8, ARRAY_SIZE(buffer) - 8);
7427 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7428 ok(ifs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, ifs.base_ios.sb->base);
7429 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7430 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7431 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7432 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7434 psb = call_func3(p_ifstream_setbuf, &ifs, buffer + 8, 0);
7435 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7436 ok(ifs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, ifs.base_ios.sb->base);
7437 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7438 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7439 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7440 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7442 psb = call_func3(p_ifstream_setbuf, &ifs, buffer + 4, ARRAY_SIZE(buffer) - 4);
7443 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7444 ok(ifs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, ifs.base_ios.sb->base);
7445 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7446 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7447 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7448 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7450 psb = call_func3(p_ifstream_setbuf, &ifs, NULL, 5);
7451 ok(psb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, psb);
7452 ok(ifs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, ifs.base_ios.sb->base);
7453 ok(ifs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), ifs.base_ios.sb->ebuf);
7454 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7455 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7456 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7457 call_func1(p_ifstream_vbase_dtor, &ifs);
7459 /* setbuf - seems to be a nop and always return NULL in those other cases */
7460 pifs = call_func5(p_ifstream_buffer_ctor, &ifs, 42, NULL, 0, TRUE);
7461 ok(ifs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7462 ok(ifs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7463 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7464 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7466 ifs.base_ios.state = IOSTATE_eofbit;
7467 psb = call_func3(p_ifstream_setbuf, &ifs, buffer, ARRAY_SIZE(buffer));
7468 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
7469 ok(ifs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7470 ok(ifs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7471 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7472 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7473 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
7475 ifs.base_ios.state = IOSTATE_eofbit;
7476 psb = call_func3(p_ifstream_setbuf, &ifs, NULL, 0);
7477 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
7478 ok(ifs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7479 ok(ifs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7480 ok(ifs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", ifs.base_ios.sb->unbuffered);
7481 ok(ifs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", ifs.base_ios.sb->allocated);
7482 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
7483 call_func1(p_ifstream_vbase_dtor, &ifs);
7485 pifs = call_func5(p_ifstream_open_ctor, &ifs, filename, OPENMODE_in, filebuf_openprot, TRUE);
7486 ifs.base_ios.state = IOSTATE_eofbit;
7487 psb = call_func3(p_ifstream_setbuf, &ifs, NULL, 0);
7488 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
7489 ok(ifs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7490 ok(ifs.base_ios.sb->ebuf != NULL, "wrong ebuf value, expected NULL got %p\n", ifs.base_ios.sb->ebuf);
7491 ok(ifs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ifs.base_ios.sb->unbuffered);
7492 ok(ifs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", ifs.base_ios.sb->allocated);
7493 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
7495 ifs.base_ios.state = IOSTATE_eofbit;
7496 psb = call_func3(p_ifstream_setbuf, &ifs, buffer, ARRAY_SIZE(buffer));
7497 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
7498 ok(ifs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", ifs.base_ios.sb->base);
7499 ok(ifs.base_ios.sb->base != buffer, "wrong base value, expected not %p got %p\n", buffer, ifs.base_ios.sb->base);
7500 ok(ifs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", ifs.base_ios.sb->unbuffered);
7501 ok(ifs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", ifs.base_ios.sb->allocated);
7502 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
7503 call_func1(p_ifstream_vbase_dtor, &ifs);
7505 /* attach */
7506 pifs = call_func2(p_ifstream_ctor, &ifs, TRUE);
7507 pfb = (filebuf*) ifs.base_ios.sb;
7508 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7509 call_func2(p_ifstream_attach, &ifs, 42);
7510 ok(ifs.base_ios.state == IOSTATE_goodbit, "attaching on vanilla stream set some state bits\n");
7511 fd = (int) call_func1(p_ifstream_fd, &ifs);
7512 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
7513 ok(pfb->close == 0, "wrong close value, expected 0 got %d\n", pfb->close);
7514 ifs.base_ios.state = IOSTATE_eofbit;
7515 call_func2(p_ifstream_attach, &ifs, 53);
7516 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
7517 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
7518 call_func1(p_ifstream_vbase_dtor, &ifs);
7520 /* fd */
7521 pifs = call_func2(p_ifstream_ctor, &ifs, TRUE);
7522 pfb = (filebuf*) ifs.base_ios.sb;
7523 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7524 fd = (int) call_func1(p_ifstream_fd, &ifs);
7525 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7526 ok(fd == -1, "wrong fd, expected -1 but got %d\n", fd);
7527 call_func1(p_ifstream_vbase_dtor, &ifs);
7529 pifs = call_func5(p_ifstream_open_ctor, &ifs, filename, OPENMODE_in, filebuf_openprot, TRUE);
7530 pfb = (filebuf*) ifs.base_ios.sb;
7531 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7532 fd = (int) call_func1(p_ifstream_fd, &ifs);
7533 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7534 ok(fd == pfb->fd, "wrong fd, expected %d but got %d\n", pfb->fd, fd);
7536 /* rdbuf */
7537 pfb = (filebuf*) call_func1(p_ifstream_rdbuf, &ifs);
7538 ok((streambuf*) pfb == ifs.base_ios.sb, "wrong return, expected %p got %p\n", ifs.base_ios.sb, pfb);
7539 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7541 /* setmode */
7542 ret = (int) call_func2(p_ifstream_setmode, &ifs, filebuf_binary);
7543 ok(ret == filebuf_text, "wrong return, expected %d got %d\n", filebuf_text, ret);
7544 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7545 ret = (int) call_func2(p_ifstream_setmode, &ifs, filebuf_binary);
7546 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
7547 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7548 ret = (int) call_func2(p_ifstream_setmode, &ifs, filebuf_text);
7549 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
7550 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7551 ret = (int) call_func2(p_ifstream_setmode, &ifs, 0x9000);
7552 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
7553 ok(ifs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ifs.base_ios.state);
7555 /* close && is_open */
7556 ok((int) call_func1(p_ifstream_is_open, &ifs) == 1, "expected ifstream to be open\n");
7557 ifs.base_ios.state = IOSTATE_eofbit | IOSTATE_failbit;
7558 call_func1(p_ifstream_close, &ifs);
7559 ok(ifs.base_ios.state == IOSTATE_goodbit, "close did not clear state = %d\n", ifs.base_ios.state);
7560 ifs.base_ios.state = IOSTATE_eofbit;
7561 call_func1(p_ifstream_close, &ifs);
7562 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "close on a closed stream did not set failbit\n");
7563 ok((int) call_func1(p_ifstream_is_open, &ifs) == 0, "expected ifstream to not be open\n");
7564 ok(_close(fd) == -1, "expected close to close the opened file\n");
7566 /* open */
7567 ifs.base_ios.state = IOSTATE_eofbit;
7568 call_func4(p_ifstream_open, &ifs, filename, OPENMODE_in, filebuf_openprot);
7569 fd = (int) call_func1(p_ifstream_fd, &ifs);
7570 ok(fd != -1, "wrong fd, expected not -1 got %d\n", fd);
7571 ok(ifs.base_ios.state == IOSTATE_eofbit, "open did not succeed\n");
7572 call_func4(p_ifstream_open, &ifs, filename, OPENMODE_in, filebuf_openprot);
7573 ok(ifs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "second open did not set failbit\n");
7574 call_func1(p_ifstream_close, &ifs);
7576 /* write something we can read later */
7577 fd = _open(filename, _O_TRUNC|_O_CREAT|_O_RDWR, _S_IWRITE);
7578 ok(fd != -1, "_open failed\n");
7579 ok(_write(fd, "test 12", 7) == 7, "_write failed\n");
7580 ok(_close(fd) == 0, "_close failed\n");
7582 /* integration with parent istream - reading */
7583 ifs.base_ios.state = IOSTATE_goodbit; /* open doesn't clear the state */
7584 call_func4(p_ifstream_open, &ifs, filename, OPENMODE_out, filebuf_openprot); /* make sure that OPENMODE_in is implicit */
7585 memset(st, 'A', sizeof(st));
7586 st[7] = 0;
7587 pifs = call_func2(p_istream_read_str, &ifs, st);
7588 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7589 ok(!strcmp(st, "test"), "expected 'test' got '%s'\n", st);
7591 i = 12345;
7592 pifs = call_func2(p_istream_read_int, pifs, &i);
7593 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7594 ok(i == 12, "expected 12 got %d\n", i);
7595 call_func1(p_ifstream_vbase_dtor, &ifs);
7597 /* make sure that OPENMODE_in is implicit with open_ctor */
7598 pifs = call_func5(p_ifstream_open_ctor, &ifs, filename, OPENMODE_out, filebuf_openprot, TRUE);
7599 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7600 memset(st, 'A', sizeof(st));
7601 st[7] = 0;
7602 pifs = call_func2(p_istream_read_str, &ifs, st);
7603 ok(pifs == &ifs, "wrong return, expected %p got %p\n", &ifs, pifs);
7604 ok(!strcmp(st, "test"), "expected 'test' got '%s'\n", st);
7605 call_func1(p_ifstream_vbase_dtor, &ifs);
7606 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
7609 static void test_strstream(void)
7611 iostream ios1, ios2, *pios;
7612 ostream *pos;
7613 strstreambuf *pssb;
7614 char buffer[32];
7616 memset(&ios1, 0xab, sizeof(iostream));
7617 memset(&ios2, 0xab, sizeof(iostream));
7619 /* constructors/destructors */
7620 pios = call_func2(p_strstream_ctor, &ios1, TRUE);
7621 pssb = (strstreambuf*) ios1.base_ios.sb;
7622 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7623 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7624 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7625 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7626 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7627 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7628 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7629 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7630 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7631 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7632 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7633 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7634 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7635 ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
7636 ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
7637 ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
7638 ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
7639 ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
7640 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7641 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7642 ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
7643 ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
7644 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7645 call_func1(p_strstream_vbase_dtor, &ios1);
7646 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7647 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7648 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7649 ios1.base2.unknown = 0xabababab;
7650 memset(&ios1.base_ios, 0xab, sizeof(ios));
7651 ios1.base_ios.delbuf = 0;
7652 pios = call_func2(p_strstream_ctor, &ios1, FALSE);
7653 pssb = (strstreambuf*) ios1.base_ios.sb;
7654 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7655 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7656 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7657 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7658 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7659 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7660 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7661 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7662 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7663 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7664 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7665 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7666 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
7667 ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
7668 ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
7669 ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
7670 ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
7671 ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
7672 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7673 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7674 ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
7675 ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
7676 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7677 call_func1(p_strstream_dtor, &ios1.base_ios);
7678 ok(ios1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, ios1.base_ios.sb);
7679 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7680 call_func1(p_strstreambuf_dtor, pssb);
7681 p_operator_delete(pssb);
7683 memset(&ios1, 0xab, sizeof(iostream));
7684 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 32, 0, TRUE);
7685 pssb = (strstreambuf*) ios1.base_ios.sb;
7686 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7687 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7688 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7689 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7690 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7691 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7692 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7693 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7694 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7695 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7696 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7697 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7698 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7699 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7700 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7701 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7702 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7703 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7704 ok(pssb->base.ebuf == buffer + 32, "wrong buffer end, expected %p got %p\n", buffer + 32, pssb->base.ebuf);
7705 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7706 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7707 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7708 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7709 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
7710 ok(pssb->base.epptr == buffer + 32, "wrong put end, expected %p got %p\n", buffer + 32, pssb->base.epptr);
7711 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7712 call_func1(p_strstream_vbase_dtor, &ios1);
7713 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7714 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7715 memset(&ios1, 0xab, sizeof(iostream));
7716 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_in, TRUE);
7717 pssb = (strstreambuf*) ios1.base_ios.sb;
7718 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7719 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7720 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7721 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7722 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7723 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7724 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7725 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7726 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7727 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7728 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7729 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7730 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7731 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7732 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7733 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7734 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7735 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7736 ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
7737 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7738 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7739 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7740 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7741 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
7742 ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
7743 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7744 call_func1(p_strstream_vbase_dtor, &ios1);
7745 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7746 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7747 memset(&ios1, 0xab, sizeof(iostream));
7748 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, -1, OPENMODE_in|OPENMODE_out, TRUE);
7749 pssb = (strstreambuf*) ios1.base_ios.sb;
7750 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7751 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7752 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7753 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7754 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7755 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7756 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7757 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7758 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7759 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7760 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7761 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7762 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7763 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7764 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7765 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7766 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7767 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7768 ok(pssb->base.ebuf == (char *)((ULONG_PTR)buffer + 0x7fffffff) || pssb->base.ebuf == (char*) -1,
7769 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.ebuf);
7770 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7771 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7772 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7773 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7774 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
7775 ok(pssb->base.epptr == (char *)((ULONG_PTR)buffer + 0x7fffffff) || pssb->base.epptr == (char*) -1,
7776 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.epptr);
7777 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7778 call_func1(p_strstream_vbase_dtor, &ios1);
7779 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7780 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7781 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7782 ios1.base2.unknown = 0xabababab;
7783 memset(&ios1.base_ios, 0xab, sizeof(ios));
7784 ios1.base_ios.delbuf = 0;
7785 strcpy(buffer, "Test");
7786 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 0, OPENMODE_in|OPENMODE_app, FALSE);
7787 pssb = (strstreambuf*) ios1.base_ios.sb;
7788 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7789 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7790 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7791 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7792 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7793 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7794 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7795 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7796 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7797 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7798 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7799 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7800 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
7801 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7802 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7803 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7804 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7805 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7806 ok(pssb->base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, pssb->base.ebuf);
7807 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7808 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7809 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7810 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7811 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
7812 ok(pssb->base.epptr == buffer + 4, "wrong put end, expected %p got %p\n", buffer + 4, pssb->base.epptr);
7813 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7814 call_func1(p_strstream_dtor, &ios1.base_ios);
7815 ok(ios1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, ios1.base_ios.sb);
7816 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7817 call_func1(p_strstreambuf_dtor, pssb);
7818 p_operator_delete(pssb);
7819 memset(&ios1, 0xab, sizeof(iostream));
7820 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_ate, TRUE);
7821 pssb = (strstreambuf*) ios1.base_ios.sb;
7822 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7823 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7824 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7825 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7826 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7827 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7828 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7829 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7830 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7831 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7832 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7833 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7834 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7835 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7836 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7837 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7838 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7839 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7840 ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
7841 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7842 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7843 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7844 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7845 ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
7846 ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
7847 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7848 call_func1(p_strstream_vbase_dtor, &ios1);
7849 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7850 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7851 pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_out|OPENMODE_ate, TRUE);
7852 pssb = (strstreambuf*) ios1.base_ios.sb;
7853 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7854 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7855 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7856 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7857 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7858 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7859 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7860 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7861 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7862 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7863 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7864 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7865 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7866 ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
7867 ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
7868 ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
7869 ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
7870 ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
7871 ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
7872 ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
7873 ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
7874 ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
7875 ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
7876 ok(pssb->base.pptr == buffer + 4, "wrong put pointer, expected %p got %p\n", buffer + 4, pssb->base.pptr);
7877 ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
7878 ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
7879 call_func1(p_strstream_vbase_dtor, &ios1);
7880 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7881 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7883 ios1.base1.extract_delim = ios1.base1.count = 0xcdcdcdcd;
7884 ios1.base2.unknown = 0xcdcdcdcd;
7885 memset(&ios1.base_ios, 0xcd, sizeof(ios));
7886 pios = call_func3(p_strstream_copy_ctor, &ios2, &ios1, TRUE);
7887 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7888 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
7889 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7890 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
7891 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
7892 ok(ios2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, ios2.base_ios.state);
7893 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7894 ok(ios2.base_ios.tie == ios1.base_ios.tie, "expected %p got %p\n", ios1.base_ios.tie, ios2.base_ios.tie);
7895 ok(ios2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, ios2.base_ios.flags);
7896 ok(ios2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.precision);
7897 ok(ios2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.fill);
7898 ok(ios2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.width);
7899 ok(ios2.base_ios.do_lock == -1, "expected -1 got %d\n", ios2.base_ios.do_lock);
7900 call_func1(p_strstream_vbase_dtor, &ios2);
7901 ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
7902 ios2.base2.unknown = 0xabababab;
7903 memset(&ios2.base_ios, 0xab, sizeof(ios));
7904 ios2.base_ios.delbuf = 0;
7905 pos = ios2.base_ios.tie;
7906 pios = call_func3(p_strstream_copy_ctor, &ios2, &ios1, FALSE);
7907 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
7908 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
7909 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7910 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
7911 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
7912 ok(ios2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.state);
7913 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7914 ok(ios2.base_ios.tie == pos, "expected %p got %p\n", pos, ios2.base_ios.tie);
7915 ok(ios2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios2.base_ios.flags);
7916 ok(ios2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.precision);
7917 ok(ios2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios2.base_ios.fill);
7918 ok(ios2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.width);
7919 ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
7920 call_func1(p_strstream_dtor, &ios2.base_ios);
7922 /* assignment */
7923 ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
7924 ios2.base2.unknown = 0xabababab;
7925 memset(&ios2.base_ios, 0xab, sizeof(ios));
7926 ios2.base_ios.delbuf = 0;
7927 pios = call_func2(p_strstream_assign, &ios2, &ios1);
7928 ok(ios2.base1.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base1.extract_delim);
7929 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
7930 ok(ios2.base2.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base2.unknown);
7931 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
7932 ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
7933 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
7934 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
7935 ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
7936 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
7937 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
7938 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
7939 ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
7942 static void test_stdiostream(void)
7944 iostream ios1, ios2, *pios;
7945 ostream *pos;
7946 stdiobuf *pstb;
7947 FILE *file;
7948 const char filename[] = "stdiostream_test";
7950 memset(&ios1, 0xab, sizeof(iostream));
7951 memset(&ios2, 0xab, sizeof(iostream));
7953 file = fopen(filename, "w+");
7954 ok(file != NULL, "Couldn't open the file named '%s'\n", filename);
7956 /* constructors/destructors */
7957 pios = call_func3(p_stdiostream_file_ctor, &ios1, file, TRUE);
7958 pstb = (stdiobuf*) ios1.base_ios.sb;
7959 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7960 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7961 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7962 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7963 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7964 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
7965 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7966 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
7967 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
7968 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
7969 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
7970 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
7971 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
7972 ok(pstb->file == file, "expected %p, got %p\n", file, pstb->file);
7973 ok(pstb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pstb->base.allocated);
7974 ok(pstb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pstb->base.unbuffered);
7975 ok(pstb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pstb->base.base);
7976 ok(pstb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pstb->base.ebuf);
7977 ok(pstb->base.do_lock == -1, "expected -1 got %d\n", pstb->base.do_lock);
7978 call_func1(p_stdiostream_vbase_dtor, &ios1);
7979 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
7980 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
7981 ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
7982 ios1.base2.unknown = 0xabababab;
7983 memset(&ios1.base_ios, 0xab, sizeof(ios));
7984 ios1.base_ios.delbuf = 0;
7985 pios = call_func3(p_stdiostream_file_ctor, &ios1, file, FALSE);
7986 pstb = (stdiobuf*) ios1.base_ios.sb;
7987 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
7988 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
7989 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
7990 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
7991 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
7992 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
7993 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
7994 ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
7995 ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
7996 ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
7997 ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
7998 ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
7999 ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
8000 ok(pstb->file == file, "expected %p, got %p\n", file, pstb->file);
8001 ok(pstb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pstb->base.allocated);
8002 ok(pstb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pstb->base.unbuffered);
8003 ok(pstb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pstb->base.base);
8004 ok(pstb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pstb->base.ebuf);
8005 ok(pstb->base.do_lock == -1, "expected -1 got %d\n", pstb->base.do_lock);
8006 call_func1(p_stdiostream_dtor, &ios1.base_ios);
8007 ok(ios1.base_ios.sb == &pstb->base, "expected %p got %p\n", &pstb->base, ios1.base_ios.sb);
8008 ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
8009 call_func1(p_stdiobuf_dtor, pstb);
8010 p_operator_delete(pstb);
8011 memset(&ios1, 0xab, sizeof(iostream));
8012 pios = call_func3(p_stdiostream_file_ctor, &ios1, NULL, TRUE);
8013 pstb = (stdiobuf*) ios1.base_ios.sb;
8014 ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
8015 ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
8016 ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
8017 ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
8018 ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
8019 ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
8020 ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
8021 ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
8022 ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
8023 ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
8024 ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
8025 ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
8026 ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
8027 ok(pstb->file == NULL, "expected %p, got %p\n", NULL, pstb->file);
8028 ok(pstb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pstb->base.allocated);
8029 ok(pstb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pstb->base.unbuffered);
8030 ok(pstb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pstb->base.base);
8031 ok(pstb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pstb->base.ebuf);
8032 ok(pstb->base.do_lock == -1, "expected -1 got %d\n", pstb->base.do_lock);
8033 call_func1(p_stdiostream_vbase_dtor, &ios1);
8034 ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
8035 ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
8037 ios1.base1.extract_delim = ios1.base1.count = 0xcdcdcdcd;
8038 ios1.base2.unknown = 0xcdcdcdcd;
8039 memset(&ios1.base_ios, 0xcd, sizeof(ios));
8040 pios = call_func3(p_stdiostream_copy_ctor, &ios2, &ios1, TRUE);
8041 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
8042 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
8043 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
8044 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
8045 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
8046 ok(ios2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, ios2.base_ios.state);
8047 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
8048 ok(ios2.base_ios.tie == ios1.base_ios.tie, "expected %p got %p\n", ios1.base_ios.tie, ios2.base_ios.tie);
8049 ok(ios2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, ios2.base_ios.flags);
8050 ok(ios2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.precision);
8051 ok(ios2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.fill);
8052 ok(ios2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.width);
8053 ok(ios2.base_ios.do_lock == -1, "expected -1 got %d\n", ios2.base_ios.do_lock);
8054 call_func1(p_stdiostream_vbase_dtor, &ios2);
8055 ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
8056 ios2.base2.unknown = 0xabababab;
8057 memset(&ios2.base_ios, 0xab, sizeof(ios));
8058 ios2.base_ios.delbuf = 0;
8059 pos = ios2.base_ios.tie;
8060 pios = call_func3(p_stdiostream_copy_ctor, &ios2, &ios1, FALSE);
8061 ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
8062 ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
8063 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
8064 ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
8065 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
8066 ok(ios2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.state);
8067 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
8068 ok(ios2.base_ios.tie == pos, "expected %p got %p\n", pos, ios2.base_ios.tie);
8069 ok(ios2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios2.base_ios.flags);
8070 ok(ios2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.precision);
8071 ok(ios2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios2.base_ios.fill);
8072 ok(ios2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.width);
8073 ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
8074 call_func1(p_stdiostream_dtor, &ios2.base_ios);
8076 /* assignment */
8077 ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
8078 ios2.base2.unknown = 0xabababab;
8079 memset(&ios2.base_ios, 0xab, sizeof(ios));
8080 ios2.base_ios.delbuf = 0;
8081 pios = call_func2(p_stdiostream_assign, &ios2, &ios1);
8082 ok(ios2.base1.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base1.extract_delim);
8083 ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
8084 ok(ios2.base2.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base2.unknown);
8085 ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
8086 ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
8087 ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
8088 ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
8089 ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
8090 ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
8091 ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
8092 ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
8093 ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
8095 fclose(file);
8096 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8099 static void test_Iostream_init(void)
8101 ios ios_obj;
8102 ostream *pos;
8103 streambuf *psb;
8104 void *pinit;
8106 memset(&ios_obj, 0xab, sizeof(ios));
8107 psb = ios_obj.sb;
8108 pinit = call_func3(p_Iostream_init_ios_ctor, NULL, &ios_obj, 0);
8109 ok(pinit == NULL, "wrong return, expected %p got %p\n", NULL, pinit);
8110 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
8111 ok(ios_obj.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.state);
8112 ok(ios_obj.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[0]);
8113 ok(ios_obj.special[1] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[1]);
8114 ok(ios_obj.delbuf == 1, "expected 1 got %d\n", ios_obj.delbuf);
8115 ok(ios_obj.tie == p_cout, "expected %p got %p\n", p_cout, ios_obj.tie);
8116 ok(ios_obj.flags == 0xabababab, "expected %d got %x\n", 0xabababab, ios_obj.flags);
8117 ok(ios_obj.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.precision);
8118 ok(ios_obj.fill == (char) 0xab, "expected -85 got %d\n", ios_obj.fill);
8119 ok(ios_obj.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.width);
8120 ok(ios_obj.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.do_lock);
8122 memset(&ios_obj, 0xab, sizeof(ios));
8123 pos = ios_obj.tie;
8124 pinit = call_func3(p_Iostream_init_ios_ctor, NULL, &ios_obj, -1);
8125 ok(pinit == NULL, "wrong return, expected %p got %p\n", NULL, pinit);
8126 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
8127 ok(ios_obj.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.state);
8128 ok(ios_obj.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[0]);
8129 ok(ios_obj.special[1] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[1]);
8130 ok(ios_obj.delbuf == 1, "expected 1 got %d\n", ios_obj.delbuf);
8131 ok(ios_obj.tie == pos, "expected %p got %p\n", pos, ios_obj.tie);
8132 ok(ios_obj.flags == 0xabababab, "expected %d got %x\n", 0xabababab, ios_obj.flags);
8133 ok(ios_obj.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.precision);
8134 ok(ios_obj.fill == (char) 0xab, "expected -85 got %d\n", ios_obj.fill);
8135 ok(ios_obj.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.width);
8136 ok(ios_obj.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.do_lock);
8138 memset(&ios_obj, 0xab, sizeof(ios));
8139 pinit = call_func3(p_Iostream_init_ios_ctor, NULL, &ios_obj, -100);
8140 ok(pinit == NULL, "wrong return, expected %p got %p\n", NULL, pinit);
8141 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
8142 ok(ios_obj.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.state);
8143 ok(ios_obj.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[0]);
8144 ok(ios_obj.special[1] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[1]);
8145 ok(ios_obj.delbuf == 1, "expected 1 got %d\n", ios_obj.delbuf);
8146 ok(ios_obj.tie == pos, "expected %p got %p\n", pos, ios_obj.tie);
8147 ok(ios_obj.flags == 0xabababab, "expected %d got %x\n", 0xabababab, ios_obj.flags);
8148 ok(ios_obj.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.precision);
8149 ok(ios_obj.fill == (char) 0xab, "expected -85 got %d\n", ios_obj.fill);
8150 ok(ios_obj.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.width);
8151 ok(ios_obj.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.do_lock);
8153 if (0) /* crashes on native */
8154 pinit = call_func3(p_Iostream_init_ios_ctor, NULL, NULL, -1);
8156 memset(&ios_obj, 0xab, sizeof(ios));
8157 ios_obj.flags = 0xcdcdcdcd;
8158 ios_obj.do_lock = 0x34343434;
8159 pinit = call_func3(p_Iostream_init_ios_ctor, (void*) 0xdeadbeef, &ios_obj, 1);
8160 ok(pinit == (void*) 0xdeadbeef, "wrong return, expected %p got %p\n", (void*) 0xdeadbeef, pinit);
8161 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
8162 ok(ios_obj.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.state);
8163 ok(ios_obj.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[0]);
8164 ok(ios_obj.special[1] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[1]);
8165 ok(ios_obj.delbuf == 1, "expected 1 got %d\n", ios_obj.delbuf);
8166 ok(ios_obj.tie == p_cout, "expected %p got %p\n", p_cout, ios_obj.tie);
8167 ok(ios_obj.flags == (0xcdcdcdcd|FLAGS_unitbuf), "expected %d got %x\n",
8168 0xcdcdcdcd|FLAGS_unitbuf, ios_obj.flags);
8169 ok(ios_obj.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.precision);
8170 ok(ios_obj.fill == (char) 0xab, "expected -85 got %d\n", ios_obj.fill);
8171 ok(ios_obj.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.width);
8172 ok(ios_obj.do_lock == 0x34343434, "expected %d got %d\n", 0x34343434, ios_obj.do_lock);
8174 memset(&ios_obj, 0xab, sizeof(ios));
8175 ios_obj.flags = 0xcdcdcdcd;
8176 ios_obj.do_lock = 0x34343434;
8177 pinit = call_func3(p_Iostream_init_ios_ctor, (void*) 0xabababab, &ios_obj, 5);
8178 ok(pinit == (void*) 0xabababab, "wrong return, expected %p got %p\n", (void*) 0xabababab, pinit);
8179 ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
8180 ok(ios_obj.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.state);
8181 ok(ios_obj.special[0] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[0]);
8182 ok(ios_obj.special[1] == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.special[1]);
8183 ok(ios_obj.delbuf == 1, "expected 1 got %d\n", ios_obj.delbuf);
8184 ok(ios_obj.tie == p_cout, "expected %p got %p\n", p_cout, ios_obj.tie);
8185 ok(ios_obj.flags == (0xcdcdcdcd|FLAGS_unitbuf), "expected %d got %x\n",
8186 0xcdcdcdcd|FLAGS_unitbuf, ios_obj.flags);
8187 ok(ios_obj.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.precision);
8188 ok(ios_obj.fill == (char) 0xab, "expected -85 got %d\n", ios_obj.fill);
8189 ok(ios_obj.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios_obj.width);
8190 ok(ios_obj.do_lock == 0x34343434, "expected %d got %d\n", 0x34343434, ios_obj.do_lock);
8193 static void test_std_streams(void)
8195 filebuf *pfb_cin = (filebuf*) p_cin->base_ios.sb;
8196 filebuf *pfb_cout = (filebuf*) p_cout->base_ios.sb;
8197 filebuf *pfb_cerr = (filebuf*) p_cerr->base_ios.sb;
8198 filebuf *pfb_clog = (filebuf*) p_clog->base_ios.sb;
8199 stdiobuf *pstb_cin, *pstb_cout, *pstb_cerr, *pstb_clog;
8201 ok(p_cin->extract_delim == 0, "expected 0 got %d\n", p_cin->extract_delim);
8202 ok(p_cin->count == 0, "expected 0 got %d\n", p_cin->count);
8203 ok(p_cin->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cin->base_ios.state);
8204 ok(p_cin->base_ios.delbuf == 1, "expected 1 got %d\n", p_cin->base_ios.delbuf);
8205 ok(p_cin->base_ios.tie == p_cout, "expected %p got %p\n", p_cout, p_cin->base_ios.tie);
8206 ok(p_cin->base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, p_cin->base_ios.flags);
8207 ok(p_cin->base_ios.precision == 6, "expected 6 got %d\n", p_cin->base_ios.precision);
8208 ok(p_cin->base_ios.fill == ' ', "expected 32 got %d\n", p_cin->base_ios.fill);
8209 ok(p_cin->base_ios.width == 0, "expected 0 got %d\n", p_cin->base_ios.width);
8210 ok(p_cin->base_ios.do_lock == -1, "expected -1 got %d\n", p_cin->base_ios.do_lock);
8211 ok(pfb_cin->fd == 0, "wrong fd, expected 0 got %d\n", pfb_cin->fd);
8212 ok(pfb_cin->close == 0, "wrong value, expected 0 got %d\n", pfb_cin->close);
8213 ok(pfb_cin->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb_cin->base.allocated);
8214 ok(pfb_cin->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb_cin->base.unbuffered);
8216 ok(p_cout->unknown == 0, "expected 0 got %d\n", p_cout->unknown);
8217 ok(p_cout->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cout->base_ios.state);
8218 ok(p_cout->base_ios.delbuf == 1, "expected 1 got %d\n", p_cout->base_ios.delbuf);
8219 ok(p_cout->base_ios.tie == NULL, "expected %p got %p\n", NULL, p_cout->base_ios.tie);
8220 ok(p_cout->base_ios.flags == 0, "expected 0 got %x\n", p_cout->base_ios.flags);
8221 ok(p_cout->base_ios.precision == 6, "expected 6 got %d\n", p_cout->base_ios.precision);
8222 ok(p_cout->base_ios.fill == ' ', "expected 32 got %d\n", p_cout->base_ios.fill);
8223 ok(p_cout->base_ios.width == 0, "expected 0 got %d\n", p_cout->base_ios.width);
8224 ok(p_cout->base_ios.do_lock == -1, "expected -1 got %d\n", p_cout->base_ios.do_lock);
8225 ok(pfb_cout->fd == 1, "wrong fd, expected 1 got %d\n", pfb_cout->fd);
8226 ok(pfb_cout->close == 0, "wrong value, expected 0 got %d\n", pfb_cout->close);
8227 ok(pfb_cout->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb_cout->base.allocated);
8228 ok(pfb_cout->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb_cout->base.unbuffered);
8230 ok(p_cerr->unknown == 0, "expected 0 got %d\n", p_cerr->unknown);
8231 ok(p_cerr->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cerr->base_ios.state);
8232 ok(p_cerr->base_ios.delbuf == 1, "expected 1 got %d\n", p_cerr->base_ios.delbuf);
8233 ok(p_cerr->base_ios.tie == p_cout, "expected %p got %p\n", p_cout, p_cerr->base_ios.tie);
8234 ok(p_cerr->base_ios.flags == FLAGS_unitbuf, "expected %x got %x\n", FLAGS_unitbuf, p_cerr->base_ios.flags);
8235 ok(p_cerr->base_ios.precision == 6, "expected 6 got %d\n", p_cerr->base_ios.precision);
8236 ok(p_cerr->base_ios.fill == ' ', "expected 32 got %d\n", p_cerr->base_ios.fill);
8237 ok(p_cerr->base_ios.width == 0, "expected 0 got %d\n", p_cerr->base_ios.width);
8238 ok(p_cerr->base_ios.do_lock == -1, "expected -1 got %d\n", p_cerr->base_ios.do_lock);
8239 ok(pfb_cerr->fd == 2, "wrong fd, expected 2 got %d\n", pfb_cerr->fd);
8240 ok(pfb_cerr->close == 0, "wrong value, expected 0 got %d\n", pfb_cerr->close);
8241 ok(pfb_cerr->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb_cerr->base.allocated);
8242 ok(pfb_cerr->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb_cerr->base.unbuffered);
8244 ok(p_clog->unknown == 0, "expected 0 got %d\n", p_clog->unknown);
8245 ok(p_clog->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_clog->base_ios.state);
8246 ok(p_clog->base_ios.delbuf == 1, "expected 1 got %d\n", p_clog->base_ios.delbuf);
8247 ok(p_clog->base_ios.tie == p_cout, "expected %p got %p\n", p_cout, p_clog->base_ios.tie);
8248 ok(p_clog->base_ios.flags == 0, "expected 0 got %x\n", p_clog->base_ios.flags);
8249 ok(p_clog->base_ios.precision == 6, "expected 6 got %d\n", p_clog->base_ios.precision);
8250 ok(p_clog->base_ios.fill == ' ', "expected 32 got %d\n", p_clog->base_ios.fill);
8251 ok(p_clog->base_ios.width == 0, "expected 0 got %d\n", p_clog->base_ios.width);
8252 ok(p_clog->base_ios.do_lock == -1, "expected -1 got %d\n", p_clog->base_ios.do_lock);
8253 ok(pfb_clog->fd == 2, "wrong fd, expected 2 got %d\n", pfb_clog->fd);
8254 ok(pfb_clog->close == 0, "wrong value, expected 0 got %d\n", pfb_clog->close);
8255 ok(pfb_clog->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb_clog->base.allocated);
8256 ok(pfb_clog->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb_clog->base.unbuffered);
8258 /* sync_with_stdio */
8259 ok(*p_ios_sunk_with_stdio == 0, "expected 0 got %d\n", *p_ios_sunk_with_stdio);
8260 p_cin->extract_delim = p_cin->count = 0xabababab;
8261 p_cin->base_ios.state = 0xabababab;
8262 p_cin->base_ios.fill = 0xab;
8263 p_cin->base_ios.precision = p_cin->base_ios.width = 0xabababab;
8264 p_cout->unknown = 0xabababab;
8265 p_cout->base_ios.state = 0xabababab;
8266 p_cout->base_ios.fill = 0xab;
8267 p_cout->base_ios.precision = p_cout->base_ios.width = 0xabababab;
8268 p_cerr->unknown = 0xabababab;
8269 p_cerr->base_ios.state = 0xabababab;
8270 p_cerr->base_ios.fill = 0xab;
8271 p_cerr->base_ios.precision = p_cerr->base_ios.width = 0xabababab;
8272 p_clog->unknown = 0xabababab;
8273 p_clog->base_ios.state = 0xabababab;
8274 p_clog->base_ios.fill = 0xab;
8275 p_clog->base_ios.precision = p_clog->base_ios.width = 0xabababab;
8276 p_ios_sync_with_stdio();
8277 ok(*p_ios_sunk_with_stdio == 1, "expected 1 got %d\n", *p_ios_sunk_with_stdio);
8279 pstb_cin = (stdiobuf*) p_cin->base_ios.sb;
8280 ok(p_cin->extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, p_cin->extract_delim);
8281 ok(p_cin->count == 0, "expected 0 got %d\n", p_cin->count);
8282 ok(p_cin->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cin->base_ios.state);
8283 ok(p_cin->base_ios.delbuf == 1, "expected 1 got %d\n", p_cin->base_ios.delbuf);
8284 ok(p_cin->base_ios.tie == NULL, "expected %p got %p\n", NULL, p_cin->base_ios.tie);
8285 ok(p_cin->base_ios.flags == (FLAGS_skipws|FLAGS_stdio), "expected %x got %x\n",
8286 FLAGS_skipws|FLAGS_stdio, p_cin->base_ios.flags);
8287 ok(p_cin->base_ios.precision == 6, "expected 6 got %d\n", p_cin->base_ios.precision);
8288 ok(p_cin->base_ios.fill == ' ', "expected 32 got %d\n", p_cin->base_ios.fill);
8289 ok(p_cin->base_ios.width == 0, "expected 0 got %d\n", p_cin->base_ios.width);
8290 ok(p_cin->base_ios.do_lock == -1, "expected -1 got %d\n", p_cin->base_ios.do_lock);
8291 ok(pstb_cin->file == stdin, "wrong file pointer, expected %p got %p\n", stdin, pstb_cin->file);
8292 ok(pstb_cin->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pstb_cin->base.allocated);
8293 ok(pstb_cin->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pstb_cin->base.unbuffered);
8294 ok(pstb_cin->base.ebuf == NULL, "wrong ebuf pointer, expected %p got %p\n", NULL, pstb_cin->base.eback);
8295 ok(pstb_cin->base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, pstb_cin->base.eback);
8296 ok(pstb_cin->base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, pstb_cin->base.pbase);
8298 pstb_cout = (stdiobuf*) p_cout->base_ios.sb;
8299 ok(p_cout->unknown == 0xabababab, "expected %d got %d\n", 0xabababab, p_cout->unknown);
8300 ok(p_cout->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cout->base_ios.state);
8301 ok(p_cout->base_ios.delbuf == 1, "expected 1 got %d\n", p_cout->base_ios.delbuf);
8302 ok(p_cout->base_ios.tie == NULL, "expected %p got %p\n", NULL, p_cout->base_ios.tie);
8303 ok(p_cout->base_ios.flags == (FLAGS_unitbuf|FLAGS_stdio), "expected %x got %x\n",
8304 FLAGS_unitbuf|FLAGS_stdio, p_cout->base_ios.flags);
8305 ok(p_cout->base_ios.precision == 6, "expected 6 got %d\n", p_cout->base_ios.precision);
8306 ok(p_cout->base_ios.fill == ' ', "expected 32 got %d\n", p_cout->base_ios.fill);
8307 ok(p_cout->base_ios.width == 0, "expected 0 got %d\n", p_cout->base_ios.width);
8308 ok(p_cout->base_ios.do_lock == -1, "expected -1 got %d\n", p_cout->base_ios.do_lock);
8309 ok(pstb_cout->file == stdout, "wrong file pointer, expected %p got %p\n", stdout, pstb_cout->file);
8310 ok(pstb_cout->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pstb_cout->base.allocated);
8311 ok(pstb_cout->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pstb_cout->base.unbuffered);
8312 ok(pstb_cout->base.ebuf == pstb_cout->base.base + 80, "wrong ebuf pointer, expected %p got %p\n",
8313 pstb_cout->base.base + 80, pstb_cout->base.eback);
8314 ok(pstb_cout->base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, pstb_cout->base.eback);
8315 ok(pstb_cout->base.pbase == pstb_cout->base.base, "wrong put base, expected %p got %p\n",
8316 pstb_cout->base.base, pstb_cout->base.pbase);
8317 ok(pstb_cout->base.pptr == pstb_cout->base.base, "wrong put pointer, expected %p got %p\n",
8318 pstb_cout->base.base, pstb_cout->base.pptr);
8319 ok(pstb_cout->base.epptr == pstb_cout->base.base + 80, "wrong put end, expected %p got %p\n",
8320 pstb_cout->base.base + 80, pstb_cout->base.epptr);
8322 pstb_cerr = (stdiobuf*) p_cerr->base_ios.sb;
8323 ok(p_cerr->unknown == 0xabababab, "expected %d got %d\n", 0xabababab, p_cerr->unknown);
8324 ok(p_cerr->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_cerr->base_ios.state);
8325 ok(p_cerr->base_ios.delbuf == 1, "expected 1 got %d\n", p_cerr->base_ios.delbuf);
8326 ok(p_cerr->base_ios.tie == NULL, "expected %p got %p\n", NULL, p_cerr->base_ios.tie);
8327 ok(p_cerr->base_ios.flags == (FLAGS_unitbuf|FLAGS_stdio), "expected %x got %x\n",
8328 FLAGS_unitbuf|FLAGS_stdio, p_cerr->base_ios.flags);
8329 ok(p_cerr->base_ios.precision == 6, "expected 6 got %d\n", p_cerr->base_ios.precision);
8330 ok(p_cerr->base_ios.fill == ' ', "expected 32 got %d\n", p_cerr->base_ios.fill);
8331 ok(p_cerr->base_ios.width == 0, "expected 0 got %d\n", p_cerr->base_ios.width);
8332 ok(p_cerr->base_ios.do_lock == -1, "expected -1 got %d\n", p_cerr->base_ios.do_lock);
8333 ok(pstb_cerr->file == stderr, "wrong file pointer, expected %p got %p\n", stderr, pstb_cerr->file);
8334 ok(pstb_cerr->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pstb_cerr->base.allocated);
8335 ok(pstb_cerr->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pstb_cerr->base.unbuffered);
8336 ok(pstb_cerr->base.ebuf == pstb_cerr->base.base + 80, "wrong ebuf pointer, expected %p got %p\n",
8337 pstb_cerr->base.base + 80, pstb_cerr->base.eback);
8338 ok(pstb_cerr->base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, pstb_cerr->base.eback);
8339 ok(pstb_cerr->base.pbase == pstb_cerr->base.base, "wrong put base, expected %p got %p\n",
8340 pstb_cerr->base.base, pstb_cerr->base.pbase);
8341 ok(pstb_cerr->base.pptr == pstb_cerr->base.base, "wrong put pointer, expected %p got %p\n",
8342 pstb_cerr->base.base, pstb_cerr->base.pptr);
8343 ok(pstb_cerr->base.epptr == pstb_cerr->base.base + 80, "wrong put end, expected %p got %p\n",
8344 pstb_cerr->base.base + 80, pstb_cerr->base.epptr);
8346 pstb_clog = (stdiobuf*) p_clog->base_ios.sb;
8347 ok(p_clog->unknown == 0xabababab, "expected %d got %d\n", 0xabababab, p_clog->unknown);
8348 ok(p_clog->base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, p_clog->base_ios.state);
8349 ok(p_clog->base_ios.delbuf == 1, "expected 1 got %d\n", p_clog->base_ios.delbuf);
8350 ok(p_clog->base_ios.tie == NULL, "expected %p got %p\n", NULL, p_clog->base_ios.tie);
8351 ok(p_clog->base_ios.flags == FLAGS_stdio, "expected %x got %x\n", FLAGS_stdio, p_clog->base_ios.flags);
8352 ok(p_clog->base_ios.precision == 6, "expected 6 got %d\n", p_clog->base_ios.precision);
8353 ok(p_clog->base_ios.fill == ' ', "expected 32 got %d\n", p_clog->base_ios.fill);
8354 ok(p_clog->base_ios.width == 0, "expected 0 got %d\n", p_clog->base_ios.width);
8355 ok(p_clog->base_ios.do_lock == -1, "expected -1 got %d\n", p_clog->base_ios.do_lock);
8356 ok(pstb_clog->file == stderr, "wrong file pointer, expected %p got %p\n", stderr, pstb_clog->file);
8357 ok(pstb_clog->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pstb_clog->base.allocated);
8358 ok(pstb_clog->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pstb_clog->base.unbuffered);
8359 ok(pstb_clog->base.ebuf == pstb_clog->base.base + 512, "wrong ebuf pointer, expected %p got %p\n",
8360 pstb_clog->base.base + 512, pstb_clog->base.eback);
8361 ok(pstb_clog->base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, pstb_clog->base.eback);
8362 ok(pstb_clog->base.pbase == pstb_clog->base.base, "wrong put base, expected %p got %p\n",
8363 pstb_clog->base.base, pstb_clog->base.pbase);
8364 ok(pstb_clog->base.pptr == pstb_clog->base.base, "wrong put pointer, expected %p got %p\n",
8365 pstb_clog->base.base, pstb_clog->base.pptr);
8366 ok(pstb_clog->base.epptr == pstb_clog->base.base + 512, "wrong put end, expected %p got %p\n",
8367 pstb_clog->base.base + 512, pstb_clog->base.epptr);
8369 p_cin->count = 0xabababab;
8370 p_ios_sync_with_stdio();
8371 ok(*p_ios_sunk_with_stdio == 1, "expected 1 got %d\n", *p_ios_sunk_with_stdio);
8372 ok(p_cin->count == 0xabababab, "expected %d got %d\n", 0xabababab, p_cin->count);
8373 p_ios_sync_with_stdio();
8374 ok(*p_ios_sunk_with_stdio == 1, "expected 1 got %d\n", *p_ios_sunk_with_stdio);
8375 ok(p_cin->count == 0xabababab, "expected %d got %d\n", 0xabababab, p_cin->count);
8378 static void test_fstream(void)
8380 const char *filename = "fstream_test";
8381 iostream fs, fs_copy, *pfs;
8382 char buffer[64];
8383 streambuf *psb;
8384 filebuf *pfb;
8385 ostream *pos;
8386 istream *pis;
8387 char st[8];
8388 int i, ret, fd;
8390 memset(&fs, 0xab, sizeof(iostream));
8392 /* constructors/destructors */
8393 pfs = call_func2(p_fstream_ctor, &fs, TRUE);
8394 pfb = (filebuf*) fs.base_ios.sb;
8395 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8396 ok(fs.base1.extract_delim == 0, "expected 0 got %d\n", fs.base1.extract_delim);
8397 ok(fs.base1.count == 0, "expected 0 got %d\n", fs.base1.count);
8398 ok(fs.base2.unknown == 0, "expected 0 got %d\n", fs.base2.unknown);
8399 ok(fs.base_ios.sb != NULL, "expected not %p got %p\n", NULL, fs.base_ios.sb);
8400 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8401 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8402 ok(fs.base_ios.tie == NULL, "expected %p got %p\n", NULL, fs.base_ios.tie);
8403 ok(fs.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, fs.base_ios.flags);
8404 ok(fs.base_ios.precision == 6, "expected 6 got %d\n", fs.base_ios.precision);
8405 ok(fs.base_ios.fill == ' ', "expected 32 got %d\n", fs.base_ios.fill);
8406 ok(fs.base_ios.width == 0, "expected 0 got %d\n", fs.base_ios.width);
8407 ok(fs.base_ios.do_lock == -1, "expected -1 got %d\n", fs.base_ios.do_lock);
8408 ok(pfb->fd == -1, "wrong fd, expected -1 got %d\n", pfb->fd);
8409 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
8410 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
8411 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
8412 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
8413 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
8414 ok(pfb->fd == -1, "wrong fd, expected 0 got %d\n", pfb->fd);
8415 call_func1(p_fstream_vbase_dtor, &fs);
8417 pfs = call_func3(p_fstream_fd_ctor, &fs, 42, TRUE);
8418 pfb = (filebuf*) fs.base_ios.sb;
8419 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8420 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8421 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8422 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
8423 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
8424 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
8425 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
8426 ok(pfb->fd == 42, "wrong fd, expected 42 got %d\n", pfb->fd);
8427 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
8429 pfs = call_func3(p_fstream_copy_ctor, &fs_copy, &fs, TRUE);
8430 pfb = (filebuf*) fs_copy.base_ios.sb;
8431 ok(pfs == &fs_copy, "wrong return, expected %p got %p\n", &fs_copy, pfs);
8432 ok(fs_copy.base_ios.sb == fs.base_ios.sb, "expected shared streambuf\n");
8433 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8434 ok(fs_copy.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs_copy.base_ios.state);
8436 call_func1(p_fstream_vbase_dtor, &fs_copy);
8437 call_func1(p_fstream_dtor, &fs.base_ios);
8439 pfs = call_func5(p_fstream_buffer_ctor, &fs, 53, buffer, ARRAY_SIZE(buffer), TRUE);
8440 pfb = (filebuf*) fs.base_ios.sb;
8441 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8442 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8443 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8444 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
8445 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
8446 ok(pfb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pfb->base.base);
8447 ok(pfb->base.ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), pfb->base.ebuf);
8448 ok(pfb->fd == 53, "wrong fd, expected 53 got %d\n", pfb->fd);
8449 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
8450 call_func1(p_fstream_dtor, &fs.base_ios);
8452 pfs = call_func5(p_fstream_buffer_ctor, &fs, 64, NULL, 0, TRUE);
8453 pfb = (filebuf*) fs.base_ios.sb;
8454 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8455 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8456 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8457 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8458 ok(pfb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pfb->base.allocated);
8459 ok(pfb->base.unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", pfb->base.unbuffered);
8460 ok(pfb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pfb->base.base);
8461 ok(pfb->base.ebuf == NULL, "wrong ebuf, expected %p got %p\n", NULL, pfb->base.ebuf);
8462 ok(pfb->fd == 64, "wrong fd, expected 64 got %d\n", pfb->fd);
8463 ok(pfb->close == 0, "wrong value, expected 0 got %d\n", pfb->close);
8464 call_func1(p_fstream_vbase_dtor, &fs);
8466 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_out, filebuf_openprot, TRUE);
8467 pfb = (filebuf*) fs.base_ios.sb;
8468 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8469 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8470 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8471 ok(pfb->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pfb->base.allocated);
8472 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
8473 ok(pfb->base.base != NULL, "wrong buffer, expected not %p got %p\n", NULL, pfb->base.base);
8474 ok(pfb->base.ebuf != NULL, "wrong ebuf, expected not %p got %p\n", NULL, pfb->base.ebuf);
8475 ok(pfb->fd != -1, "wrong fd, expected not -1 got %d\n", pfb->fd);
8476 fd = pfb->fd;
8477 ok(pfb->close == 1, "wrong value, expected 1 got %d\n", pfb->close);
8478 call_func1(p_fstream_vbase_dtor, &fs);
8479 ok(_close(fd) == -1, "expected fstream to close opened file\n");
8480 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8482 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_in, filebuf_openprot, TRUE);
8483 pfb = (filebuf*) fs.base_ios.sb;
8484 ok(fs.base_ios.delbuf == 1, "expected 1 got %d\n", fs.base_ios.delbuf);
8485 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8486 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8487 ok(pfb->base.allocated == 1, "wrong allocate value, expected 1 got %d\n", pfb->base.allocated);
8488 ok(pfb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pfb->base.unbuffered);
8489 ok(pfb->base.base != NULL, "wrong buffer, expected not %p got %p\n", NULL, pfb->base.base);
8490 ok(pfb->base.ebuf != NULL, "wrong ebuf, expected not %p got %p\n", NULL, pfb->base.ebuf);
8491 ok(pfb->fd != -1, "wrong fd, expected not -1 got %d\n", pfb->fd);
8492 fd = pfb->fd;
8493 ok(pfb->close == 1, "wrong value, expected 1 got %d\n", pfb->close);
8494 call_func1(p_fstream_vbase_dtor, &fs);
8495 ok(_close(fd) == -1, "expected fstream to close opened file\n");
8496 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8498 /* setbuf */
8499 call_func5(p_fstream_buffer_ctor, &fs, -1, NULL, 0, TRUE);
8500 ok(fs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8501 ok(fs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8502 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8503 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8505 psb = call_func3(p_fstream_setbuf, &fs, buffer, ARRAY_SIZE(buffer));
8506 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8507 ok(fs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, fs.base_ios.sb->base);
8508 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8509 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8510 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8511 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8513 psb = call_func3(p_fstream_setbuf, &fs, NULL, 0);
8514 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8515 ok(fs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, fs.base_ios.sb->base);
8516 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8517 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8518 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8519 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8520 call_func1(p_fstream_vbase_dtor, &fs);
8522 call_func2(p_fstream_ctor, &fs, TRUE);
8523 ok(fs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8524 ok(fs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8525 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8526 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8527 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8529 psb = call_func3(p_fstream_setbuf, &fs, buffer, ARRAY_SIZE(buffer));
8530 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8531 ok(fs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, fs.base_ios.sb->base);
8532 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8533 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8534 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8535 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8537 psb = call_func3(p_fstream_setbuf, &fs, NULL, 0);
8538 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8539 ok(fs.base_ios.sb->base == buffer, "wrong buffer, expected %p got %p\n", buffer, fs.base_ios.sb->base);
8540 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8541 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8542 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8543 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8545 psb = call_func3(p_fstream_setbuf, &fs, buffer + 8, ARRAY_SIZE(buffer) - 8);
8546 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8547 ok(fs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, fs.base_ios.sb->base);
8548 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8549 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8550 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8551 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8553 psb = call_func3(p_fstream_setbuf, &fs, buffer + 8, 0);
8554 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8555 ok(fs.base_ios.sb->base == buffer + 8, "wrong buffer, expected %p got %p\n", buffer + 8, fs.base_ios.sb->base);
8556 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8557 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8558 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8559 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8561 psb = call_func3(p_fstream_setbuf, &fs, buffer + 4, ARRAY_SIZE(buffer) - 4);
8562 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8563 ok(fs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, fs.base_ios.sb->base);
8564 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8565 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8566 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8567 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8569 psb = call_func3(p_fstream_setbuf, &fs, NULL, 5);
8570 ok(psb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, psb);
8571 ok(fs.base_ios.sb->base == buffer + 4, "wrong buffer, expected %p got %p\n", buffer + 4, fs.base_ios.sb->base);
8572 ok(fs.base_ios.sb->ebuf == buffer + ARRAY_SIZE(buffer), "wrong ebuf, expected %p got %p\n", buffer + ARRAY_SIZE(buffer), fs.base_ios.sb->ebuf);
8573 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8574 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8575 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8576 call_func1(p_fstream_vbase_dtor, &fs);
8578 /* setbuf - seems to be a nop and always return NULL in those other cases */
8579 pfs = call_func5(p_fstream_buffer_ctor, &fs, 42, NULL, 0, TRUE);
8580 ok(fs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8581 ok(fs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8582 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8583 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8585 fs.base_ios.state = IOSTATE_eofbit;
8586 psb = call_func3(p_fstream_setbuf, &fs, buffer, ARRAY_SIZE(buffer));
8587 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8588 ok(fs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8589 ok(fs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8590 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8591 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8592 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8594 fs.base_ios.state = IOSTATE_eofbit;
8595 psb = call_func3(p_fstream_setbuf, &fs, NULL, 0);
8596 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8597 ok(fs.base_ios.sb->base == NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8598 ok(fs.base_ios.sb->ebuf == NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8599 ok(fs.base_ios.sb->unbuffered == 1, "wrong unbuffered value, expected 1 got %d\n", fs.base_ios.sb->unbuffered);
8600 ok(fs.base_ios.sb->allocated == 0, "wrong allocated value, expected 0 got %d\n", fs.base_ios.sb->allocated);
8601 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8602 call_func1(p_fstream_vbase_dtor, &fs);
8604 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_out, filebuf_openprot, TRUE);
8605 fs.base_ios.state = IOSTATE_eofbit;
8606 psb = call_func3(p_fstream_setbuf, &fs, NULL, 0);
8607 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8608 ok(fs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8609 ok(fs.base_ios.sb->ebuf != NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8610 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8611 ok(fs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", fs.base_ios.sb->allocated);
8612 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8614 fs.base_ios.state = IOSTATE_eofbit;
8615 psb = call_func3(p_fstream_setbuf, &fs, buffer, ARRAY_SIZE(buffer));
8616 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8617 ok(fs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8618 ok(fs.base_ios.sb->base != buffer, "wrong base value, expected not %p got %p\n", buffer, fs.base_ios.sb->base);
8619 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8620 ok(fs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", fs.base_ios.sb->allocated);
8621 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8622 call_func1(p_fstream_vbase_dtor, &fs);
8623 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8625 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_in, filebuf_openprot, TRUE);
8626 fs.base_ios.state = IOSTATE_eofbit;
8627 psb = call_func3(p_fstream_setbuf, &fs, NULL, 0);
8628 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8629 ok(fs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8630 ok(fs.base_ios.sb->ebuf != NULL, "wrong ebuf value, expected NULL got %p\n", fs.base_ios.sb->ebuf);
8631 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8632 ok(fs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", fs.base_ios.sb->allocated);
8633 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8635 fs.base_ios.state = IOSTATE_eofbit;
8636 psb = call_func3(p_fstream_setbuf, &fs, buffer, ARRAY_SIZE(buffer));
8637 ok(psb == NULL, "wrong return, expected NULL got %p\n", psb);
8638 ok(fs.base_ios.sb->base != NULL, "wrong base value, expected NULL got %p\n", fs.base_ios.sb->base);
8639 ok(fs.base_ios.sb->base != buffer, "wrong base value, expected not %p got %p\n", buffer, fs.base_ios.sb->base);
8640 ok(fs.base_ios.sb->unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", fs.base_ios.sb->unbuffered);
8641 ok(fs.base_ios.sb->allocated == 1, "wrong allocated value, expected 1 got %d\n", fs.base_ios.sb->allocated);
8642 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8643 call_func1(p_fstream_vbase_dtor, &fs);
8644 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8646 /* attach */
8647 pfs = call_func2(p_fstream_ctor, &fs, TRUE);
8648 pfb = (filebuf*) fs.base_ios.sb;
8649 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8650 call_func2(p_fstream_attach, &fs, 42);
8651 ok(fs.base_ios.state == IOSTATE_goodbit, "attaching on vanilla stream set some state bits\n");
8652 fd = (int) call_func1(p_fstream_fd, &fs);
8653 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
8654 ok(pfb->close == 0, "wrong close value, expected 0 got %d\n", pfb->close);
8655 fs.base_ios.state = IOSTATE_eofbit;
8656 call_func2(p_fstream_attach, &fs, 53);
8657 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "attaching on already setup stream did not set failbit\n");
8658 ok(fd == 42, "wrong fd, expected 42 got %d\n", fd);
8659 call_func1(p_fstream_vbase_dtor, &fs);
8661 /* fd */
8662 pfs = call_func2(p_fstream_ctor, &fs, TRUE);
8663 pfb = (filebuf*) fs.base_ios.sb;
8664 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8665 fd = (int) call_func1(p_fstream_fd, &fs);
8666 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8667 ok(fd == -1, "wrong fd, expected -1 but got %d\n", fd);
8668 call_func1(p_fstream_vbase_dtor, &fs);
8670 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_in, filebuf_openprot, TRUE);
8671 pfb = (filebuf*) fs.base_ios.sb;
8672 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8673 fd = (int) call_func1(p_fstream_fd, &fs);
8674 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8675 ok(fd == pfb->fd, "wrong fd, expected %d but got %d\n", pfb->fd, fd);
8676 call_func1(p_fstream_vbase_dtor, &fs);
8677 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8679 pfs = call_func2(p_fstream_ctor, &fs, TRUE);
8680 pfb = (filebuf*) fs.base_ios.sb;
8681 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8682 fd = (int) call_func1(p_fstream_fd, &fs);
8683 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8684 ok(fd == -1, "wrong fd, expected -1 but got %d\n", fd);
8685 call_func1(p_fstream_vbase_dtor, &fs);
8687 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_out, filebuf_openprot, TRUE);
8688 pfb = (filebuf*) fs.base_ios.sb;
8689 ok(pfs == &fs, "wrong return, expected %p got %p\n", &fs, pfs);
8690 fd = (int) call_func1(p_fstream_fd, &fs);
8691 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8692 ok(fd == pfb->fd, "wrong fd, expected %d but got %d\n", pfb->fd, fd);
8694 /* rdbuf */
8695 pfb = (filebuf*) call_func1(p_fstream_rdbuf, &fs);
8696 ok((streambuf*) pfb == fs.base_ios.sb, "wrong return, expected %p got %p\n", fs.base_ios.sb, pfb);
8697 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8699 /* setmode */
8700 ret = (int) call_func2(p_fstream_setmode, &fs, filebuf_binary);
8701 ok(ret == filebuf_text, "wrong return, expected %d got %d\n", filebuf_text, ret);
8702 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8703 ret = (int) call_func2(p_fstream_setmode, &fs, filebuf_binary);
8704 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
8705 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8706 ret = (int) call_func2(p_fstream_setmode, &fs, filebuf_text);
8707 ok(ret == filebuf_binary, "wrong return, expected %d got %d\n", filebuf_binary, ret);
8708 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8709 ret = (int) call_func2(p_fstream_setmode, &fs, 0x9000);
8710 ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
8711 ok(fs.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8713 /* close && is_open */
8714 ok((int) call_func1(p_fstream_is_open, &fs) == 1, "expected fstream to be open\n");
8715 fs.base_ios.state = IOSTATE_eofbit | IOSTATE_failbit;
8716 call_func1(p_fstream_close, &fs);
8717 ok(fs.base_ios.state == IOSTATE_goodbit, "close did not clear state = %d\n", fs.base_ios.state);
8718 fs.base_ios.state = IOSTATE_eofbit;
8719 call_func1(p_fstream_close, &fs);
8720 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "close on a closed stream did not set failbit\n");
8721 ok((int) call_func1(p_fstream_is_open, &fs) == 0, "expected fstream to not be open\n");
8722 ok(_close(fd) == -1, "expected close to close the opened file\n");
8724 /* open */
8725 fs.base_ios.state = IOSTATE_eofbit;
8726 call_func4(p_fstream_open, &fs, filename, OPENMODE_out, filebuf_openprot);
8727 fd = (int) call_func1(p_fstream_fd, &fs);
8728 ok(fd != -1, "wrong fd, expected not -1 got %d\n", fd);
8729 ok(fs.base_ios.state == IOSTATE_eofbit, "open did not succeed\n");
8730 call_func4(p_fstream_open, &fs, filename, OPENMODE_out, filebuf_openprot);
8731 ok(fs.base_ios.state == (IOSTATE_eofbit | IOSTATE_failbit), "second open did not set failbit\n");
8732 call_func1(p_fstream_close, &fs);
8733 call_func1(p_fstream_vbase_dtor, &fs);
8734 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s'\n", filename);
8736 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_out, filebuf_openprot, TRUE);
8737 ok(pfs == &fs, "constructor returned wrong pointer, expected %p got %p\n", &fs, pfs);
8738 ok(fs.base_ios.state == IOSTATE_goodbit, "wrong stream state, expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8739 pfb = (filebuf*) fs.base_ios.sb;
8740 ok((int) call_func1(p_filebuf_is_open, pfb) == TRUE, "expected filebuf to be open\n");
8741 ok(fs.base_ios.delbuf == 1, "internal filebuf not marked for deletion\n");
8743 /* integration with ostream */
8744 pos = call_func2(p_ostream_print_str, (ostream*) &fs.base2, "ftest ");
8745 ok(pos == (ostream*) &fs.base2, "stream operation returned wrong pointer, expected %p got %p\n", &fs, &fs.base2);
8746 pos = call_func2(p_ostream_print_int, (ostream*) &fs.base2, 15);
8747 ok(pos == (ostream*) &fs.base2, "stream operation returned wrong pointer, expected %p got %p\n", &fs, &fs.base2);
8749 /* make sure that OPENMODE_in is not implied */
8750 ok(_lseek(pfb->fd, 0, SEEK_SET) == 0, "_lseek failed\n");
8751 ok(_read(pfb->fd, st, 1) == -1, "_read succeeded on OPENMODE_out only fstream\n");
8753 /* reopen the file for reading */
8754 call_func1(p_fstream_vbase_dtor, &fs);
8755 pfs = call_func5(p_fstream_open_ctor, &fs, filename, OPENMODE_in, filebuf_openprot, TRUE);
8756 ok(pfs == &fs, "constructor returned wrong pointer, expected %p got %p\n", &fs, pfs);
8757 ok(fs.base_ios.state == IOSTATE_goodbit, "wrong stream state, expected %d got %d\n", IOSTATE_goodbit, fs.base_ios.state);
8758 pfb = (filebuf*) fs.base_ios.sb;
8759 ok((int) call_func1(p_filebuf_is_open, pfb) == TRUE, "expected filebuf to be open\n");
8761 /* integration with istream */
8762 memset(st, 'A', sizeof(st));
8763 pis = call_func2(p_istream_read_str, (istream*) &fs.base1, st);
8764 ok(pis == (istream*) &fs.base1, "stream operation returned wrong pointer, expected %p got %p\n", &fs, &fs.base1);
8765 st[7] = 0;
8766 ok(!strcmp(st, "ftest"), "expected 'ftest' got '%s'\n", st);
8768 i = 12345;
8769 pis = call_func2(p_istream_read_int, (istream*) &fs.base1, &i);
8770 ok(pis == (istream*) &fs.base1, "stream operation returned wrong pointer, expected %p got %p\n", &fs, &fs.base1);
8771 ok(i == 15, "expected 12 got %d\n", i);
8773 /* make sure that OPENMODE_out is not implied */
8774 ok(_lseek(pfb->fd, 0, SEEK_SET) == 0, "_lseek failed\n");
8775 ok(_write(pfb->fd, "blabla", 6) == -1, "_write succeeded on OPENMODE_in fstream\n");
8777 /* cleanup */
8778 call_func1(p_fstream_vbase_dtor, &fs);
8779 ok(_unlink(filename) == 0, "Couldn't unlink file named '%s', some filedescs are still open?\n", filename);
8782 static void test_exception(void)
8784 const char *unknown = "Unknown exception";
8785 const char *test = "test";
8786 const char *what;
8787 logic_error le;
8788 exception e;
8790 /* exception */
8791 memset(&e, 0, sizeof(e));
8792 what = call_func1(p_exception_what, (void*) &e);
8793 ok(!strcmp(what, unknown), "expected %s got %s\n", unknown, what);
8795 call_func2(p_exception_ctor, (void*) &e, &test);
8796 what = call_func1(p_exception_what, (void*) &e);
8797 ok(!strcmp(what, test), "expected %s got %s\n", test, what);
8798 call_func1(p_exception_dtor, (void*) &e);
8800 /* logic_error */
8801 memset(&le, 0xff, sizeof(le));
8802 call_func2(p_logic_error_ctor, (void*) &le, &test);
8803 ok(!strcmp(le.e.name, test), "expected %s got %s\n", test, le.e.name);
8804 ok(le.e.do_free, "expected TRUE, got FALSE\n");
8805 what = call_func1(p_exception_what, (void*) &le.e);
8806 ok(!strcmp(what, test), "expected %s got %s\n", test, what);
8807 call_func1(p_logic_error_dtor, (void*) &le);
8810 static DWORD WINAPI _try_enter_critical(void *crit)
8812 BOOL ret = TryEnterCriticalSection(crit);
8814 if (ret)
8815 LeaveCriticalSection(crit);
8817 return ret;
8820 static void test_mtlock_mtunlock(void)
8822 CRITICAL_SECTION crit;
8823 HANDLE thread;
8824 DWORD exit_code, ret;
8826 InitializeCriticalSection(&crit);
8828 p__mtlock(&crit);
8830 thread = CreateThread(NULL, 0, _try_enter_critical, &crit, 0, NULL);
8831 ok(thread != NULL, "failed to create a thread, error: %lx\n", GetLastError());
8832 ret = WaitForSingleObject(thread, 1000);
8833 ok(ret == WAIT_OBJECT_0, "failed to wait for the thread, ret: %ld, error: %lx\n", ret, GetLastError());
8834 ok(GetExitCodeThread(thread, &exit_code), "failed to get exit code of the thread\n");
8835 ok(exit_code == FALSE, "the thread entered critical section\n");
8836 ret = CloseHandle(thread);
8837 ok(ret, "failed to close thread's handle, error: %lx\n", GetLastError());
8839 p__mtunlock(&crit);
8841 thread = CreateThread(NULL, 0, _try_enter_critical, &crit, 0, NULL);
8842 ok(thread != NULL, "failed to create a thread, error: %lx\n", GetLastError());
8843 ret = WaitForSingleObject(thread, 1000);
8844 ok(ret == WAIT_OBJECT_0, "failed to wait for the thread, ret: %ld, error: %lx\n", ret, GetLastError());
8845 ok(GetExitCodeThread(thread, &exit_code), "failed to get exit code of the thread\n");
8846 ok(exit_code == TRUE, "the thread was not able to enter critical section\n");
8847 ret = CloseHandle(thread);
8848 ok(ret, "failed to close thread's handle, error: %lx\n", GetLastError());
8851 START_TEST(msvcirt)
8853 if(!init())
8854 return;
8856 test_streambuf();
8857 test_filebuf();
8858 test_strstreambuf();
8859 test_stdiobuf();
8860 test_ios();
8861 test_ostream();
8862 test_ostream_print();
8863 test_ostream_withassign();
8864 test_ostrstream();
8865 test_ofstream();
8866 test_istream();
8867 test_istream_getint();
8868 test_istream_getdouble();
8869 test_istream_read();
8870 test_istream_withassign();
8871 test_istrstream();
8872 test_iostream();
8873 test_ifstream();
8874 test_strstream();
8875 test_stdiostream();
8876 test_Iostream_init();
8877 test_std_streams();
8878 test_fstream();
8879 test_exception();
8880 test_mtlock_mtunlock();
8882 FreeLibrary(msvcrt);
8883 FreeLibrary(msvcirt);