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
25 #include "wine/test.h"
27 typedef void (*vtable_ptr
)(void);
28 typedef LONG streamoff
;
29 typedef LONG streampos
;
31 typedef void* (__cdecl
*allocFunction
)(LONG
);
32 typedef void (__cdecl
*freeFunction
)(void*);
35 IOSTATE_goodbit
= 0x0,
37 IOSTATE_failbit
= 0x2,
46 OPENMODE_trunc
= 0x10,
47 OPENMODE_nocreate
= 0x20,
48 OPENMODE_noreplace
= 0x40,
49 OPENMODE_binary
= 0x80
66 FLAGS_showbase
= 0x80,
67 FLAGS_showpoint
= 0x100,
68 FLAGS_uppercase
= 0x200,
69 FLAGS_showpos
= 0x400,
70 FLAGS_scientific
= 0x800,
72 FLAGS_unitbuf
= 0x2000,
76 const int filebuf_sh_none
= 0x800;
77 const int filebuf_sh_read
= 0xa00;
78 const int filebuf_sh_write
= 0xc00;
79 const int filebuf_openprot
= 420;
80 const int filebuf_binary
= _O_BINARY
;
81 const int filebuf_text
= _O_TEXT
;
85 const vtable_ptr
*vtable
;
98 CRITICAL_SECTION lock
;
108 /* class strstreambuf */
115 allocFunction f_alloc
;
128 const vtable_ptr
*vtable
;
133 struct _ostream
*tie
;
139 CRITICAL_SECTION lock
;
143 typedef struct _ostream
{
146 ios base_ios
; /* virtually inherited */
154 ios base_ios
; /* virtually inherited */
157 static inline float __port_infinity(void)
159 static const unsigned __inf_bytes
= 0x7f800000;
160 return *(const float *)&__inf_bytes
;
162 #define INFINITY __port_infinity()
164 static inline float __port_nan(void)
166 static const unsigned __nan_bytes
= 0x7fc00000;
167 return *(const float *)&__nan_bytes
;
169 #define NAN __port_nan()
173 #define __thiscall __stdcall
175 #define __thiscall __cdecl
178 static void* (__cdecl
*p_operator_new
)(unsigned int);
179 static void (__cdecl
*p_operator_delete
)(void*);
182 static streambuf
* (*__thiscall p_streambuf_reserve_ctor
)(streambuf
*, char*, int);
183 static streambuf
* (*__thiscall p_streambuf_ctor
)(streambuf
*);
184 static void (*__thiscall p_streambuf_dtor
)(streambuf
*);
185 static int (*__thiscall p_streambuf_allocate
)(streambuf
*);
186 static void (*__thiscall p_streambuf_clrclock
)(streambuf
*);
187 static int (*__thiscall p_streambuf_doallocate
)(streambuf
*);
188 static void (*__thiscall p_streambuf_gbump
)(streambuf
*, int);
189 static void (*__thiscall p_streambuf_lock
)(streambuf
*);
190 static int (*__thiscall p_streambuf_pbackfail
)(streambuf
*, int);
191 static void (*__thiscall p_streambuf_pbump
)(streambuf
*, int);
192 static int (*__thiscall p_streambuf_sbumpc
)(streambuf
*);
193 static void (*__thiscall p_streambuf_setb
)(streambuf
*, char*, char*, int);
194 static void (*__thiscall p_streambuf_setlock
)(streambuf
*);
195 static streambuf
* (*__thiscall p_streambuf_setbuf
)(streambuf
*, char*, int);
196 static int (*__thiscall p_streambuf_sgetc
)(streambuf
*);
197 static int (*__thiscall p_streambuf_snextc
)(streambuf
*);
198 static int (*__thiscall p_streambuf_sputc
)(streambuf
*, int);
199 static void (*__thiscall p_streambuf_stossc
)(streambuf
*);
200 static int (*__thiscall p_streambuf_sync
)(streambuf
*);
201 static void (*__thiscall p_streambuf_unlock
)(streambuf
*);
202 static int (*__thiscall p_streambuf_xsgetn
)(streambuf
*, char*, int);
203 static int (*__thiscall p_streambuf_xsputn
)(streambuf
*, const char*, int);
206 static filebuf
* (*__thiscall p_filebuf_fd_ctor
)(filebuf
*, int);
207 static filebuf
* (*__thiscall p_filebuf_fd_reserve_ctor
)(filebuf
*, int, char*, int);
208 static filebuf
* (*__thiscall p_filebuf_ctor
)(filebuf
*);
209 static void (*__thiscall p_filebuf_dtor
)(filebuf
*);
210 static filebuf
* (*__thiscall p_filebuf_attach
)(filebuf
*, filedesc
);
211 static filebuf
* (*__thiscall p_filebuf_open
)(filebuf
*, const char*, ios_open_mode
, int);
212 static filebuf
* (*__thiscall p_filebuf_close
)(filebuf
*);
213 static int (*__thiscall p_filebuf_setmode
)(filebuf
*, int);
214 static streambuf
* (*__thiscall p_filebuf_setbuf
)(filebuf
*, char*, int);
215 static int (*__thiscall p_filebuf_sync
)(filebuf
*);
216 static int (*__thiscall p_filebuf_overflow
)(filebuf
*, int);
217 static int (*__thiscall p_filebuf_underflow
)(filebuf
*);
218 static streampos (*__thiscall p_filebuf_seekoff
)(filebuf
*, streamoff
, ios_seek_dir
, int);
221 static strstreambuf
* (*__thiscall p_strstreambuf_dynamic_ctor
)(strstreambuf
*, int);
222 static strstreambuf
* (*__thiscall p_strstreambuf_funcs_ctor
)(strstreambuf
*, allocFunction
, freeFunction
);
223 static strstreambuf
* (*__thiscall p_strstreambuf_buffer_ctor
)(strstreambuf
*, char*, int, char*);
224 static strstreambuf
* (*__thiscall p_strstreambuf_ubuffer_ctor
)(strstreambuf
*, unsigned char*, int, unsigned char*);
225 static strstreambuf
* (*__thiscall p_strstreambuf_ctor
)(strstreambuf
*);
226 static void (*__thiscall p_strstreambuf_dtor
)(strstreambuf
*);
227 static int (*__thiscall p_strstreambuf_doallocate
)(strstreambuf
*);
228 static void (*__thiscall p_strstreambuf_freeze
)(strstreambuf
*, int);
229 static int (*__thiscall p_strstreambuf_overflow
)(strstreambuf
*, int);
230 static streampos (*__thiscall p_strstreambuf_seekoff
)(strstreambuf
*, streamoff
, ios_seek_dir
, int);
231 static streambuf
* (*__thiscall p_strstreambuf_setbuf
)(strstreambuf
*, char*, int);
232 static int (*__thiscall p_strstreambuf_underflow
)(strstreambuf
*);
235 static stdiobuf
* (*__thiscall p_stdiobuf_file_ctor
)(stdiobuf
*, FILE*);
236 static void (*__thiscall p_stdiobuf_dtor
)(stdiobuf
*);
237 static int (*__thiscall p_stdiobuf_overflow
)(stdiobuf
*, int);
238 static int (*__thiscall p_stdiobuf_pbackfail
)(stdiobuf
*, int);
239 static streampos (*__thiscall p_stdiobuf_seekoff
)(stdiobuf
*, streamoff
, ios_seek_dir
, int);
240 static int (*__thiscall p_stdiobuf_setrwbuf
)(stdiobuf
*, int, int);
241 static int (*__thiscall p_stdiobuf_sync
)(stdiobuf
*);
242 static int (*__thiscall p_stdiobuf_underflow
)(stdiobuf
*);
245 static ios
* (*__thiscall p_ios_copy_ctor
)(ios
*, const ios
*);
246 static ios
* (*__thiscall p_ios_ctor
)(ios
*);
247 static ios
* (*__thiscall p_ios_sb_ctor
)(ios
*, streambuf
*);
248 static ios
* (*__thiscall p_ios_assign
)(ios
*, const ios
*);
249 static void (*__thiscall p_ios_init
)(ios
*, streambuf
*);
250 static void (*__thiscall p_ios_dtor
)(ios
*);
251 static void (*__cdecl p_ios_clrlock
)(ios
*);
252 static void (*__cdecl p_ios_setlock
)(ios
*);
253 static void (*__cdecl p_ios_lock
)(ios
*);
254 static void (*__cdecl p_ios_unlock
)(ios
*);
255 static void (*__cdecl p_ios_lockbuf
)(ios
*);
256 static void (*__cdecl p_ios_unlockbuf
)(ios
*);
257 static CRITICAL_SECTION
*p_ios_static_lock
;
258 static void (*__cdecl p_ios_lockc
)(void);
259 static void (*__cdecl p_ios_unlockc
)(void);
260 static LONG (*__thiscall p_ios_flags_set
)(ios
*, LONG
);
261 static LONG (*__thiscall p_ios_flags_get
)(const ios
*);
262 static LONG (*__thiscall p_ios_setf
)(ios
*, LONG
);
263 static LONG (*__thiscall p_ios_setf_mask
)(ios
*, LONG
, LONG
);
264 static LONG (*__thiscall p_ios_unsetf
)(ios
*, LONG
);
265 static int (*__thiscall p_ios_good
)(const ios
*);
266 static int (*__thiscall p_ios_bad
)(const ios
*);
267 static int (*__thiscall p_ios_eof
)(const ios
*);
268 static int (*__thiscall p_ios_fail
)(const ios
*);
269 static void (*__thiscall p_ios_clear
)(ios
*, int);
270 static LONG
*p_ios_maxbit
;
271 static LONG (*__cdecl p_ios_bitalloc
)(void);
272 static int *p_ios_curindex
;
273 static LONG
*p_ios_statebuf
;
274 static LONG
* (*__thiscall p_ios_iword
)(const ios
*, int);
275 static void** (*__thiscall p_ios_pword
)(const ios
*, int);
276 static int (*__cdecl p_ios_xalloc
)(void);
277 static int *p_ios_fLockcInit
;
280 static ostream
* (*__thiscall p_ostream_copy_ctor
)(ostream
*, const ostream
*, BOOL
);
281 static ostream
* (*__thiscall p_ostream_sb_ctor
)(ostream
*, streambuf
*, BOOL
);
282 static ostream
* (*__thiscall p_ostream_ctor
)(ostream
*, BOOL
);
283 static void (*__thiscall p_ostream_dtor
)(ios
*);
284 static ostream
* (*__thiscall p_ostream_assign
)(ostream
*, const ostream
*);
285 static ostream
* (*__thiscall p_ostream_assign_sb
)(ostream
*, streambuf
*);
286 static void (*__thiscall p_ostream_vbase_dtor
)(ostream
*);
287 static ostream
* (*__thiscall p_ostream_flush
)(ostream
*);
288 static int (*__thiscall p_ostream_opfx
)(ostream
*);
289 static void (*__thiscall p_ostream_osfx
)(ostream
*);
290 static ostream
* (*__thiscall p_ostream_put_char
)(ostream
*, char);
291 static ostream
* (*__thiscall p_ostream_write_char
)(ostream
*, const char*, int);
292 static ostream
* (*__thiscall p_ostream_seekp_offset
)(ostream
*, streamoff
, ios_seek_dir
);
293 static ostream
* (*__thiscall p_ostream_seekp
)(ostream
*, streampos
);
294 static streampos (*__thiscall p_ostream_tellp
)(ostream
*);
295 static ostream
* (*__thiscall p_ostream_writepad
)(ostream
*, const char*, const char*);
296 static ostream
* (*__thiscall p_ostream_print_char
)(ostream
*, char);
297 static ostream
* (*__thiscall p_ostream_print_str
)(ostream
*, const char*);
298 static ostream
* (*__thiscall p_ostream_print_int
)(ostream
*, int);
299 static ostream
* (*__thiscall p_ostream_print_float
)(ostream
*, float);
300 static ostream
* (*__thiscall p_ostream_print_double
)(ostream
*, double);
301 static ostream
* (*__thiscall p_ostream_print_ptr
)(ostream
*, const void*);
302 static ostream
* (*__thiscall p_ostream_print_streambuf
)(ostream
*, streambuf
*);
305 static istream
* (*__thiscall p_istream_copy_ctor
)(istream
*, const istream
*, BOOL
);
306 static istream
* (*__thiscall p_istream_ctor
)(istream
*, BOOL
);
307 static istream
* (*__thiscall p_istream_sb_ctor
)(istream
*, streambuf
*, BOOL
);
308 static void (*__thiscall p_istream_dtor
)(ios
*);
309 static istream
* (*__thiscall p_istream_assign_sb
)(istream
*, streambuf
*);
310 static istream
* (*__thiscall p_istream_assign
)(istream
*, const istream
*);
311 static void (*__thiscall p_istream_vbase_dtor
)(istream
*);
312 static void (*__thiscall p_istream_eatwhite
)(istream
*);
314 /* Emulate a __thiscall */
317 #include "pshpack1.h"
318 struct thiscall_thunk
320 BYTE pop_eax
; /* popl %eax (ret addr) */
321 BYTE pop_edx
; /* popl %edx (func) */
322 BYTE pop_ecx
; /* popl %ecx (this) */
323 BYTE push_eax
; /* pushl %eax */
324 WORD jmp_edx
; /* jmp *%edx */
328 static void * (WINAPI
*call_thiscall_func1
)( void *func
, void *this );
329 static void * (WINAPI
*call_thiscall_func2
)( void *func
, void *this, const void *a
);
330 static void * (WINAPI
*call_thiscall_func3
)( void *func
, void *this, const void *a
, const void *b
);
331 static void * (WINAPI
*call_thiscall_func4
)( void *func
, void *this, const void *a
, const void *b
,
333 static void * (WINAPI
*call_thiscall_func5
)( void *func
, void *this, const void *a
, const void *b
,
334 const void *c
, const void *d
);
335 static void * (WINAPI
*call_thiscall_func2_ptr_dbl
)( void *func
, void *this, double a
);
336 static void * (WINAPI
*call_thiscall_func2_ptr_flt
)( void *func
, void *this, float a
);
338 static void init_thiscall_thunk(void)
340 struct thiscall_thunk
*thunk
= VirtualAlloc( NULL
, sizeof(*thunk
),
341 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
342 thunk
->pop_eax
= 0x58; /* popl %eax */
343 thunk
->pop_edx
= 0x5a; /* popl %edx */
344 thunk
->pop_ecx
= 0x59; /* popl %ecx */
345 thunk
->push_eax
= 0x50; /* pushl %eax */
346 thunk
->jmp_edx
= 0xe2ff; /* jmp *%edx */
347 call_thiscall_func1
= (void *)thunk
;
348 call_thiscall_func2
= (void *)thunk
;
349 call_thiscall_func3
= (void *)thunk
;
350 call_thiscall_func4
= (void *)thunk
;
351 call_thiscall_func5
= (void *)thunk
;
352 call_thiscall_func2_ptr_dbl
= (void *)thunk
;
353 call_thiscall_func2_ptr_flt
= (void *)thunk
;
356 #define call_func1(func,_this) call_thiscall_func1(func,_this)
357 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
358 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
359 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
361 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
362 (const void*)(c), (const void *)(d))
363 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
364 #define call_func2_ptr_flt(func,_this,a) call_thiscall_func2_ptr_flt(func,_this,a)
368 #define init_thiscall_thunk()
369 #define call_func1(func,_this) func(_this)
370 #define call_func2(func,_this,a) func(_this,a)
371 #define call_func3(func,_this,a,b) func(_this,a,b)
372 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
373 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
374 #define call_func2_ptr_dbl call_func2
375 #define call_func2_ptr_flt call_func2
377 #endif /* __i386__ */
379 static HMODULE msvcrt
, msvcirt
;
380 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcirt,y)
381 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
382 static BOOL
init(void)
384 msvcrt
= LoadLibraryA("msvcrt.dll");
385 msvcirt
= LoadLibraryA("msvcirt.dll");
387 win_skip("msvcirt.dll not installed\n");
391 if(sizeof(void*) == 8) { /* 64-bit initialization */
392 p_operator_new
= (void*)GetProcAddress(msvcrt
, "??2@YAPEAX_K@Z");
393 p_operator_delete
= (void*)GetProcAddress(msvcrt
, "??3@YAXPEAX@Z");
395 SET(p_streambuf_reserve_ctor
, "??0streambuf@@IEAA@PEADH@Z");
396 SET(p_streambuf_ctor
, "??0streambuf@@IEAA@XZ");
397 SET(p_streambuf_dtor
, "??1streambuf@@UEAA@XZ");
398 SET(p_streambuf_allocate
, "?allocate@streambuf@@IEAAHXZ");
399 SET(p_streambuf_clrclock
, "?clrlock@streambuf@@QEAAXXZ");
400 SET(p_streambuf_doallocate
, "?doallocate@streambuf@@MEAAHXZ");
401 SET(p_streambuf_gbump
, "?gbump@streambuf@@IEAAXH@Z");
402 SET(p_streambuf_lock
, "?lock@streambuf@@QEAAXXZ");
403 SET(p_streambuf_pbackfail
, "?pbackfail@streambuf@@UEAAHH@Z");
404 SET(p_streambuf_pbump
, "?pbump@streambuf@@IEAAXH@Z");
405 SET(p_streambuf_sbumpc
, "?sbumpc@streambuf@@QEAAHXZ");
406 SET(p_streambuf_setb
, "?setb@streambuf@@IEAAXPEAD0H@Z");
407 SET(p_streambuf_setbuf
, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z");
408 SET(p_streambuf_setlock
, "?setlock@streambuf@@QEAAXXZ");
409 SET(p_streambuf_sgetc
, "?sgetc@streambuf@@QEAAHXZ");
410 SET(p_streambuf_snextc
, "?snextc@streambuf@@QEAAHXZ");
411 SET(p_streambuf_sputc
, "?sputc@streambuf@@QEAAHH@Z");
412 SET(p_streambuf_stossc
, "?stossc@streambuf@@QEAAXXZ");
413 SET(p_streambuf_sync
, "?sync@streambuf@@UEAAHXZ");
414 SET(p_streambuf_unlock
, "?unlock@streambuf@@QEAAXXZ");
415 SET(p_streambuf_xsgetn
, "?xsgetn@streambuf@@UEAAHPEADH@Z");
416 SET(p_streambuf_xsputn
, "?xsputn@streambuf@@UEAAHPEBDH@Z");
418 SET(p_filebuf_fd_ctor
, "??0filebuf@@QEAA@H@Z");
419 SET(p_filebuf_fd_reserve_ctor
, "??0filebuf@@QEAA@HPEADH@Z");
420 SET(p_filebuf_ctor
, "??0filebuf@@QEAA@XZ");
421 SET(p_filebuf_dtor
, "??1filebuf@@UEAA@XZ");
422 SET(p_filebuf_attach
, "?attach@filebuf@@QEAAPEAV1@H@Z");
423 SET(p_filebuf_open
, "?open@filebuf@@QEAAPEAV1@PEBDHH@Z");
424 SET(p_filebuf_close
, "?close@filebuf@@QEAAPEAV1@XZ");
425 SET(p_filebuf_setmode
, "?setmode@filebuf@@QEAAHH@Z");
426 SET(p_filebuf_setbuf
, "?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z");
427 SET(p_filebuf_sync
, "?sync@filebuf@@UEAAHXZ");
428 SET(p_filebuf_overflow
, "?overflow@filebuf@@UEAAHH@Z");
429 SET(p_filebuf_underflow
, "?underflow@filebuf@@UEAAHXZ");
430 SET(p_filebuf_seekoff
, "?seekoff@filebuf@@UEAAJJW4seek_dir@ios@@H@Z");
432 SET(p_strstreambuf_dynamic_ctor
, "??0strstreambuf@@QEAA@H@Z");
433 SET(p_strstreambuf_funcs_ctor
, "??0strstreambuf@@QEAA@P6APEAXJ@ZP6AXPEAX@Z@Z");
434 SET(p_strstreambuf_buffer_ctor
, "??0strstreambuf@@QEAA@PEADH0@Z");
435 SET(p_strstreambuf_ubuffer_ctor
, "??0strstreambuf@@QEAA@PEAEH0@Z");
436 SET(p_strstreambuf_ctor
, "??0strstreambuf@@QEAA@XZ");
437 SET(p_strstreambuf_dtor
, "??1strstreambuf@@UEAA@XZ");
438 SET(p_strstreambuf_doallocate
, "?doallocate@strstreambuf@@MEAAHXZ");
439 SET(p_strstreambuf_freeze
, "?freeze@strstreambuf@@QEAAXH@Z");
440 SET(p_strstreambuf_overflow
, "?overflow@strstreambuf@@UEAAHH@Z");
441 SET(p_strstreambuf_seekoff
, "?seekoff@strstreambuf@@UEAAJJW4seek_dir@ios@@H@Z");
442 SET(p_strstreambuf_setbuf
, "?setbuf@strstreambuf@@UEAAPEAVstreambuf@@PEADH@Z");
443 SET(p_strstreambuf_underflow
, "?underflow@strstreambuf@@UEAAHXZ");
445 SET(p_stdiobuf_file_ctor
, "??0stdiobuf@@QEAA@PEAU_iobuf@@@Z");
446 SET(p_stdiobuf_dtor
, "??1stdiobuf@@UEAA@XZ");
447 SET(p_stdiobuf_overflow
, "?overflow@stdiobuf@@UEAAHH@Z");
448 SET(p_stdiobuf_pbackfail
, "?pbackfail@stdiobuf@@UEAAHH@Z");
449 SET(p_stdiobuf_seekoff
, "?seekoff@stdiobuf@@UEAAJJW4seek_dir@ios@@H@Z");
450 SET(p_stdiobuf_setrwbuf
, "?setrwbuf@stdiobuf@@QEAAHHH@Z");
451 SET(p_stdiobuf_sync
, "?sync@stdiobuf@@UEAAHXZ");
452 SET(p_stdiobuf_underflow
, "?underflow@stdiobuf@@UEAAHXZ");
454 SET(p_ios_copy_ctor
, "??0ios@@IEAA@AEBV0@@Z");
455 SET(p_ios_ctor
, "??0ios@@IEAA@XZ");
456 SET(p_ios_sb_ctor
, "??0ios@@QEAA@PEAVstreambuf@@@Z");
457 SET(p_ios_assign
, "??4ios@@IEAAAEAV0@AEBV0@@Z");
458 SET(p_ios_init
, "?init@ios@@IEAAXPEAVstreambuf@@@Z");
459 SET(p_ios_dtor
, "??1ios@@UEAA@XZ");
460 SET(p_ios_clrlock
, "?clrlock@ios@@QEAAXXZ");
461 SET(p_ios_setlock
, "?setlock@ios@@QEAAXXZ");
462 SET(p_ios_lock
, "?lock@ios@@QEAAXXZ");
463 SET(p_ios_unlock
, "?unlock@ios@@QEAAXXZ");
464 SET(p_ios_lockbuf
, "?lockbuf@ios@@QEAAXXZ");
465 SET(p_ios_unlockbuf
, "?unlockbuf@ios@@QEAAXXZ");
466 SET(p_ios_flags_set
, "?flags@ios@@QEAAJJ@Z");
467 SET(p_ios_flags_get
, "?flags@ios@@QEBAJXZ");
468 SET(p_ios_setf
, "?setf@ios@@QEAAJJ@Z");
469 SET(p_ios_setf_mask
, "?setf@ios@@QEAAJJJ@Z");
470 SET(p_ios_unsetf
, "?unsetf@ios@@QEAAJJ@Z");
471 SET(p_ios_good
, "?good@ios@@QEBAHXZ");
472 SET(p_ios_bad
, "?bad@ios@@QEBAHXZ");
473 SET(p_ios_eof
, "?eof@ios@@QEBAHXZ");
474 SET(p_ios_fail
, "?fail@ios@@QEBAHXZ");
475 SET(p_ios_clear
, "?clear@ios@@QEAAXH@Z");
476 SET(p_ios_iword
, "?iword@ios@@QEBAAEAJH@Z");
477 SET(p_ios_pword
, "?pword@ios@@QEBAAEAPEAXH@Z");
479 SET(p_ostream_copy_ctor
, "??0ostream@@IEAA@AEBV0@@Z");
480 SET(p_ostream_sb_ctor
, "??0ostream@@QEAA@PEAVstreambuf@@@Z");
481 SET(p_ostream_ctor
, "??0ostream@@IEAA@XZ");
482 SET(p_ostream_dtor
, "??1ostream@@UEAA@XZ");
483 SET(p_ostream_assign
, "??4ostream@@IEAAAEAV0@AEBV0@@Z");
484 SET(p_ostream_assign_sb
, "??4ostream@@IEAAAEAV0@PEAVstreambuf@@@Z");
485 SET(p_ostream_vbase_dtor
, "??_Dostream@@QEAAXXZ");
486 SET(p_ostream_flush
, "?flush@ostream@@QEAAAEAV1@XZ");
487 SET(p_ostream_opfx
, "?opfx@ostream@@QEAAHXZ");
488 SET(p_ostream_osfx
, "?osfx@ostream@@QEAAXXZ");
489 SET(p_ostream_put_char
, "?put@ostream@@QEAAAEAV1@D@Z");
490 SET(p_ostream_write_char
, "?write@ostream@@QEAAAEAV1@PEBDH@Z");
491 SET(p_ostream_seekp_offset
, "?seekp@ostream@@QEAAAEAV1@JW4seek_dir@ios@@@Z");
492 SET(p_ostream_seekp
, "?seekp@ostream@@QEAAAEAV1@J@Z");
493 SET(p_ostream_tellp
, "?tellp@ostream@@QEAAJXZ");
494 SET(p_ostream_writepad
, "?writepad@ostream@@AEAAAEAV1@PEBD0@Z");
495 SET(p_ostream_print_char
, "??6ostream@@QEAAAEAV0@D@Z");
496 SET(p_ostream_print_str
, "??6ostream@@QEAAAEAV0@PEBD@Z");
497 SET(p_ostream_print_int
, "??6ostream@@QEAAAEAV0@H@Z");
498 SET(p_ostream_print_float
, "??6ostream@@QEAAAEAV0@M@Z");
499 SET(p_ostream_print_double
, "??6ostream@@QEAAAEAV0@N@Z");
500 SET(p_ostream_print_ptr
, "??6ostream@@QEAAAEAV0@PEBX@Z");
501 SET(p_ostream_print_streambuf
, "??6ostream@@QEAAAEAV0@PEAVstreambuf@@@Z");
503 SET(p_istream_copy_ctor
, "??0istream@@IEAA@AEBV0@@Z");
504 SET(p_istream_ctor
, "??0istream@@IEAA@XZ");
505 SET(p_istream_sb_ctor
, "??0istream@@QEAA@PEAVstreambuf@@@Z");
506 SET(p_istream_dtor
, "??1istream@@UEAA@XZ");
507 SET(p_istream_assign_sb
, "??4istream@@IEAAAEAV0@PEAVstreambuf@@@Z");
508 SET(p_istream_assign
, "??4istream@@IEAAAEAV0@AEBV0@@Z");
509 SET(p_istream_vbase_dtor
, "??_Distream@@QEAAXXZ");
510 SET(p_istream_eatwhite
, "?eatwhite@istream@@QEAAXXZ");
512 p_operator_new
= (void*)GetProcAddress(msvcrt
, "??2@YAPAXI@Z");
513 p_operator_delete
= (void*)GetProcAddress(msvcrt
, "??3@YAXPAX@Z");
515 SET(p_streambuf_reserve_ctor
, "??0streambuf@@IAE@PADH@Z");
516 SET(p_streambuf_ctor
, "??0streambuf@@IAE@XZ");
517 SET(p_streambuf_dtor
, "??1streambuf@@UAE@XZ");
518 SET(p_streambuf_allocate
, "?allocate@streambuf@@IAEHXZ");
519 SET(p_streambuf_clrclock
, "?clrlock@streambuf@@QAEXXZ");
520 SET(p_streambuf_doallocate
, "?doallocate@streambuf@@MAEHXZ");
521 SET(p_streambuf_gbump
, "?gbump@streambuf@@IAEXH@Z");
522 SET(p_streambuf_lock
, "?lock@streambuf@@QAEXXZ");
523 SET(p_streambuf_pbackfail
, "?pbackfail@streambuf@@UAEHH@Z");
524 SET(p_streambuf_pbump
, "?pbump@streambuf@@IAEXH@Z");
525 SET(p_streambuf_sbumpc
, "?sbumpc@streambuf@@QAEHXZ");
526 SET(p_streambuf_setb
, "?setb@streambuf@@IAEXPAD0H@Z");
527 SET(p_streambuf_setbuf
, "?setbuf@streambuf@@UAEPAV1@PADH@Z");
528 SET(p_streambuf_setlock
, "?setlock@streambuf@@QAEXXZ");
529 SET(p_streambuf_sgetc
, "?sgetc@streambuf@@QAEHXZ");
530 SET(p_streambuf_snextc
, "?snextc@streambuf@@QAEHXZ");
531 SET(p_streambuf_sputc
, "?sputc@streambuf@@QAEHH@Z");
532 SET(p_streambuf_stossc
, "?stossc@streambuf@@QAEXXZ");
533 SET(p_streambuf_sync
, "?sync@streambuf@@UAEHXZ");
534 SET(p_streambuf_unlock
, "?unlock@streambuf@@QAEXXZ");
535 SET(p_streambuf_xsgetn
, "?xsgetn@streambuf@@UAEHPADH@Z");
536 SET(p_streambuf_xsputn
, "?xsputn@streambuf@@UAEHPBDH@Z");
538 SET(p_filebuf_fd_ctor
, "??0filebuf@@QAE@H@Z");
539 SET(p_filebuf_fd_reserve_ctor
, "??0filebuf@@QAE@HPADH@Z");
540 SET(p_filebuf_ctor
, "??0filebuf@@QAE@XZ");
541 SET(p_filebuf_dtor
, "??1filebuf@@UAE@XZ");
542 SET(p_filebuf_attach
, "?attach@filebuf@@QAEPAV1@H@Z");
543 SET(p_filebuf_open
, "?open@filebuf@@QAEPAV1@PBDHH@Z");
544 SET(p_filebuf_close
, "?close@filebuf@@QAEPAV1@XZ");
545 SET(p_filebuf_setmode
, "?setmode@filebuf@@QAEHH@Z");
546 SET(p_filebuf_setbuf
, "?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z");
547 SET(p_filebuf_sync
, "?sync@filebuf@@UAEHXZ");
548 SET(p_filebuf_overflow
, "?overflow@filebuf@@UAEHH@Z");
549 SET(p_filebuf_underflow
, "?underflow@filebuf@@UAEHXZ");
550 SET(p_filebuf_seekoff
, "?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z");
552 SET(p_strstreambuf_dynamic_ctor
, "??0strstreambuf@@QAE@H@Z");
553 SET(p_strstreambuf_funcs_ctor
, "??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z");
554 SET(p_strstreambuf_buffer_ctor
, "??0strstreambuf@@QAE@PADH0@Z");
555 SET(p_strstreambuf_ubuffer_ctor
, "??0strstreambuf@@QAE@PAEH0@Z");
556 SET(p_strstreambuf_ctor
, "??0strstreambuf@@QAE@XZ");
557 SET(p_strstreambuf_dtor
, "??1strstreambuf@@UAE@XZ");
558 SET(p_strstreambuf_doallocate
, "?doallocate@strstreambuf@@MAEHXZ");
559 SET(p_strstreambuf_freeze
, "?freeze@strstreambuf@@QAEXH@Z");
560 SET(p_strstreambuf_overflow
, "?overflow@strstreambuf@@UAEHH@Z");
561 SET(p_strstreambuf_seekoff
, "?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z");
562 SET(p_strstreambuf_setbuf
, "?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z");
563 SET(p_strstreambuf_underflow
, "?underflow@strstreambuf@@UAEHXZ");
565 SET(p_stdiobuf_file_ctor
, "??0stdiobuf@@QAE@PAU_iobuf@@@Z");
566 SET(p_stdiobuf_dtor
, "??1stdiobuf@@UAE@XZ");
567 SET(p_stdiobuf_overflow
, "?overflow@stdiobuf@@UAEHH@Z");
568 SET(p_stdiobuf_pbackfail
, "?pbackfail@stdiobuf@@UAEHH@Z");
569 SET(p_stdiobuf_seekoff
, "?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z");
570 SET(p_stdiobuf_setrwbuf
, "?setrwbuf@stdiobuf@@QAEHHH@Z");
571 SET(p_stdiobuf_sync
, "?sync@stdiobuf@@UAEHXZ");
572 SET(p_stdiobuf_underflow
, "?underflow@stdiobuf@@UAEHXZ");
574 SET(p_ios_copy_ctor
, "??0ios@@IAE@ABV0@@Z");
575 SET(p_ios_ctor
, "??0ios@@IAE@XZ");
576 SET(p_ios_sb_ctor
, "??0ios@@QAE@PAVstreambuf@@@Z");
577 SET(p_ios_assign
, "??4ios@@IAEAAV0@ABV0@@Z");
578 SET(p_ios_init
, "?init@ios@@IAEXPAVstreambuf@@@Z");
579 SET(p_ios_dtor
, "??1ios@@UAE@XZ");
580 SET(p_ios_clrlock
, "?clrlock@ios@@QAAXXZ");
581 SET(p_ios_setlock
, "?setlock@ios@@QAAXXZ");
582 SET(p_ios_lock
, "?lock@ios@@QAAXXZ");
583 SET(p_ios_unlock
, "?unlock@ios@@QAAXXZ");
584 SET(p_ios_lockbuf
, "?lockbuf@ios@@QAAXXZ");
585 SET(p_ios_unlockbuf
, "?unlockbuf@ios@@QAAXXZ");
586 SET(p_ios_flags_set
, "?flags@ios@@QAEJJ@Z");
587 SET(p_ios_flags_get
, "?flags@ios@@QBEJXZ");
588 SET(p_ios_setf
, "?setf@ios@@QAEJJ@Z");
589 SET(p_ios_setf_mask
, "?setf@ios@@QAEJJJ@Z");
590 SET(p_ios_unsetf
, "?unsetf@ios@@QAEJJ@Z");
591 SET(p_ios_good
, "?good@ios@@QBEHXZ");
592 SET(p_ios_bad
, "?bad@ios@@QBEHXZ");
593 SET(p_ios_eof
, "?eof@ios@@QBEHXZ");
594 SET(p_ios_fail
, "?fail@ios@@QBEHXZ");
595 SET(p_ios_clear
, "?clear@ios@@QAEXH@Z");
596 SET(p_ios_iword
, "?iword@ios@@QBEAAJH@Z");
597 SET(p_ios_pword
, "?pword@ios@@QBEAAPAXH@Z");
599 SET(p_ostream_copy_ctor
, "??0ostream@@IAE@ABV0@@Z");
600 SET(p_ostream_sb_ctor
, "??0ostream@@QAE@PAVstreambuf@@@Z");
601 SET(p_ostream_ctor
, "??0ostream@@IAE@XZ");
602 SET(p_ostream_dtor
, "??1ostream@@UAE@XZ");
603 SET(p_ostream_assign
, "??4ostream@@IAEAAV0@ABV0@@Z");
604 SET(p_ostream_assign_sb
, "??4ostream@@IAEAAV0@PAVstreambuf@@@Z");
605 SET(p_ostream_vbase_dtor
, "??_Dostream@@QAEXXZ");
606 SET(p_ostream_flush
, "?flush@ostream@@QAEAAV1@XZ");
607 SET(p_ostream_opfx
, "?opfx@ostream@@QAEHXZ");
608 SET(p_ostream_osfx
, "?osfx@ostream@@QAEXXZ");
609 SET(p_ostream_put_char
, "?put@ostream@@QAEAAV1@D@Z");
610 SET(p_ostream_write_char
, "?write@ostream@@QAEAAV1@PBDH@Z");
611 SET(p_ostream_seekp_offset
, "?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z");
612 SET(p_ostream_seekp
, "?seekp@ostream@@QAEAAV1@J@Z");
613 SET(p_ostream_tellp
, "?tellp@ostream@@QAEJXZ");
614 SET(p_ostream_writepad
, "?writepad@ostream@@AAEAAV1@PBD0@Z");
615 SET(p_ostream_print_char
, "??6ostream@@QAEAAV0@D@Z");
616 SET(p_ostream_print_str
, "??6ostream@@QAEAAV0@PBD@Z");
617 SET(p_ostream_print_int
, "??6ostream@@QAEAAV0@H@Z");
618 SET(p_ostream_print_float
, "??6ostream@@QAEAAV0@M@Z");
619 SET(p_ostream_print_double
, "??6ostream@@QAEAAV0@N@Z");
620 SET(p_ostream_print_ptr
, "??6ostream@@QAEAAV0@PBX@Z");
621 SET(p_ostream_print_streambuf
, "??6ostream@@QAEAAV0@PAVstreambuf@@@Z");
623 SET(p_istream_copy_ctor
, "??0istream@@IAE@ABV0@@Z");
624 SET(p_istream_ctor
, "??0istream@@IAE@XZ");
625 SET(p_istream_sb_ctor
, "??0istream@@QAE@PAVstreambuf@@@Z");
626 SET(p_istream_dtor
, "??1istream@@UAE@XZ");
627 SET(p_istream_assign_sb
, "??4istream@@IAEAAV0@PAVstreambuf@@@Z");
628 SET(p_istream_assign
, "??4istream@@IAEAAV0@ABV0@@Z");
629 SET(p_istream_vbase_dtor
, "??_Distream@@QAEXXZ");
630 SET(p_istream_eatwhite
, "?eatwhite@istream@@QAEXXZ");
632 SET(p_ios_static_lock
, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
633 SET(p_ios_lockc
, "?lockc@ios@@KAXXZ");
634 SET(p_ios_unlockc
, "?unlockc@ios@@KAXXZ");
635 SET(p_ios_maxbit
, "?x_maxbit@ios@@0JA");
636 SET(p_ios_bitalloc
, "?bitalloc@ios@@SAJXZ");
637 SET(p_ios_curindex
, "?x_curindex@ios@@0HA");
638 SET(p_ios_statebuf
, "?x_statebuf@ios@@0PAJA");
639 SET(p_ios_xalloc
, "?xalloc@ios@@SAHXZ");
640 SET(p_ios_fLockcInit
, "?fLockcInit@ios@@0HA");
642 init_thiscall_thunk();
646 static int overflow_count
, underflow_count
;
647 static streambuf
*test_this
;
648 static char test_get_buffer
[24];
649 static int buffer_pos
, get_end
;
652 static int __thiscall
test_streambuf_overflow(int ch
)
654 static int __thiscall
test_streambuf_overflow(streambuf
*this, int ch
)
658 if (ch
== 'L') /* simulate a failure */
660 if (!test_this
->unbuffered
)
661 test_this
->pptr
= test_this
->pbase
+ 5;
666 static int __thiscall
test_streambuf_underflow(void)
668 static int __thiscall
test_streambuf_underflow(streambuf
*this)
672 if (test_this
->unbuffered
) {
673 return (buffer_pos
< 23) ? test_get_buffer
[buffer_pos
++] : EOF
;
674 } else if (test_this
->gptr
< test_this
->egptr
) {
675 return *test_this
->gptr
;
677 return get_end
? EOF
: *(test_this
->gptr
= test_this
->eback
);
681 struct streambuf_lock_arg
688 static DWORD WINAPI
lock_streambuf(void *arg
)
690 struct streambuf_lock_arg
*lock_arg
= arg
;
691 call_func1(p_streambuf_lock
, lock_arg
->sb
);
692 SetEvent(lock_arg
->lock
[0]);
693 WaitForSingleObject(lock_arg
->test
[0], INFINITE
);
694 call_func1(p_streambuf_lock
, lock_arg
->sb
);
695 SetEvent(lock_arg
->lock
[1]);
696 WaitForSingleObject(lock_arg
->test
[1], INFINITE
);
697 call_func1(p_streambuf_lock
, lock_arg
->sb
);
698 SetEvent(lock_arg
->lock
[2]);
699 WaitForSingleObject(lock_arg
->test
[2], INFINITE
);
700 call_func1(p_streambuf_unlock
, lock_arg
->sb
);
701 SetEvent(lock_arg
->lock
[3]);
702 WaitForSingleObject(lock_arg
->test
[3], INFINITE
);
703 call_func1(p_streambuf_unlock
, lock_arg
->sb
);
707 static void test_streambuf(void)
709 streambuf sb
, sb2
, sb3
, *psb
;
710 vtable_ptr test_streambuf_vtbl
[11];
711 struct streambuf_lock_arg lock_arg
;
717 memset(&sb
, 0xab, sizeof(streambuf
));
718 memset(&sb2
, 0xab, sizeof(streambuf
));
719 memset(&sb3
, 0xab, sizeof(streambuf
));
722 call_func1(p_streambuf_ctor
, &sb
);
723 ok(sb
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", sb
.allocated
);
724 ok(sb
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", sb
.unbuffered
);
725 ok(sb
.base
== NULL
, "wrong base pointer, expected %p got %p\n", NULL
, sb
.base
);
726 ok(sb
.ebuf
== NULL
, "wrong ebuf pointer, expected %p got %p\n", NULL
, sb
.ebuf
);
727 ok(sb
.lock
.LockCount
== -1, "wrong critical section state, expected -1 got %d\n", sb
.lock
.LockCount
);
728 call_func3(p_streambuf_reserve_ctor
, &sb2
, reserve
, 16);
729 ok(sb2
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", sb2
.allocated
);
730 ok(sb2
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", sb2
.unbuffered
);
731 ok(sb2
.base
== reserve
, "wrong base pointer, expected %p got %p\n", reserve
, sb2
.base
);
732 ok(sb2
.ebuf
== reserve
+16, "wrong ebuf pointer, expected %p got %p\n", reserve
+16, sb2
.ebuf
);
733 ok(sb
.lock
.LockCount
== -1, "wrong critical section state, expected -1 got %d\n", sb
.lock
.LockCount
);
734 call_func1(p_streambuf_ctor
, &sb3
);
735 ok(sb3
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", sb3
.allocated
);
736 ok(sb3
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", sb3
.unbuffered
);
737 ok(sb3
.base
== NULL
, "wrong base pointer, expected %p got %p\n", NULL
, sb3
.base
);
738 ok(sb3
.ebuf
== NULL
, "wrong ebuf pointer, expected %p got %p\n", NULL
, sb3
.ebuf
);
740 memcpy(test_streambuf_vtbl
, sb
.vtable
, sizeof(test_streambuf_vtbl
));
741 test_streambuf_vtbl
[7] = (vtable_ptr
)&test_streambuf_overflow
;
742 test_streambuf_vtbl
[8] = (vtable_ptr
)&test_streambuf_underflow
;
743 sb2
.vtable
= test_streambuf_vtbl
;
744 sb3
.vtable
= test_streambuf_vtbl
;
745 overflow_count
= underflow_count
= 0;
746 strcpy(test_get_buffer
, "CompuGlobalHyperMegaNet");
747 buffer_pos
= get_end
= 0;
750 ok(sb
.do_lock
== -1, "expected do_lock value -1, got %d\n", sb
.do_lock
);
751 call_func1(p_streambuf_setlock
, &sb
);
752 ok(sb
.do_lock
== -2, "expected do_lock value -2, got %d\n", sb
.do_lock
);
753 call_func1(p_streambuf_setlock
, &sb
);
754 ok(sb
.do_lock
== -3, "expected do_lock value -3, got %d\n", sb
.do_lock
);
756 call_func1(p_streambuf_setlock
, &sb
);
757 ok(sb
.do_lock
== 2, "expected do_lock value 2, got %d\n", sb
.do_lock
);
761 call_func1(p_streambuf_clrclock
, &sb
);
762 ok(sb
.do_lock
== -1, "expected do_lock value -1, got %d\n", sb
.do_lock
);
763 call_func1(p_streambuf_clrclock
, &sb
);
764 ok(sb
.do_lock
== 0, "expected do_lock value 0, got %d\n", sb
.do_lock
);
765 call_func1(p_streambuf_clrclock
, &sb
);
766 ok(sb
.do_lock
== 1, "expected do_lock value 1, got %d\n", sb
.do_lock
);
767 call_func1(p_streambuf_clrclock
, &sb
);
768 ok(sb
.do_lock
== 1, "expected do_lock value 1, got %d\n", sb
.do_lock
);
772 for (i
= 0; i
< 4; i
++) {
773 lock_arg
.lock
[i
] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
774 ok(lock_arg
.lock
[i
] != NULL
, "CreateEventW failed\n");
775 lock_arg
.test
[i
] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
776 ok(lock_arg
.test
[i
] != NULL
, "CreateEventW failed\n");
780 thread
= CreateThread(NULL
, 0, lock_streambuf
, (void*)&lock_arg
, 0, NULL
);
781 ok(thread
!= NULL
, "CreateThread failed\n");
782 WaitForSingleObject(lock_arg
.lock
[0], INFINITE
);
783 locked
= TryEnterCriticalSection(&sb
.lock
);
784 ok(locked
!= 0, "could not lock the streambuf\n");
785 LeaveCriticalSection(&sb
.lock
);
788 SetEvent(lock_arg
.test
[0]);
789 WaitForSingleObject(lock_arg
.lock
[1], INFINITE
);
790 locked
= TryEnterCriticalSection(&sb
.lock
);
791 ok(locked
!= 0, "could not lock the streambuf\n");
792 LeaveCriticalSection(&sb
.lock
);
795 SetEvent(lock_arg
.test
[1]);
796 WaitForSingleObject(lock_arg
.lock
[2], INFINITE
);
797 locked
= TryEnterCriticalSection(&sb
.lock
);
798 ok(locked
== 0, "the streambuf was not locked before\n");
801 SetEvent(lock_arg
.test
[2]);
802 WaitForSingleObject(lock_arg
.lock
[3], INFINITE
);
803 locked
= TryEnterCriticalSection(&sb
.lock
);
804 ok(locked
== 0, "the streambuf was not locked before\n");
808 call_func4(p_streambuf_setb
, &sb
, reserve
, reserve
+16, 0);
809 ok(sb
.base
== reserve
, "wrong base pointer, expected %p got %p\n", reserve
, sb
.base
);
810 ok(sb
.ebuf
== reserve
+16, "wrong ebuf pointer, expected %p got %p\n", reserve
+16, sb
.ebuf
);
811 call_func4(p_streambuf_setb
, &sb
, reserve
, reserve
+16, 4);
812 ok(sb
.allocated
== 4, "wrong allocate value, expected 4 got %d\n", sb
.allocated
);
814 call_func4(p_streambuf_setb
, &sb
, NULL
, NULL
, 3);
815 ok(sb
.allocated
== 3, "wrong allocate value, expected 3 got %d\n", sb
.allocated
);
818 psb
= call_func3(p_streambuf_setbuf
, &sb
, NULL
, 5);
819 ok(psb
== &sb
, "wrong return value, expected %p got %p\n", &sb
, psb
);
820 ok(sb
.allocated
== 3, "wrong allocate value, expected 3 got %d\n", sb
.allocated
);
821 ok(sb
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", sb
.unbuffered
);
822 ok(sb
.base
== NULL
, "wrong base pointer, expected %p got %p\n", NULL
, sb
.base
);
823 ok(sb
.ebuf
== NULL
, "wrong ebuf pointer, expected %p got %p\n", NULL
, sb
.ebuf
);
824 psb
= call_func3(p_streambuf_setbuf
, &sb
, reserve
, 0);
825 ok(psb
== &sb
, "wrong return value, expected %p got %p\n", &sb
, psb
);
826 ok(sb
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", sb
.unbuffered
);
827 ok(sb
.base
== NULL
, "wrong base pointer, expected %p got %p\n", NULL
, sb
.base
);
828 ok(sb
.ebuf
== NULL
, "wrong ebuf pointer, expected %p got %p\n", NULL
, sb
.ebuf
);
829 psb
= call_func3(p_streambuf_setbuf
, &sb
, reserve
, 16);
830 ok(psb
== &sb
, "wrong return value, expected %p got %p\n", &sb
, psb
);
831 ok(sb
.allocated
== 3, "wrong allocate value, expected 3 got %d\n", sb
.allocated
);
832 ok(sb
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", sb
.unbuffered
);
833 ok(sb
.base
== reserve
, "wrong base pointer, expected %p got %p\n", reserve
, sb
.base
);
834 ok(sb
.ebuf
== reserve
+16, "wrong ebuf pointer, expected %p got %p\n", reserve
+16, sb
.ebuf
);
835 psb
= call_func3(p_streambuf_setbuf
, &sb
, NULL
, 8);
836 ok(psb
== NULL
, "wrong return value, expected %p got %p\n", NULL
, psb
);
837 ok(sb
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", sb
.unbuffered
);
838 ok(sb
.base
== reserve
, "wrong base pointer, expected %p got %p\n", reserve
, sb
.base
);
839 ok(sb
.ebuf
== reserve
+16, "wrong ebuf pointer, expected %p got %p\n", reserve
+16, sb
.ebuf
);
842 ret
= (int) call_func1(p_streambuf_allocate
, &sb
);
843 ok(ret
== 0, "wrong return value, expected 0 got %d\n", ret
);
845 ret
= (int) call_func1(p_streambuf_allocate
, &sb
);
846 ok(ret
== 1, "wrong return value, expected 1 got %d\n", ret
);
847 ok(sb
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", sb
.allocated
);
848 ok(sb
.ebuf
- sb
.base
== 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb
.ebuf
, sb
.base
);
851 ret
= (int) call_func1(p_streambuf_doallocate
, &sb2
);
852 ok(ret
== 1, "doallocate failed, got %d\n", ret
);
853 ok(sb2
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", sb2
.allocated
);
854 ok(sb2
.ebuf
- sb2
.base
== 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb2
.ebuf
, sb2
.base
);
855 ret
= (int) call_func1(p_streambuf_doallocate
, &sb3
);
856 ok(ret
== 1, "doallocate failed, got %d\n", ret
);
857 ok(sb3
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", sb3
.allocated
);
858 ok(sb3
.ebuf
- sb3
.base
== 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb3
.ebuf
, sb3
.base
);
860 /* sb: buffered, space available */
861 sb
.eback
= sb
.gptr
= sb
.base
;
862 sb
.egptr
= sb
.base
+ 256;
863 sb
.pbase
= sb
.pptr
= sb
.base
+ 256;
864 sb
.epptr
= sb
.base
+ 512;
865 /* sb2: buffered, no space available */
866 sb2
.eback
= sb2
.base
;
867 sb2
.gptr
= sb2
.egptr
= sb2
.base
+ 256;
868 sb2
.pbase
= sb2
.base
+ 256;
869 sb2
.pptr
= sb2
.epptr
= sb2
.base
+ 512;
870 /* sb3: unbuffered */
874 call_func2(p_streambuf_gbump
, &sb
, 10);
875 ok(sb
.gptr
== sb
.eback
+ 10, "advance get pointer failed, expected %p got %p\n", sb
.eback
+ 10, sb
.gptr
);
876 call_func2(p_streambuf_gbump
, &sb
, -15);
877 ok(sb
.gptr
== sb
.eback
- 5, "advance get pointer failed, expected %p got %p\n", sb
.eback
- 5, sb
.gptr
);
881 call_func2(p_streambuf_pbump
, &sb
, -2);
882 ok(sb
.pptr
== sb
.pbase
- 2, "advance put pointer failed, expected %p got %p\n", sb
.pbase
- 2, sb
.pptr
);
883 call_func2(p_streambuf_pbump
, &sb
, 20);
884 ok(sb
.pptr
== sb
.pbase
+ 18, "advance put pointer failed, expected %p got %p\n", sb
.pbase
+ 18, sb
.pptr
);
888 ret
= (int) call_func1(p_streambuf_sync
, &sb
);
889 ok(ret
== EOF
, "sync failed, expected EOF got %d\n", ret
);
891 ret
= (int) call_func1(p_streambuf_sync
, &sb
);
892 ok(ret
== 0, "sync failed, expected 0 got %d\n", ret
);
893 sb
.gptr
= sb
.egptr
+ 1;
894 ret
= (int) call_func1(p_streambuf_sync
, &sb
);
895 ok(ret
== 0, "sync failed, expected 0 got %d\n", ret
);
897 ret
= (int) call_func1(p_streambuf_sync
, &sb2
);
898 ok(ret
== EOF
, "sync failed, expected EOF got %d\n", ret
);
899 sb2
.pptr
= sb2
.pbase
;
900 ret
= (int) call_func1(p_streambuf_sync
, &sb2
);
901 ok(ret
== 0, "sync failed, expected 0 got %d\n", ret
);
902 sb2
.pptr
= sb2
.pbase
- 1;
903 ret
= (int) call_func1(p_streambuf_sync
, &sb2
);
904 ok(ret
== 0, "sync failed, expected 0 got %d\n", ret
);
905 sb2
.pptr
= sb2
.epptr
;
906 ret
= (int) call_func1(p_streambuf_sync
, &sb3
);
907 ok(ret
== 0, "sync failed, expected 0 got %d\n", ret
);
910 strcpy(sb2
.eback
, "WorstTestEver");
912 ret
= (int) call_func1(p_streambuf_sgetc
, &sb2
);
913 ok(ret
== 'W', "expected 'W' got '%c'\n", ret
);
914 ok(underflow_count
== 1, "expected call to underflow\n");
915 ok(sb2
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb2
.stored_char
);
917 ret
= (int) call_func1(p_streambuf_sgetc
, &sb2
);
918 ok(ret
== 'o', "expected 'o' got '%c'\n", ret
);
919 ok(underflow_count
== 2, "expected call to underflow\n");
920 ok(sb2
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb2
.stored_char
);
921 sb2
.gptr
= sb2
.egptr
;
923 ret
= (int) call_func1(p_streambuf_sgetc
, &sb3
);
924 ok(ret
== 'C', "expected 'C' got '%c'\n", ret
);
925 ok(underflow_count
== 3, "expected call to underflow\n");
926 ok(sb3
.stored_char
== 'C', "wrong stored character, expected 'C' got %c\n", sb3
.stored_char
);
927 sb3
.stored_char
= 'b';
928 ret
= (int) call_func1(p_streambuf_sgetc
, &sb3
);
929 ok(ret
== 'b', "expected 'b' got '%c'\n", ret
);
930 ok(underflow_count
== 3, "no call to underflow expected\n");
931 ok(sb3
.stored_char
== 'b', "wrong stored character, expected 'b' got %c\n", sb3
.stored_char
);
935 ret
= (int) call_func2(p_streambuf_sputc
, &sb
, 'c');
936 ok(ret
== 'c', "wrong return value, expected 'c' got %d\n", ret
);
937 ok(overflow_count
== 0, "no call to overflow expected\n");
938 ok(*sb
.pbase
== 'c', "expected 'c' in the put area, got %c\n", *sb
.pbase
);
939 ok(sb
.pptr
== sb
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", sb
.pbase
+ 1, sb
.pptr
);
941 ret
= (int) call_func2(p_streambuf_sputc
, &sb
, 150);
942 ok(ret
== 150, "wrong return value, expected 150 got %d\n", ret
);
943 ok(overflow_count
== 0, "no call to overflow expected\n");
944 ok(*sb
.pbase
== -106, "expected -106 in the put area, got %d\n", *sb
.pbase
);
945 ok(sb
.pptr
== sb
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", sb
.pbase
+ 1, sb
.pptr
);
947 ret
= (int) call_func2(p_streambuf_sputc
, &sb
, -50);
948 ok(ret
== 206, "wrong return value, expected 206 got %d\n", ret
);
949 ok(overflow_count
== 0, "no call to overflow expected\n");
950 ok(*sb
.pbase
== -50, "expected -50 in the put area, got %d\n", *sb
.pbase
);
951 ok(sb
.pptr
== sb
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", sb
.pbase
+ 1, sb
.pptr
);
953 ret
= (int) call_func2(p_streambuf_sputc
, &sb2
, 'c');
954 ok(ret
== 'c', "wrong return value, expected 'c' got %d\n", ret
);
955 ok(overflow_count
== 1, "expected call to overflow\n");
956 ok(sb2
.pptr
== sb2
.pbase
+ 5, "wrong put pointer, expected %p got %p\n", sb2
.pbase
+ 5, sb2
.pptr
);
958 ret
= (int) call_func2(p_streambuf_sputc
, &sb3
, 'c');
959 ok(ret
== 'c', "wrong return value, expected 'c' got %d\n", ret
);
960 ok(overflow_count
== 2, "expected call to overflow\n");
961 sb3
.pbase
= sb3
.pptr
= sb3
.base
;
962 sb3
.epptr
= sb3
.ebuf
;
963 ret
= (int) call_func2(p_streambuf_sputc
, &sb3
, 'c');
964 ok(ret
== 'c', "wrong return value, expected 'c' got %d\n", ret
);
965 ok(overflow_count
== 2, "no call to overflow expected\n");
966 ok(*sb3
.pbase
== 'c', "expected 'c' in the put area, got %c\n", *sb3
.pbase
);
967 sb3
.pbase
= sb3
.pptr
= sb3
.epptr
= NULL
;
970 sb2
.gptr
= sb2
.egptr
= sb2
.eback
+ 13;
972 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb2
, reserve
, 5);
973 ok(ret
== 5, "wrong return value, expected 5 got %d\n", ret
);
974 ok(!strncmp(reserve
, "Worst", 5), "expected 'Worst' got %s\n", reserve
);
975 ok(sb2
.gptr
== sb2
.eback
+ 5, "wrong get pointer, expected %p got %p\n", sb2
.eback
+ 5, sb2
.gptr
);
976 ok(underflow_count
== 4, "expected call to underflow\n");
977 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb2
, reserve
, 4);
978 ok(ret
== 4, "wrong return value, expected 4 got %d\n", ret
);
979 ok(!strncmp(reserve
, "Test", 4), "expected 'Test' got %s\n", reserve
);
980 ok(sb2
.gptr
== sb2
.eback
+ 9, "wrong get pointer, expected %p got %p\n", sb2
.eback
+ 9, sb2
.gptr
);
981 ok(underflow_count
== 5, "expected call to underflow\n");
983 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb2
, reserve
, 16);
984 ok(ret
== 4, "wrong return value, expected 4 got %d\n", ret
);
985 ok(!strncmp(reserve
, "Ever", 4), "expected 'Ever' got %s\n", reserve
);
986 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
987 ok(underflow_count
== 7, "expected 2 calls to underflow, got %d\n", underflow_count
- 5);
989 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb3
, reserve
, 11);
990 ok(ret
== 11, "wrong return value, expected 11 got %d\n", ret
);
991 ok(!strncmp(reserve
, "bompuGlobal", 11), "expected 'bompuGlobal' got %s\n", reserve
);
992 ok(sb3
.stored_char
== 'H', "wrong stored character, expected 'H' got %c\n", sb3
.stored_char
);
993 ok(underflow_count
== 18, "expected 11 calls to underflow, got %d\n", underflow_count
- 7);
994 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb3
, reserve
, 16);
995 ok(ret
== 12, "wrong return value, expected 12 got %d\n", ret
);
996 ok(!strncmp(reserve
, "HyperMegaNet", 12), "expected 'HyperMegaNet' got %s\n", reserve
);
997 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
998 ok(underflow_count
== 30, "expected 12 calls to underflow, got %d\n", underflow_count
- 18);
999 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb3
, reserve
, 3);
1000 ok(ret
== 0, "wrong return value, expected 0 got %d\n", ret
);
1001 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1002 ok(underflow_count
== 31, "expected call to underflow\n");
1004 ret
= (int) call_func3(p_streambuf_xsgetn
, &sb3
, reserve
, 5);
1005 ok(ret
== 5, "wrong return value, expected 5 got %d\n", ret
);
1006 ok(!strncmp(reserve
, "Compu", 5), "expected 'Compu' got %s\n", reserve
);
1007 ok(sb3
.stored_char
== 'G', "wrong stored character, expected 'G' got %c\n", sb3
.stored_char
);
1008 ok(underflow_count
== 37, "expected 6 calls to underflow, got %d\n", underflow_count
- 31);
1011 ret
= (int) call_func3(p_streambuf_xsputn
, &sb
, "Test\0ing", 8);
1012 ok(ret
== 8, "wrong return value, expected 8 got %d\n", ret
);
1013 ok(sb
.pptr
== sb
.pbase
+ 9, "wrong put pointer, expected %p got %p\n", sb
.pbase
+ 9, sb
.pptr
);
1015 sb2
.pptr
= sb2
.epptr
- 7;
1016 ret
= (int) call_func3(p_streambuf_xsputn
, &sb2
, "Testing", 7);
1017 ok(ret
== 7, "wrong return value, expected 7 got %d\n", ret
);
1018 ok(sb2
.pptr
== sb2
.epptr
, "wrong put pointer, expected %p got %p\n", sb2
.epptr
, sb2
.pptr
);
1019 ok(overflow_count
== 2, "no call to overflow expected\n");
1020 sb2
.pptr
= sb2
.epptr
- 5;
1022 ret
= (int) call_func3(p_streambuf_xsputn
, &sb2
, "Testing", 7);
1023 ok(ret
== 7, "wrong return value, expected 7 got %d\n", ret
);
1024 ok(sb2
.pbase
[5] == 'g', "expected 'g' got %c\n", sb2
.pbase
[5]);
1025 ok(sb2
.pptr
== sb2
.pbase
+ 6, "wrong put pointer, expected %p got %p\n", sb2
.pbase
+ 6, sb2
.pptr
);
1026 ok(overflow_count
== 3, "expected call to overflow\n");
1027 sb2
.pptr
= sb2
.epptr
- 4;
1028 ret
= (int) call_func3(p_streambuf_xsputn
, &sb2
, "TestLing", 8);
1029 ok(ret
== 4, "wrong return value, expected 4 got %d\n", ret
);
1030 ok(sb2
.pptr
== sb2
.epptr
, "wrong put pointer, expected %p got %p\n", sb2
.epptr
, sb2
.pptr
);
1031 ok(overflow_count
== 4, "expected call to overflow\n");
1033 ret
= (int) call_func3(p_streambuf_xsputn
, &sb3
, "Testing", 7);
1034 ok(ret
== 7, "wrong return value, expected 7 got %d\n", ret
);
1035 ok(sb3
.stored_char
== 'G', "wrong stored character, expected 'G' got %c\n", sb3
.stored_char
);
1036 ok(overflow_count
== 11, "expected 7 calls to overflow, got %d\n", overflow_count
- 4);
1037 ret
= (int) call_func3(p_streambuf_xsputn
, &sb3
, "TeLephone", 9);
1038 ok(ret
== 2, "wrong return value, expected 2 got %d\n", ret
);
1039 ok(sb3
.stored_char
== 'G', "wrong stored character, expected 'G' got %c\n", sb3
.stored_char
);
1040 ok(overflow_count
== 14, "expected 3 calls to overflow, got %d\n", overflow_count
- 11);
1043 strcpy(sb
.eback
, "Test");
1044 ret
= (int) call_func1(p_streambuf_snextc
, &sb
);
1045 ok(ret
== 'e', "expected 'e' got '%c'\n", ret
);
1046 ok(sb
.gptr
== sb
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 1, sb
.gptr
);
1048 ret
= (int) call_func1(p_streambuf_snextc
, &sb
);
1049 ok(ret
== 206, "expected 206 got %d\n", ret
);
1050 ok(sb
.gptr
== sb
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 1, sb
.gptr
);
1052 ret
= (int) call_func1(p_streambuf_snextc
, &sb2
);
1053 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1054 ok(sb2
.gptr
== sb2
.egptr
+ 1, "wrong get pointer, expected %p got %p\n", sb2
.egptr
+ 1, sb2
.gptr
);
1055 ok(underflow_count
== 39, "expected 2 calls to underflow, got %d\n", underflow_count
- 37);
1056 sb2
.gptr
= sb2
.egptr
- 1;
1057 ret
= (int) call_func1(p_streambuf_snextc
, &sb2
);
1058 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1059 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
1060 ok(underflow_count
== 40, "expected call to underflow\n");
1062 ret
= (int) call_func1(p_streambuf_snextc
, &sb2
);
1063 ok(ret
== 'o', "expected 'o' got '%c'\n", ret
);
1064 ok(sb2
.gptr
== sb2
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb2
.eback
+ 1, sb2
.gptr
);
1065 ok(underflow_count
== 41, "expected call to underflow\n");
1066 sb2
.gptr
= sb2
.egptr
- 1;
1067 ret
= (int) call_func1(p_streambuf_snextc
, &sb2
);
1068 ok(ret
== 'W', "expected 'W' got '%c'\n", ret
);
1069 ok(sb2
.gptr
== sb2
.eback
, "wrong get pointer, expected %p got %p\n", sb2
.eback
, sb2
.gptr
);
1070 ok(underflow_count
== 42, "expected call to underflow\n");
1071 sb2
.gptr
= sb2
.egptr
;
1073 ret
= (int) call_func1(p_streambuf_snextc
, &sb3
);
1074 ok(ret
== 'l', "expected 'l' got '%c'\n", ret
);
1075 ok(sb3
.stored_char
== 'l', "wrong stored character, expected 'l' got %c\n", sb3
.stored_char
);
1076 ok(underflow_count
== 43, "expected call to underflow\n");
1078 ret
= (int) call_func1(p_streambuf_snextc
, &sb3
);
1079 ok(ret
== 't', "expected 't' got '%c'\n", ret
);
1080 ok(sb3
.stored_char
== 't', "wrong stored character, expected 't' got %c\n", sb3
.stored_char
);
1081 ok(underflow_count
== 44, "expected call to underflow\n");
1082 ret
= (int) call_func1(p_streambuf_snextc
, &sb3
);
1083 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1084 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1085 ok(underflow_count
== 45, "expected call to underflow\n");
1087 ret
= (int) call_func1(p_streambuf_snextc
, &sb3
);
1088 ok(ret
== 'o', "expected 'o' got '%c'\n", ret
);
1089 ok(sb3
.stored_char
== 'o', "wrong stored character, expected 'o' got %c\n", sb3
.stored_char
);
1090 ok(underflow_count
== 47, "expected 2 calls to underflow, got %d\n", underflow_count
- 45);
1091 sb3
.stored_char
= EOF
;
1092 ret
= (int) call_func1(p_streambuf_snextc
, &sb3
);
1093 ok(ret
== 'p', "expected 'p' got '%c'\n", ret
);
1094 ok(sb3
.stored_char
== 'p', "wrong stored character, expected 'p' got %c\n", sb3
.stored_char
);
1095 ok(underflow_count
== 49, "expected 2 calls to underflow, got %d\n", underflow_count
- 47);
1099 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb
);
1100 ok(ret
== 'T', "expected 'T' got '%c'\n", ret
);
1101 ok(sb
.gptr
== sb
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 1, sb
.gptr
);
1102 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb
);
1103 ok(ret
== 206, "expected 206 got %d\n", ret
);
1104 ok(sb
.gptr
== sb
.eback
+ 2, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 2, sb
.gptr
);
1106 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb2
);
1107 ok(ret
== 'W', "expected 'W' got '%c'\n", ret
);
1108 ok(sb2
.gptr
== sb2
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb2
.eback
+ 1, sb2
.gptr
);
1109 ok(underflow_count
== 50, "expected call to underflow\n");
1110 sb2
.gptr
= sb2
.egptr
- 1;
1112 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb2
);
1113 ok(ret
== 't', "expected 't' got '%c'\n", ret
);
1114 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
1115 ok(underflow_count
== 50, "no call to underflow expected\n");
1117 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb2
);
1118 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1119 ok(sb2
.gptr
== sb2
.egptr
+ 1, "wrong get pointer, expected %p got %p\n", sb2
.egptr
+ 1, sb2
.gptr
);
1120 ok(underflow_count
== 51, "expected call to underflow\n");
1121 sb2
.gptr
= sb2
.egptr
;
1123 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb3
);
1124 ok(ret
== 'p', "expected 'p' got '%c'\n", ret
);
1125 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1126 ok(underflow_count
== 51, "no call to underflow expected\n");
1127 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb3
);
1128 ok(ret
== 'u', "expected 'u' got '%c'\n", ret
);
1129 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1130 ok(underflow_count
== 52, "expected call to underflow\n");
1132 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb3
);
1133 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1134 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1135 ok(underflow_count
== 53, "expected call to underflow\n");
1137 ret
= (int) call_func1(p_streambuf_sbumpc
, &sb3
);
1138 ok(ret
== 'C', "expected 'C' got '%c'\n", ret
);
1139 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1140 ok(underflow_count
== 54, "expected call to underflow\n");
1143 call_func1(p_streambuf_stossc
, &sb
);
1144 ok(sb
.gptr
== sb
.eback
+ 3, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 3, sb
.gptr
);
1146 call_func1(p_streambuf_stossc
, &sb2
);
1147 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
1148 ok(underflow_count
== 55, "expected call to underflow\n");
1150 call_func1(p_streambuf_stossc
, &sb2
);
1151 ok(sb2
.gptr
== sb2
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb2
.eback
+ 1, sb2
.gptr
);
1152 ok(underflow_count
== 56, "expected call to underflow\n");
1153 sb2
.gptr
= sb2
.egptr
- 1;
1154 call_func1(p_streambuf_stossc
, &sb2
);
1155 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
1156 ok(underflow_count
== 56, "no call to underflow expected\n");
1158 call_func1(p_streambuf_stossc
, &sb3
);
1159 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1160 ok(underflow_count
== 57, "expected call to underflow\n");
1161 sb3
.stored_char
= 'a';
1162 call_func1(p_streambuf_stossc
, &sb3
);
1163 ok(sb3
.stored_char
== EOF
, "wrong stored character, expected EOF got %c\n", sb3
.stored_char
);
1164 ok(underflow_count
== 57, "no call to underflow expected\n");
1167 ret
= (int) call_func2(p_streambuf_pbackfail
, &sb
, 'A');
1168 ok(ret
== 'A', "expected 'A' got '%c'\n", ret
);
1169 ok(sb
.gptr
== sb
.eback
+ 2, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 2, sb
.gptr
);
1170 ok(*sb
.gptr
== 'A', "expected 'A' in the get area, got %c\n", *sb
.gptr
);
1171 ret
= (int) call_func2(p_streambuf_pbackfail
, &sb
, EOF
);
1172 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1173 ok(sb
.gptr
== sb
.eback
+ 1, "wrong get pointer, expected %p got %p\n", sb
.eback
+ 1, sb
.gptr
);
1174 ok((signed char)*sb
.gptr
== EOF
, "expected EOF in the get area, got %c\n", *sb
.gptr
);
1176 ret
= (int) call_func2(p_streambuf_pbackfail
, &sb
, 'Z');
1177 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1178 ok(sb
.gptr
== sb
.eback
, "wrong get pointer, expected %p got %p\n", sb
.eback
, sb
.gptr
);
1179 ok(*sb
.gptr
== 'T', "expected 'T' in the get area, got %c\n", *sb
.gptr
);
1180 ret
= (int) call_func2(p_streambuf_pbackfail
, &sb
, EOF
);
1181 ok(ret
== EOF
, "expected EOF got '%c'\n", ret
);
1182 ok(sb
.gptr
== sb
.eback
, "wrong get pointer, expected %p got %p\n", sb
.eback
, sb
.gptr
);
1183 ok(*sb
.gptr
== 'T', "expected 'T' in the get area, got %c\n", *sb
.gptr
);
1184 sb2
.gptr
= sb2
.egptr
+ 1;
1185 ret
= (int) call_func2(p_streambuf_pbackfail
, &sb2
, 'X');
1186 ok(ret
== 'X', "expected 'X' got '%c'\n", ret
);
1187 ok(sb2
.gptr
== sb2
.egptr
, "wrong get pointer, expected %p got %p\n", sb2
.egptr
, sb2
.gptr
);
1188 ok(*sb2
.gptr
== 'X', "expected 'X' in the get area, got %c\n", *sb2
.gptr
);
1190 SetEvent(lock_arg
.test
[3]);
1191 WaitForSingleObject(thread
, INFINITE
);
1193 call_func1(p_streambuf_dtor
, &sb
);
1194 call_func1(p_streambuf_dtor
, &sb2
);
1195 call_func1(p_streambuf_dtor
, &sb3
);
1196 for (i
= 0; i
< 4; i
++) {
1197 CloseHandle(lock_arg
.lock
[i
]);
1198 CloseHandle(lock_arg
.test
[i
]);
1200 CloseHandle(thread
);
1203 struct filebuf_lock_arg
1205 filebuf
*fb1
, *fb2
, *fb3
;
1210 static DWORD WINAPI
lock_filebuf(void *arg
)
1212 struct filebuf_lock_arg
*lock_arg
= arg
;
1213 call_func1(p_streambuf_lock
, &lock_arg
->fb1
->base
);
1214 call_func1(p_streambuf_lock
, &lock_arg
->fb2
->base
);
1215 call_func1(p_streambuf_lock
, &lock_arg
->fb3
->base
);
1216 SetEvent(lock_arg
->lock
);
1217 WaitForSingleObject(lock_arg
->test
, INFINITE
);
1218 call_func1(p_streambuf_unlock
, &lock_arg
->fb1
->base
);
1219 call_func1(p_streambuf_unlock
, &lock_arg
->fb2
->base
);
1220 call_func1(p_streambuf_unlock
, &lock_arg
->fb3
->base
);
1224 static void test_filebuf(void)
1226 filebuf fb1
, fb2
, fb3
, *pret
;
1227 struct filebuf_lock_arg lock_arg
;
1229 const char filename1
[] = "test1";
1230 const char filename2
[] = "test2";
1231 const char filename3
[] = "test3";
1232 char read_buffer
[16];
1235 memset(&fb1
, 0xab, sizeof(filebuf
));
1236 memset(&fb2
, 0xab, sizeof(filebuf
));
1237 memset(&fb3
, 0xab, sizeof(filebuf
));
1240 call_func2(p_filebuf_fd_ctor
, &fb1
, 1);
1241 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1242 ok(fb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", fb1
.base
.unbuffered
);
1243 ok(fb1
.fd
== 1, "wrong fd, expected 1 got %d\n", fb1
.fd
);
1244 ok(fb1
.close
== 0, "wrong value, expected 0 got %d\n", fb1
.close
);
1245 call_func4(p_filebuf_fd_reserve_ctor
, &fb2
, 4, NULL
, 0);
1246 ok(fb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb2
.base
.allocated
);
1247 ok(fb2
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", fb2
.base
.unbuffered
);
1248 ok(fb2
.fd
== 4, "wrong fd, expected 4 got %d\n", fb2
.fd
);
1249 ok(fb2
.close
== 0, "wrong value, expected 0 got %d\n", fb2
.close
);
1250 call_func1(p_filebuf_ctor
, &fb3
);
1251 ok(fb3
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb3
.base
.allocated
);
1252 ok(fb3
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", fb3
.base
.unbuffered
);
1253 ok(fb3
.fd
== -1, "wrong fd, expected -1 got %d\n", fb3
.fd
);
1254 ok(fb3
.close
== 0, "wrong value, expected 0 got %d\n", fb3
.close
);
1256 lock_arg
.fb1
= &fb1
;
1257 lock_arg
.fb2
= &fb2
;
1258 lock_arg
.fb3
= &fb3
;
1259 lock_arg
.lock
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
1260 ok(lock_arg
.lock
!= NULL
, "CreateEventW failed\n");
1261 lock_arg
.test
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
1262 ok(lock_arg
.test
!= NULL
, "CreateEventW failed\n");
1263 thread
= CreateThread(NULL
, 0, lock_filebuf
, (void*)&lock_arg
, 0, NULL
);
1264 ok(thread
!= NULL
, "CreateThread failed\n");
1265 WaitForSingleObject(lock_arg
.lock
, INFINITE
);
1268 fb1
.base
.do_lock
= 0;
1269 pret
= (filebuf
*) call_func3(p_filebuf_setbuf
, &fb1
, read_buffer
, 16);
1270 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1271 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1272 ok(fb1
.base
.base
== read_buffer
, "wrong buffer, expected %p got %p\n", read_buffer
, fb1
.base
.base
);
1273 ok(fb1
.base
.pbase
== NULL
, "wrong put area, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
1274 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
;
1275 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1276 fb1
.base
.do_lock
= -1;
1277 pret
= (filebuf
*) call_func3(p_filebuf_setbuf
, &fb1
, read_buffer
, 16);
1278 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1279 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1280 ok(fb1
.base
.base
== read_buffer
, "wrong buffer, expected %p got %p\n", read_buffer
, fb1
.base
.base
);
1281 ok(fb1
.base
.pbase
== read_buffer
, "wrong put area, expected %p got %p\n", read_buffer
, fb1
.base
.pbase
);
1282 fb1
.base
.base
= fb1
.base
.ebuf
= NULL
;
1283 fb1
.base
.do_lock
= 0;
1284 pret
= (filebuf
*) call_func3(p_filebuf_setbuf
, &fb1
, read_buffer
, 0);
1285 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1286 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1287 ok(fb1
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", fb1
.base
.unbuffered
);
1288 ok(fb1
.base
.base
== NULL
, "wrong buffer, expected %p got %p\n", NULL
, fb1
.base
.base
);
1289 ok(fb1
.base
.pbase
== read_buffer
, "wrong put area, expected %p got %p\n", read_buffer
, fb1
.base
.pbase
);
1290 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.epptr
= NULL
;
1291 fb1
.base
.unbuffered
= 0;
1292 fb1
.base
.do_lock
= -1;
1295 pret
= call_func2(p_filebuf_attach
, &fb1
, 2);
1296 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1297 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1298 ok(fb1
.fd
== 1, "wrong fd, expected 1 got %d\n", fb1
.fd
);
1300 fb2
.base
.do_lock
= 0;
1301 pret
= call_func2(p_filebuf_attach
, &fb2
, 3);
1302 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1303 ok(fb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb2
.base
.allocated
);
1304 ok(fb2
.fd
== 3, "wrong fd, expected 3 got %d\n", fb2
.fd
);
1305 fb2
.base
.do_lock
= -1;
1306 fb3
.base
.do_lock
= 0;
1307 pret
= call_func2(p_filebuf_attach
, &fb3
, 2);
1308 ok(pret
== &fb3
, "wrong return, expected %p got %p\n", &fb3
, pret
);
1309 ok(fb3
.base
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", fb3
.base
.allocated
);
1310 ok(fb3
.fd
== 2, "wrong fd, expected 2 got %d\n", fb3
.fd
);
1311 fb3
.base
.do_lock
= -1;
1314 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_out
, filebuf_openprot
);
1315 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1317 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
,
1318 OPENMODE_ate
|OPENMODE_nocreate
|OPENMODE_noreplace
|OPENMODE_binary
, filebuf_openprot
);
1319 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1320 ok(fb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", fb1
.base
.allocated
);
1321 fb1
.base
.do_lock
= 0;
1322 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_out
, filebuf_openprot
);
1323 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1324 ok(fb1
.base
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", fb1
.base
.allocated
);
1325 ok(_write(fb1
.fd
, "testing", 7) == 7, "_write failed\n");
1326 pret
= call_func1(p_filebuf_close
, &fb1
);
1327 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1328 ok(fb1
.fd
== -1, "wrong fd, expected -1 got %d\n", fb1
.fd
);
1329 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_out
, filebuf_openprot
);
1330 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1331 ok(_read(fb1
.fd
, read_buffer
, 1) == -1, "file should not be open for reading\n");
1332 pret
= call_func1(p_filebuf_close
, &fb1
);
1333 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1334 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_app
, filebuf_openprot
);
1335 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1336 ok(_read(fb1
.fd
, read_buffer
, 1) == -1, "file should not be open for reading\n");
1337 ok(_write(fb1
.fd
, "testing", 7) == 7, "_write failed\n");
1338 ok(_lseek(fb1
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1339 ok(_write(fb1
.fd
, "append", 6) == 6, "_write failed\n");
1340 pret
= call_func1(p_filebuf_close
, &fb1
);
1341 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1342 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_out
|OPENMODE_ate
, filebuf_openprot
);
1343 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1344 ok(_read(fb1
.fd
, read_buffer
, 1) == -1, "file should not be open for reading\n");
1345 ok(_lseek(fb1
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1346 ok(_write(fb1
.fd
, "ate", 3) == 3, "_write failed\n");
1347 pret
= call_func1(p_filebuf_close
, &fb1
);
1348 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1349 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_in
, filebuf_openprot
);
1350 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1351 ok(_read(fb1
.fd
, read_buffer
, 13) == 13, "read failed\n");
1352 read_buffer
[13] = 0;
1353 ok(!strncmp(read_buffer
, "atetingappend", 13), "wrong contents, expected 'atetingappend' got '%s'\n", read_buffer
);
1354 pret
= call_func1(p_filebuf_close
, &fb1
);
1355 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1356 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_in
|OPENMODE_trunc
, filebuf_openprot
);
1357 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1358 ok(_read(fb1
.fd
, read_buffer
, 1) == 0, "read failed\n");
1359 ok(_write(fb1
.fd
, "file1", 5) == 5, "_write failed\n");
1360 pret
= call_func1(p_filebuf_close
, &fb1
);
1361 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1362 pret
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_in
|OPENMODE_app
, filebuf_openprot
);
1363 ok(pret
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pret
);
1364 ok(_write(fb1
.fd
, "app", 3) == 3, "_write failed\n");
1365 ok(_read(fb1
.fd
, read_buffer
, 1) == 0, "read failed\n");
1366 ok(_lseek(fb1
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1367 ok(_read(fb1
.fd
, read_buffer
, 8) == 8, "read failed\n");
1369 ok(!strncmp(read_buffer
, "file1app", 8), "wrong contents, expected 'file1app' got '%s'\n", read_buffer
);
1370 fb1
.base
.do_lock
= -1;
1373 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_out
|OPENMODE_nocreate
, filebuf_openprot
);
1374 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1375 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_in
|OPENMODE_nocreate
, filebuf_openprot
);
1376 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1377 fb2
.base
.do_lock
= 0;
1378 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_in
, filebuf_openprot
);
1379 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1380 ok(_read(fb1
.fd
, read_buffer
, 1) == 0, "read failed\n");
1381 pret
= call_func1(p_filebuf_close
, &fb2
);
1382 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1383 fb2
.base
.do_lock
= -1;
1384 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_in
|OPENMODE_noreplace
, filebuf_openprot
);
1385 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1386 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_trunc
|OPENMODE_noreplace
, filebuf_openprot
);
1387 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1388 pret
= call_func4(p_filebuf_open
, &fb2
, filename3
, OPENMODE_out
|OPENMODE_nocreate
|OPENMODE_noreplace
, filebuf_openprot
);
1389 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1391 /* open protection*/
1393 fb3
.base
.do_lock
= 0;
1394 pret
= call_func4(p_filebuf_open
, &fb3
, filename3
, OPENMODE_in
|OPENMODE_out
, filebuf_openprot
);
1395 ok(pret
== &fb3
, "wrong return, expected %p got %p\n", &fb3
, pret
);
1396 ok(_write(fb3
.fd
, "You wouldn't\nget this from\nany other guy", 40) == 40, "_write failed\n");
1397 fb2
.base
.do_lock
= 0;
1398 pret
= call_func4(p_filebuf_open
, &fb2
, filename3
, OPENMODE_in
|OPENMODE_out
, filebuf_openprot
);
1399 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1400 pret
= call_func1(p_filebuf_close
, &fb2
);
1401 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1402 fb2
.base
.do_lock
= -1;
1403 pret
= call_func1(p_filebuf_close
, &fb3
);
1404 ok(pret
== &fb3
, "wrong return, expected %p got %p\n", &fb3
, pret
);
1405 pret
= call_func4(p_filebuf_open
, &fb3
, filename3
, OPENMODE_in
, filebuf_sh_none
);
1406 ok(pret
== &fb3
, "wrong return, expected %p got %p\n", &fb3
, pret
);
1407 pret
= call_func4(p_filebuf_open
, &fb2
, filename3
, OPENMODE_in
, filebuf_openprot
);
1408 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1409 fb3
.base
.do_lock
= -1;
1412 fb1
.base
.do_lock
= 0;
1413 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
;
1414 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1415 ret
= (int) call_func2(p_filebuf_setmode
, &fb1
, filebuf_binary
);
1416 ok(ret
== filebuf_text
, "wrong return, expected %d got %d\n", filebuf_text
, ret
);
1417 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1418 ret
= (int) call_func2(p_filebuf_setmode
, &fb1
, filebuf_binary
);
1419 ok(ret
== filebuf_binary
, "wrong return, expected %d got %d\n", filebuf_binary
, ret
);
1420 fb1
.base
.do_lock
= -1;
1421 ret
= (int) call_func2(p_filebuf_setmode
, &fb1
, 0x9000);
1422 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1423 fb2
.base
.do_lock
= 0;
1424 ret
= (int) call_func2(p_filebuf_setmode
, &fb2
, filebuf_text
);
1425 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1426 fb2
.base
.do_lock
= -1;
1429 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1430 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1431 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1432 fb1
.base
.egptr
= fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
+ 256;
1433 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1434 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "We're no strangers to love\n", 27);
1435 ok(ret
== 27, "wrong return, expected 27 got %d\n", ret
);
1436 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1437 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1438 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1439 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1440 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.egptr
= NULL
;
1441 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
;
1442 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1443 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "You know the rules and so do I\n", 31);
1444 ok(ret
== 31, "wrong return, expected 31 got %d\n", ret
);
1445 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1446 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1447 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1448 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1449 fb1
.base
.eback
= fb1
.base
.base
;
1450 fb1
.base
.gptr
= fb1
.base
.base
+ 190;
1451 fb1
.base
.egptr
= fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
+ 256;
1452 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1453 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1454 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1455 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1456 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1457 ok(_tell(fb1
.fd
) == 0, "_tell failed\n");
1458 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
;
1459 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1460 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1461 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
1462 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1463 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1464 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1465 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1466 ok(fb1
.base
.epptr
== NULL
, "wrong put end, expected %p got %p\n", NULL
, fb1
.base
.epptr
);
1467 fb1
.base
.pbase
= fb1
.base
.base
;
1468 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1469 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1470 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
1471 fb1
.base
.pbase
= fb1
.base
.base
;
1472 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1473 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1474 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1475 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
1476 ok(fb1
.base
.epptr
== NULL
, "wrong put end, expected %p got %p\n", NULL
, fb1
.base
.epptr
);
1477 fb1
.base
.eback
= fb1
.base
.base
;
1478 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1479 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1480 ok(fb1
.base
.eback
== NULL
, "wrong get base, expected %p got %p\n", NULL
, fb1
.base
.eback
);
1481 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1482 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1483 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1484 ok(fb1
.base
.gptr
== NULL
, "wrong get base, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1485 fb1
.base
.gptr
= fb1
.base
.base
;
1486 fb1
.base
.egptr
= fb1
.base
.base
+ 100;
1487 fb1
.base
.pbase
= fb1
.base
.base
;
1488 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1489 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1490 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1491 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 100, "wrong get base, expected %p got %p\n", fb1
.base
.base
+ 100, fb1
.base
.egptr
);
1492 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
1493 fb1
.base
.egptr
= NULL
;
1494 ret
= (int) call_func1(p_filebuf_sync
, &fb1
);
1495 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1496 ok(fb1
.base
.gptr
== NULL
, "wrong get base, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1497 ok(fb1
.base
.egptr
== NULL
, "wrong get base, expected %p got %p\n", NULL
, fb1
.base
.egptr
);
1498 ret
= (int) call_func1(p_filebuf_sync
, &fb2
);
1499 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1500 fb3
.base
.eback
= fb3
.base
.base
;
1501 fb3
.base
.gptr
= fb3
.base
.egptr
= fb3
.base
.pbase
= fb3
.base
.pptr
= fb3
.base
.base
+ 256;
1502 fb3
.base
.epptr
= fb3
.base
.ebuf
;
1503 ret
= (int) call_func3(p_streambuf_xsputn
, &fb3
.base
, "A full commitment's what I'm thinking of\n", 41);
1504 ok(ret
== 41, "wrong return, expected 41 got %d\n", ret
);
1505 ret
= (int) call_func1(p_filebuf_sync
, &fb3
);
1506 ok(ret
== -1, "wrong return, expected -1 got %d\n", ret
);
1507 ok(fb3
.base
.gptr
== fb3
.base
.base
+ 256, "wrong get pointer, expected %p got %p\n", fb3
.base
.base
+ 256, fb3
.base
.gptr
);
1508 ok(fb3
.base
.pptr
== fb3
.base
.base
+ 297, "wrong put pointer, expected %p got %p\n", fb3
.base
.base
+ 297, fb3
.base
.pptr
);
1509 fb3
.base
.eback
= fb3
.base
.base
;
1510 fb3
.base
.gptr
= fb3
.base
.egptr
= fb3
.base
.pbase
= fb3
.base
.pptr
= fb3
.base
.base
+ 256;
1511 fb3
.base
.epptr
= fb3
.base
.ebuf
;
1512 ret
= (int) call_func1(p_filebuf_sync
, &fb3
);
1513 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1514 ok(fb3
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb3
.base
.gptr
);
1515 ok(fb3
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb3
.base
.pptr
);
1516 fb3
.base
.eback
= fb3
.base
.base
;
1517 fb3
.base
.gptr
= fb3
.base
.base
+ 216;
1518 fb3
.base
.egptr
= fb3
.base
.pbase
= fb3
.base
.pptr
= fb3
.base
.base
+ 256;
1519 fb3
.base
.epptr
= fb3
.base
.ebuf
;
1520 ok(_read(fb3
.fd
, fb3
.base
.gptr
, 42) == 40, "read failed\n");
1521 ret
= (int) call_func1(p_filebuf_sync
, &fb3
);
1522 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
1523 ok(fb3
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb3
.base
.gptr
);
1524 ok(fb3
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb3
.base
.pptr
);
1525 ok(_tell(fb3
.fd
) == 0, "_tell failed\n");
1526 fb3
.base
.eback
= fb3
.base
.gptr
= fb3
.base
.egptr
= NULL
;
1527 fb3
.base
.pbase
= fb3
.base
.pptr
= fb3
.base
.epptr
= NULL
;
1530 ret
= (int) call_func2(p_filebuf_overflow
, &fb1
, EOF
);
1531 ok(ret
== 1, "wrong return, expected 1 got %d\n", ret
);
1532 fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.epptr
= NULL
;
1533 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1534 fb1
.base
.egptr
= fb1
.base
.ebuf
;
1535 ret
= (int) call_func2(p_filebuf_overflow
, &fb1
, 'a');
1536 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1537 fb1
.base
.gptr
= fb1
.base
.egptr
= fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
+ 256;
1538 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1539 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "I just want to tell you how I'm feeling", 39);
1540 ok(ret
== 39, "wrong return, expected 39 got %d\n", ret
);
1541 ret
= (int) call_func2(p_filebuf_overflow
, &fb1
, '\n');
1542 ok(ret
== 1, "wrong return, expected 1 got %d\n", ret
);
1543 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1544 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
1545 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 1, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 1, fb1
.base
.pptr
);
1546 ok(fb1
.base
.epptr
== fb1
.base
.ebuf
, "wrong put end pointer, expected %p got %p\n", fb1
.base
.ebuf
, fb1
.base
.epptr
);
1547 ok(*fb1
.base
.pbase
== '\n', "wrong character, expected '\\n' got '%c'\n", *fb1
.base
.pbase
);
1548 ret
= (int) call_func2(p_filebuf_overflow
, &fb1
, EOF
);
1549 ok(ret
== 1, "wrong return, expected 1 got %d\n", ret
);
1550 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1551 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
1552 ok(fb1
.base
.pptr
== fb1
.base
.base
, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pptr
);
1553 ok(fb1
.base
.epptr
== fb1
.base
.ebuf
, "wrong put end pointer, expected %p got %p\n", fb1
.base
.ebuf
, fb1
.base
.epptr
);
1554 ret
= (int) call_func2(p_filebuf_overflow
, &fb2
, EOF
);
1555 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1556 fb2
.base
.do_lock
= 0;
1557 pret
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_in
|OPENMODE_out
, filebuf_openprot
);
1558 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1559 fb2
.base
.do_lock
= -1;
1560 ret
= (int) call_func2(p_filebuf_overflow
, &fb2
, EOF
);
1561 ok(ret
== 1, "wrong return, expected 1 got %d\n", ret
);
1564 ret
= (int) call_func1(p_filebuf_underflow
, &fb1
);
1565 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1566 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1567 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1568 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1569 fb1
.base
.egptr
= fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
+ 256;
1570 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1571 *fb1
.base
.gptr
= 'A';
1572 ret
= (int) call_func1(p_filebuf_underflow
, &fb1
);
1573 ok(ret
== 'A', "wrong return, expected 'A' got %d\n", ret
);
1574 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1575 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 256, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 256, fb1
.base
.pptr
);
1576 *fb1
.base
.gptr
= -50;
1577 ret
= (int) call_func1(p_filebuf_underflow
, &fb1
);
1578 ok(ret
== 206, "wrong return, expected 206 got %d\n", ret
);
1579 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1580 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 256, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 256, fb1
.base
.pptr
);
1581 fb1
.base
.gptr
= fb1
.base
.ebuf
;
1582 ret
= (int) call_func1(p_filebuf_underflow
, &fb1
);
1583 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1584 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1585 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1586 ok(_lseek(fb1
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1587 ret
= (int) call_func1(p_filebuf_underflow
, &fb1
);
1588 ok(ret
== 'f', "wrong return, expected 'f' got %d\n", ret
);
1589 ok(fb1
.base
.eback
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.eback
);
1590 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1591 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 106, "wrong get end pointer, expected %p got %p\n", fb1
.base
.base
+ 106, fb1
.base
.egptr
);
1592 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1593 ret
= (int) call_func1(p_filebuf_underflow
, &fb2
);
1594 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1595 ok(_write(fb2
.fd
, "A\n", 2) == 2, "_write failed\n");
1596 ok(_lseek(fb2
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1597 ret
= (int) call_func1(p_filebuf_underflow
, &fb2
);
1598 ok(ret
== 'A', "wrong return, expected 'A' got %d\n", ret
);
1599 ret
= (int) call_func1(p_filebuf_underflow
, &fb2
);
1600 ok(ret
== '\n', "wrong return, expected '\\n' got %d\n", ret
);
1601 ok(_lseek(fb2
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1602 ok(_write(fb2
.fd
, "\xCE\n", 2) == 2, "_write failed\n");
1603 ok(_lseek(fb2
.fd
, 0, SEEK_SET
) == 0, "_lseek failed\n");
1604 ret
= (int) call_func1(p_filebuf_underflow
, &fb2
);
1605 ok(ret
== 206, "wrong return, expected 206 got %d\n", ret
);
1606 fb2
.base
.do_lock
= 0;
1607 pret
= call_func1(p_filebuf_close
, &fb2
);
1608 ok(pret
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pret
);
1609 fb2
.base
.do_lock
= -1;
1610 ret
= (int) call_func1(p_filebuf_underflow
, &fb2
);
1611 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1614 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 5, SEEKDIR_beg
, 0);
1615 ok(ret
== 5, "wrong return, expected 5 got %d\n", ret
);
1616 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1617 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1618 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1619 fb1
.base
.egptr
= fb1
.base
.ebuf
;
1620 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 0, SEEKDIR_beg
, 0);
1621 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1622 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.egptr
= NULL
;
1623 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 10, SEEKDIR_beg
, OPENMODE_in
|OPENMODE_out
);
1624 ok(ret
== 10, "wrong return, expected 10 got %d\n", ret
);
1625 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 0, SEEKDIR_cur
, 0);
1626 ok(ret
== 10, "wrong return, expected 10 got %d\n", ret
);
1627 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 200, SEEKDIR_cur
, OPENMODE_in
);
1628 ok(ret
== 210, "wrong return, expected 210 got %d\n", ret
);
1629 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, -60, SEEKDIR_cur
, 0);
1630 ok(ret
== 150, "wrong return, expected 150 got %d\n", ret
);
1631 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 0, SEEKDIR_end
, 0);
1632 ok(ret
== 106, "wrong return, expected 106 got %d\n", ret
);
1633 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 20, SEEKDIR_end
, OPENMODE_out
);
1634 ok(ret
== 126, "wrong return, expected 126 got %d\n", ret
);
1635 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, -150, SEEKDIR_end
, -1);
1636 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1637 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 10, 3, 0);
1638 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1639 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 16, SEEKDIR_beg
, 0);
1640 ok(ret
== 16, "wrong return, expected 16 got %d\n", ret
);
1643 ret
= (int) call_func2(p_streambuf_pbackfail
, &fb1
.base
, 'B');
1644 ok(ret
== 'B', "wrong return, expected 'B' got %d\n", ret
);
1645 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1646 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1647 ok(_tell(fb1
.fd
) == 15, "_tell failed\n");
1648 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1649 fb1
.base
.egptr
= fb1
.base
.pbase
= fb1
.base
.pptr
= fb1
.base
.base
+ 256;
1650 fb1
.base
.epptr
= fb1
.base
.ebuf
;
1651 ret
= (int) call_func2(p_streambuf_pbackfail
, &fb1
.base
, 'C');
1652 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
1653 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1654 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1655 ok(_tell(fb1
.fd
) == 15, "_tell failed\n");
1656 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1657 fb1
.base
.egptr
= fb1
.base
.base
+ 2;
1658 ret
= (int) call_func2(p_streambuf_pbackfail
, &fb1
.base
, 'C');
1659 ok(ret
== 'C', "wrong return, expected 'C' got %d\n", ret
);
1660 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
1661 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1662 ok(_tell(fb1
.fd
) == 12, "_tell failed\n");
1663 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.base
;
1664 fb1
.base
.egptr
= fb1
.base
.ebuf
;
1665 *fb1
.base
.gptr
++ = 'D';
1666 ret
= (int) call_func2(p_streambuf_pbackfail
, &fb1
.base
, 'C');
1667 ok(ret
== 'C', "wrong return, expected 'C' got %d\n", ret
);
1668 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
1669 ok(*fb1
.base
.gptr
== 'C', "wrong character, expected 'C' got '%c'\n", *fb1
.base
.gptr
);
1670 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
1671 ok(_tell(fb1
.fd
) == 12, "_tell failed\n");
1672 fb1
.base
.eback
= fb1
.base
.gptr
= fb1
.base
.egptr
= NULL
;
1675 pret
= call_func1(p_filebuf_close
, &fb2
);
1676 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1677 fb3
.base
.do_lock
= 0;
1678 pret
= call_func1(p_filebuf_close
, &fb3
);
1679 ok(pret
== &fb3
, "wrong return, expected %p got %p\n", &fb3
, pret
);
1680 ok(fb3
.fd
== -1, "wrong fd, expected -1 got %d\n", fb3
.fd
);
1682 pret
= call_func1(p_filebuf_close
, &fb3
);
1683 ok(pret
== NULL
, "wrong return, expected %p got %p\n", NULL
, pret
);
1684 ok(fb3
.fd
== 5, "wrong fd, expected 5 got %d\n", fb3
.fd
);
1685 fb3
.base
.do_lock
= -1;
1687 SetEvent(lock_arg
.test
);
1688 WaitForSingleObject(thread
, INFINITE
);
1691 call_func1(p_filebuf_dtor
, &fb1
);
1692 ok(fb1
.fd
== -1, "wrong fd, expected -1 got %d\n", fb1
.fd
);
1693 call_func1(p_filebuf_dtor
, &fb2
);
1694 call_func1(p_filebuf_dtor
, &fb3
);
1696 ok(_unlink(filename1
) == 0, "Couldn't unlink file named '%s'\n", filename1
);
1697 ok(_unlink(filename2
) == 0, "Couldn't unlink file named '%s'\n", filename2
);
1698 ok(_unlink(filename3
) == 0, "Couldn't unlink file named '%s'\n", filename3
);
1699 CloseHandle(lock_arg
.lock
);
1700 CloseHandle(lock_arg
.test
);
1701 CloseHandle(thread
);
1704 static void test_strstreambuf(void)
1706 strstreambuf ssb1
, ssb2
;
1708 char buffer
[64], *pbuffer
;
1711 memset(&ssb1
, 0xab, sizeof(strstreambuf
));
1712 memset(&ssb2
, 0xab, sizeof(strstreambuf
));
1714 /* constructors/destructor */
1715 call_func2(p_strstreambuf_dynamic_ctor
, &ssb1
, 64);
1716 ok(ssb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb1
.base
.allocated
);
1717 ok(ssb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb1
.base
.unbuffered
);
1718 ok(ssb1
.dynamic
== 1, "expected 1, got %d\n", ssb1
.dynamic
);
1719 ok(ssb1
.increase
== 64, "expected 64, got %d\n", ssb1
.increase
);
1720 ok(ssb1
.constant
== 0, "expected 0, got %d\n", ssb1
.constant
);
1721 ok(ssb1
.f_alloc
== NULL
, "expected %p, got %p\n", NULL
, ssb1
.f_alloc
);
1722 ok(ssb1
.f_free
== NULL
, "expected %p, got %p\n", NULL
, ssb1
.f_free
);
1723 call_func1(p_strstreambuf_dtor
, &ssb1
);
1724 call_func3(p_strstreambuf_funcs_ctor
, &ssb2
, (allocFunction
)p_operator_new
, p_operator_delete
);
1725 ok(ssb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb2
.base
.allocated
);
1726 ok(ssb2
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb2
.base
.unbuffered
);
1727 ok(ssb2
.dynamic
== 1, "expected 1, got %d\n", ssb2
.dynamic
);
1728 ok(ssb2
.increase
== 1, "expected 1, got %d\n", ssb2
.increase
);
1729 ok(ssb2
.constant
== 0, "expected 0, got %d\n", ssb2
.constant
);
1730 ok(ssb2
.f_alloc
== (allocFunction
)p_operator_new
, "expected %p, got %p\n", p_operator_new
, ssb2
.f_alloc
);
1731 ok(ssb2
.f_free
== p_operator_delete
, "expected %p, got %p\n", p_operator_delete
, ssb2
.f_free
);
1732 call_func1(p_strstreambuf_dtor
, &ssb2
);
1733 memset(&ssb1
, 0xab, sizeof(strstreambuf
));
1734 memset(&ssb2
, 0xab, sizeof(strstreambuf
));
1735 call_func4(p_strstreambuf_buffer_ctor
, &ssb1
, buffer
, 64, buffer
+ 20);
1736 ok(ssb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb1
.base
.allocated
);
1737 ok(ssb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb1
.base
.unbuffered
);
1738 ok(ssb1
.base
.base
== buffer
, "wrong buffer, expected %p got %p\n", buffer
, ssb1
.base
.base
);
1739 ok(ssb1
.base
.ebuf
== buffer
+ 64, "wrong buffer end, expected %p got %p\n", buffer
+ 64, ssb1
.base
.ebuf
);
1740 ok(ssb1
.base
.eback
== buffer
, "wrong get base, expected %p got %p\n", buffer
, ssb1
.base
.eback
);
1741 ok(ssb1
.base
.gptr
== buffer
, "wrong get pointer, expected %p got %p\n", buffer
, ssb1
.base
.gptr
);
1742 ok(ssb1
.base
.egptr
== buffer
+ 20, "wrong get end, expected %p got %p\n", buffer
+ 20, ssb1
.base
.egptr
);
1743 ok(ssb1
.base
.pbase
== buffer
+ 20, "wrong put base, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pbase
);
1744 ok(ssb1
.base
.pptr
== buffer
+ 20, "wrong put pointer, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pptr
);
1745 ok(ssb1
.base
.epptr
== buffer
+ 64, "wrong put end, expected %p got %p\n", buffer
+ 64, ssb1
.base
.epptr
);
1746 ok(ssb1
.dynamic
== 0, "expected 0, got %d\n", ssb1
.dynamic
);
1747 ok(ssb1
.constant
== 1, "expected 1, got %d\n", ssb1
.constant
);
1748 call_func1(p_strstreambuf_dtor
, &ssb1
);
1749 strcpy(buffer
, "Test");
1750 call_func4(p_strstreambuf_buffer_ctor
, &ssb2
, buffer
, 0, buffer
+ 20);
1751 ok(ssb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb2
.base
.allocated
);
1752 ok(ssb2
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb2
.base
.unbuffered
);
1753 ok(ssb2
.base
.base
== buffer
, "wrong buffer, expected %p got %p\n", buffer
, ssb2
.base
.base
);
1754 ok(ssb2
.base
.ebuf
== buffer
+ 4, "wrong buffer end, expected %p got %p\n", buffer
+ 4, ssb2
.base
.ebuf
);
1755 ok(ssb2
.base
.eback
== buffer
, "wrong get base, expected %p got %p\n", buffer
, ssb2
.base
.eback
);
1756 ok(ssb2
.base
.gptr
== buffer
, "wrong get pointer, expected %p got %p\n", buffer
, ssb2
.base
.gptr
);
1757 ok(ssb2
.base
.egptr
== buffer
+ 20, "wrong get end, expected %p got %p\n", buffer
+ 20, ssb2
.base
.egptr
);
1758 ok(ssb2
.base
.pbase
== buffer
+ 20, "wrong put base, expected %p got %p\n", buffer
+ 20, ssb2
.base
.pbase
);
1759 ok(ssb2
.base
.pptr
== buffer
+ 20, "wrong put pointer, expected %p got %p\n", buffer
+ 20, ssb2
.base
.pptr
);
1760 ok(ssb2
.base
.epptr
== buffer
+ 4, "wrong put end, expected %p got %p\n", buffer
+ 4, ssb2
.base
.epptr
);
1761 ok(ssb2
.dynamic
== 0, "expected 0, got %d\n", ssb2
.dynamic
);
1762 ok(ssb2
.constant
== 1, "expected 1, got %d\n", ssb2
.constant
);
1763 call_func1(p_strstreambuf_dtor
, &ssb2
);
1764 memset(&ssb1
, 0xab, sizeof(strstreambuf
));
1765 memset(&ssb2
, 0xab, sizeof(strstreambuf
));
1766 call_func4(p_strstreambuf_buffer_ctor
, &ssb1
, NULL
, 16, buffer
+ 20);
1767 ok(ssb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb1
.base
.allocated
);
1768 ok(ssb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb1
.base
.unbuffered
);
1769 ok(ssb1
.base
.base
== NULL
, "wrong buffer, expected %p got %p\n", NULL
, ssb1
.base
.base
);
1770 ok(ssb1
.base
.ebuf
== (char*)16, "wrong buffer end, expected %p got %p\n", (char*)16, ssb1
.base
.ebuf
);
1771 ok(ssb1
.base
.eback
== NULL
, "wrong get base, expected %p got %p\n", NULL
, ssb1
.base
.eback
);
1772 ok(ssb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, ssb1
.base
.gptr
);
1773 ok(ssb1
.base
.egptr
== buffer
+ 20, "wrong get end, expected %p got %p\n", buffer
+ 20, ssb1
.base
.egptr
);
1774 ok(ssb1
.base
.pbase
== buffer
+ 20, "wrong put base, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pbase
);
1775 ok(ssb1
.base
.pptr
== buffer
+ 20, "wrong put pointer, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pptr
);
1776 ok(ssb1
.base
.epptr
== (char*)16, "wrong put end, expected %p got %p\n", (char*)16, ssb1
.base
.epptr
);
1777 ok(ssb1
.dynamic
== 0, "expected 0, got %d\n", ssb1
.dynamic
);
1778 ok(ssb1
.constant
== 1, "expected 1, got %d\n", ssb1
.constant
);
1779 call_func1(p_strstreambuf_dtor
, &ssb1
);
1780 call_func4(p_strstreambuf_buffer_ctor
, &ssb2
, buffer
, 0, NULL
);
1781 ok(ssb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb2
.base
.allocated
);
1782 ok(ssb2
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb2
.base
.unbuffered
);
1783 ok(ssb2
.base
.base
== buffer
, "wrong buffer, expected %p got %p\n", buffer
, ssb2
.base
.base
);
1784 ok(ssb2
.base
.ebuf
== buffer
+ 4, "wrong buffer end, expected %p got %p\n", buffer
+ 4, ssb2
.base
.ebuf
);
1785 ok(ssb2
.base
.eback
== buffer
, "wrong get base, expected %p got %p\n", buffer
, ssb2
.base
.eback
);
1786 ok(ssb2
.base
.gptr
== buffer
, "wrong get pointer, expected %p got %p\n", buffer
, ssb2
.base
.gptr
);
1787 ok(ssb2
.base
.egptr
== buffer
+ 4, "wrong get end, expected %p got %p\n", buffer
+ 4, ssb2
.base
.egptr
);
1788 ok(ssb2
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, ssb2
.base
.pbase
);
1789 ok(ssb2
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, ssb2
.base
.pptr
);
1790 ok(ssb2
.base
.epptr
== NULL
, "wrong put end, expected %p got %p\n", NULL
, ssb2
.base
.epptr
);
1791 ok(ssb2
.dynamic
== 0, "expected 0, got %d\n", ssb2
.dynamic
);
1792 ok(ssb2
.constant
== 1, "expected 1, got %d\n", ssb2
.constant
);
1793 call_func1(p_strstreambuf_dtor
, &ssb2
);
1794 memset(&ssb1
, 0xab, sizeof(strstreambuf
));
1795 memset(&ssb2
, 0xab, sizeof(strstreambuf
));
1796 call_func4(p_strstreambuf_buffer_ctor
, &ssb1
, buffer
, -5, buffer
+ 20);
1797 ok(ssb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb1
.base
.allocated
);
1798 ok(ssb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb1
.base
.unbuffered
);
1799 ok(ssb1
.base
.base
== buffer
, "wrong buffer, expected %p got %p\n", buffer
, ssb1
.base
.base
);
1800 ok(ssb1
.base
.ebuf
== buffer
+ 0x7fffffff || ssb1
.base
.ebuf
== (char*)-1,
1801 "wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer
, ssb1
.base
.ebuf
);
1802 ok(ssb1
.base
.eback
== buffer
, "wrong get base, expected %p got %p\n", buffer
, ssb1
.base
.eback
);
1803 ok(ssb1
.base
.gptr
== buffer
, "wrong get pointer, expected %p got %p\n", buffer
, ssb1
.base
.gptr
);
1804 ok(ssb1
.base
.egptr
== buffer
+ 20, "wrong get end, expected %p got %p\n", buffer
+ 20, ssb1
.base
.egptr
);
1805 ok(ssb1
.base
.pbase
== buffer
+ 20, "wrong put base, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pbase
);
1806 ok(ssb1
.base
.pptr
== buffer
+ 20, "wrong put pointer, expected %p got %p\n", buffer
+ 20, ssb1
.base
.pptr
);
1807 ok(ssb1
.base
.epptr
== buffer
+ 0x7fffffff || ssb1
.base
.epptr
== (char*)-1,
1808 "wrong put end, expected %p + 0x7fffffff or -1, got %p\n", buffer
, ssb1
.base
.epptr
);
1809 ok(ssb1
.dynamic
== 0, "expected 0, got %d\n", ssb1
.dynamic
);
1810 ok(ssb1
.constant
== 1, "expected 1, got %d\n", ssb1
.constant
);
1811 call_func1(p_strstreambuf_ctor
, &ssb2
);
1812 ok(ssb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", ssb2
.base
.allocated
);
1813 ok(ssb2
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", ssb2
.base
.unbuffered
);
1814 ok(ssb2
.dynamic
== 1, "expected 1, got %d\n", ssb2
.dynamic
);
1815 ok(ssb2
.increase
== 1, "expected 1, got %d\n", ssb2
.increase
);
1816 ok(ssb2
.constant
== 0, "expected 0, got %d\n", ssb2
.constant
);
1817 ok(ssb2
.f_alloc
== NULL
, "expected %p, got %p\n", NULL
, ssb2
.f_alloc
);
1818 ok(ssb2
.f_free
== NULL
, "expected %p, got %p\n", NULL
, ssb2
.f_free
);
1821 call_func2(p_strstreambuf_freeze
, &ssb1
, 0);
1822 ok(ssb1
.dynamic
== 0, "expected 0, got %d\n", ssb1
.dynamic
);
1824 call_func2(p_strstreambuf_freeze
, &ssb1
, 0);
1825 ok(ssb1
.dynamic
== 1, "expected 1, got %d\n", ssb1
.dynamic
);
1826 call_func2(p_strstreambuf_freeze
, &ssb1
, 3);
1827 ok(ssb1
.dynamic
== 0, "expected 0, got %d\n", ssb1
.dynamic
);
1829 call_func2(p_strstreambuf_freeze
, &ssb2
, 5);
1830 ok(ssb2
.dynamic
== 0, "expected 0, got %d\n", ssb2
.dynamic
);
1831 call_func2(p_strstreambuf_freeze
, &ssb2
, 0);
1832 ok(ssb2
.dynamic
== 1, "expected 1, got %d\n", ssb2
.dynamic
);
1837 ret
= (int) call_func1(p_strstreambuf_doallocate
, &ssb2
);
1838 ok(ret
== 1, "return value %d\n", ret
);
1839 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 5, "expected %p, got %p\n", ssb2
.base
.base
+ 5, ssb2
.base
.ebuf
);
1840 ssb2
.base
.eback
= ssb2
.base
.base
;
1841 ssb2
.base
.gptr
= ssb2
.base
.base
+ 2;
1842 ssb2
.base
.egptr
= ssb2
.base
.base
+ 4;
1843 strcpy(ssb2
.base
.base
, "Check");
1844 ret
= (int) call_func1(p_strstreambuf_doallocate
, &ssb2
);
1845 ok(ret
== 1, "return value %d\n", ret
);
1846 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 10, "expected %p, got %p\n", ssb2
.base
.base
+ 10, ssb2
.base
.ebuf
);
1847 ok(ssb2
.base
.eback
== ssb2
.base
.base
, "wrong get base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.eback
);
1848 ok(ssb2
.base
.gptr
== ssb2
.base
.base
+ 2, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
+ 2, ssb2
.base
.gptr
);
1849 ok(ssb2
.base
.egptr
== ssb2
.base
.base
+ 4, "wrong get end, expected %p got %p\n", ssb2
.base
.base
+ 4, ssb2
.base
.egptr
);
1850 ok(!strncmp(ssb2
.base
.base
, "Check", 5), "strings are not equal\n");
1851 ssb2
.base
.pbase
= ssb2
.base
.pptr
= ssb2
.base
.base
+ 4;
1852 ssb2
.base
.epptr
= ssb2
.base
.ebuf
;
1854 ret
= (int) call_func1(p_strstreambuf_doallocate
, &ssb2
);
1855 ok(ret
== 1, "return value %d\n", ret
);
1856 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 11, "expected %p, got %p\n", ssb2
.base
.base
+ 11, ssb2
.base
.ebuf
);
1857 ok(ssb2
.base
.pbase
== ssb2
.base
.base
+ 4, "wrong put base, expected %p got %p\n", ssb2
.base
.base
+ 4, ssb2
.base
.pbase
);
1858 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 4, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 4, ssb2
.base
.pptr
);
1859 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 10, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 10, ssb2
.base
.epptr
);
1860 ok(!strncmp(ssb2
.base
.base
, "Check", 5), "strings are not equal\n");
1864 pret
= call_func3(p_strstreambuf_setbuf
, &ssb1
, buffer
+ 16, 16);
1865 ok(pret
== &ssb1
.base
, "expected %p got %p\n", &ssb1
.base
, pret
);
1866 ok(ssb1
.base
.base
== buffer
, "wrong buffer, expected %p got %p\n", buffer
, ssb1
.base
.base
);
1867 ok(ssb1
.increase
== 16, "expected 16, got %d\n", ssb1
.increase
);
1868 pret
= call_func3(p_strstreambuf_setbuf
, &ssb2
, NULL
, 2);
1869 ok(pret
== &ssb2
.base
, "expected %p got %p\n", &ssb2
.base
, pret
);
1870 ok(ssb2
.increase
== 2, "expected 2, got %d\n", ssb2
.increase
);
1871 pret
= call_func3(p_strstreambuf_setbuf
, &ssb2
, buffer
, 0);
1872 ok(pret
== &ssb2
.base
, "expected %p got %p\n", &ssb2
.base
, pret
);
1873 ok(ssb2
.increase
== 2, "expected 2, got %d\n", ssb2
.increase
);
1874 pret
= call_func3(p_strstreambuf_setbuf
, &ssb2
, NULL
, -2);
1875 ok(pret
== &ssb2
.base
, "expected %p got %p\n", &ssb2
.base
, pret
);
1876 ok(ssb2
.increase
== -2, "expected -2, got %d\n", ssb2
.increase
);
1879 ssb1
.base
.epptr
= ssb1
.base
.ebuf
= ssb1
.base
.base
+ 64;
1880 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb1
);
1881 ok(ret
== 'T', "expected 'T' got %d\n", ret
);
1882 ssb1
.base
.gptr
= ssb1
.base
.egptr
;
1883 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb1
);
1884 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1885 ret
= (int) call_func3(p_streambuf_xsputn
, &ssb1
.base
, "Gotta make you understand", 5);
1886 ok(ret
== 5, "expected 5 got %d\n", ret
);
1887 ok(ssb1
.base
.pptr
== buffer
+ 25, "wrong put pointer, expected %p got %p\n", buffer
+ 25, ssb1
.base
.pptr
);
1888 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb1
);
1889 ok(ret
== 'G', "expected 'G' got %d\n", ret
);
1890 ok(ssb1
.base
.egptr
== buffer
+ 25, "wrong get end, expected %p got %p\n", buffer
+ 25, ssb1
.base
.egptr
);
1891 *ssb1
.base
.gptr
= -50;
1892 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb1
);
1893 ok(ret
== 206, "expected 206 got %d\n", ret
);
1894 ok(ssb1
.base
.egptr
== buffer
+ 25, "wrong get end, expected %p got %p\n", buffer
+ 25, ssb1
.base
.egptr
);
1895 ssb1
.base
.gptr
= ssb1
.base
.egptr
= ssb1
.base
.pptr
= ssb1
.base
.epptr
;
1896 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb1
);
1897 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1898 ssb2
.base
.eback
= ssb2
.base
.gptr
= ssb2
.base
.egptr
= NULL
;
1899 ssb2
.base
.pbase
= ssb2
.base
.pptr
= ssb2
.base
.epptr
= NULL
;
1900 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1901 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1902 ssb2
.base
.pbase
= ssb2
.base
.pptr
= ssb2
.base
.base
;
1903 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1904 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1905 ok(ssb2
.base
.eback
== ssb2
.base
.base
, "wrong get base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.eback
);
1906 ok(ssb2
.base
.gptr
== ssb2
.base
.base
, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.gptr
);
1907 ok(ssb2
.base
.egptr
== ssb2
.base
.base
, "wrong get end, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.egptr
);
1908 ssb2
.base
.pptr
= ssb2
.base
.base
+ 3;
1909 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1910 ok(ret
== 'C', "expected 'C' got %d\n", ret
);
1911 ok(ssb2
.base
.eback
== ssb2
.base
.base
, "wrong get base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.eback
);
1912 ok(ssb2
.base
.gptr
== ssb2
.base
.base
, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.gptr
);
1913 ok(ssb2
.base
.egptr
== ssb2
.base
.base
+ 3, "wrong get end, expected %p got %p\n", ssb2
.base
.base
+ 3, ssb2
.base
.egptr
);
1914 ssb2
.base
.gptr
= ssb2
.base
.base
+ 2;
1915 ssb2
.base
.egptr
= NULL
;
1916 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1917 ok(ret
== 'e', "expected 'e' got %d\n", ret
);
1918 ok(ssb2
.base
.eback
== ssb2
.base
.base
, "wrong get base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.eback
);
1919 ok(ssb2
.base
.gptr
== ssb2
.base
.base
+ 2, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.gptr
);
1920 ok(ssb2
.base
.egptr
== ssb2
.base
.base
+ 3, "wrong get end, expected %p got %p\n", ssb2
.base
.base
+ 3, ssb2
.base
.egptr
);
1921 ssb2
.base
.eback
= ssb2
.base
.egptr
= ssb2
.base
.base
+ 1;
1922 ssb2
.base
.gptr
= ssb2
.base
.base
+ 3;
1923 ssb2
.base
.pptr
= ssb2
.base
.base
+ 5;
1924 *(ssb2
.base
.base
+ 2) = -50;
1925 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1926 ok(ret
== 206, "expected 206 got %d\n", ret
);
1927 ok(ssb2
.base
.eback
== ssb2
.base
.base
, "wrong get base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.eback
);
1928 ok(ssb2
.base
.gptr
== ssb2
.base
.base
+ 2, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.gptr
);
1929 ok(ssb2
.base
.egptr
== ssb2
.base
.base
+ 5, "wrong get end, expected %p got %p\n", ssb2
.base
.base
+ 5, ssb2
.base
.egptr
);
1930 ssb2
.base
.eback
= ssb2
.base
.base
;
1931 ssb2
.base
.gptr
= ssb2
.base
.egptr
= ssb2
.base
.ebuf
;
1932 ssb2
.base
.pbase
= ssb2
.base
.pptr
= NULL
;
1933 ret
= (int) call_func1(p_strstreambuf_underflow
, &ssb2
);
1934 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1937 ssb1
.base
.pptr
= ssb1
.base
.epptr
- 1;
1938 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb1
, EOF
);
1939 ok(ret
== 1, "expected 1 got %d\n", ret
);
1940 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb1
, 'A');
1941 ok(ret
== 1, "expected 1 got %d\n", ret
);
1942 ok(ssb1
.base
.pptr
== ssb1
.base
.epptr
, "wrong put pointer, expected %p got %p\n", ssb1
.base
.epptr
, ssb1
.base
.pptr
);
1943 ok(*(ssb1
.base
.pptr
- 1) == 'A', "expected 'A' got %d\n", *(ssb1
.base
.pptr
- 1));
1944 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb1
, 'B');
1945 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1946 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb1
, EOF
);
1947 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1949 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'C');
1950 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
1952 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'C');
1953 ok(ret
== 1, "expected 1 got %d\n", ret
);
1954 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 12, "expected %p got %p\n", ssb2
.base
.base
+ 12, ssb2
.base
.ebuf
);
1955 ok(ssb2
.base
.gptr
== ssb2
.base
.base
+ 11, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
+ 11, ssb2
.base
.gptr
);
1956 ok(ssb2
.base
.pbase
== ssb2
.base
.base
+ 11, "wrong put base, expected %p got %p\n", ssb2
.base
.base
+ 11, ssb2
.base
.pbase
);
1957 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 12, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 12, ssb2
.base
.pptr
);
1958 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 12, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 12, ssb2
.base
.epptr
);
1959 ok(*(ssb2
.base
.pptr
- 1) == 'C', "expected 'C' got %d\n", *(ssb2
.base
.pptr
- 1));
1961 ssb2
.base
.eback
= ssb2
.base
.gptr
= ssb2
.base
.egptr
= NULL
;
1962 ssb2
.base
.pbase
= ssb2
.base
.pptr
= ssb2
.base
.epptr
= NULL
;
1963 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'D');
1964 ok(ret
== 1, "expected 1 got %d\n", ret
);
1965 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 16, "expected %p got %p\n", ssb2
.base
.base
+ 16, ssb2
.base
.ebuf
);
1966 ok(ssb2
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, ssb2
.base
.gptr
);
1967 ok(ssb2
.base
.pbase
== ssb2
.base
.base
, "wrong put base, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.pbase
);
1968 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 1, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 1, ssb2
.base
.pptr
);
1969 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 16, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 16, ssb2
.base
.epptr
);
1970 ok(*(ssb2
.base
.pptr
- 1) == 'D', "expected 'D' got %d\n", *(ssb2
.base
.pptr
- 1));
1971 ssb2
.base
.pbase
= ssb2
.base
.base
+ 3;
1972 ssb2
.base
.pptr
= ssb2
.base
.epptr
+ 5;
1973 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'E');
1974 ok(ret
== 1, "expected 1 got %d\n", ret
);
1975 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 20, "expected %p got %p\n", ssb2
.base
.base
+ 20, ssb2
.base
.ebuf
);
1976 ok(ssb2
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, ssb2
.base
.gptr
);
1977 ok(ssb2
.base
.pbase
== ssb2
.base
.base
+ 3, "wrong put base, expected %p got %p\n", ssb2
.base
.base
+ 3, ssb2
.base
.pbase
);
1978 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 22, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 22, ssb2
.base
.pptr
);
1979 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 20, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 20, ssb2
.base
.epptr
);
1980 ok(*(ssb2
.base
.pptr
- 1) == 'E', "expected 'E' got %d\n", *(ssb2
.base
.pptr
- 1));
1981 ssb2
.base
.egptr
= ssb2
.base
.base
+ 2;
1982 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'F');
1983 ok(ret
== 1, "expected 1 got %d\n", ret
);
1984 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 24, "expected %p got %p\n", ssb2
.base
.base
+ 24, ssb2
.base
.ebuf
);
1985 ok(ssb2
.base
.gptr
!= NULL
, "wrong get pointer, expected != NULL\n");
1986 ok(ssb2
.base
.pbase
== ssb2
.base
.base
+ 3, "wrong put base, expected %p got %p\n", ssb2
.base
.base
+ 3, ssb2
.base
.pbase
);
1987 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 23, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 23, ssb2
.base
.pptr
);
1988 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 24, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 24, ssb2
.base
.epptr
);
1989 ok(*(ssb2
.base
.pptr
- 1) == 'F', "expected 'F' got %d\n", *(ssb2
.base
.pptr
- 1));
1990 ssb2
.base
.eback
= ssb2
.base
.gptr
= ssb2
.base
.base
;
1991 ssb2
.base
.epptr
= NULL
;
1992 ret
= (int) call_func2(p_strstreambuf_overflow
, &ssb2
, 'G');
1993 ok(ret
== 1, "expected 1 got %d\n", ret
);
1994 ok(ssb2
.base
.ebuf
== ssb2
.base
.base
+ 28, "expected %p got %p\n", ssb2
.base
.base
+ 28, ssb2
.base
.ebuf
);
1995 ok(ssb2
.base
.gptr
== ssb2
.base
.base
, "wrong get pointer, expected %p got %p\n", ssb2
.base
.base
, ssb2
.base
.gptr
);
1996 ok(ssb2
.base
.pbase
== ssb2
.base
.base
+ 2, "wrong put base, expected %p got %p\n", ssb2
.base
.base
+ 2, ssb2
.base
.pbase
);
1997 ok(ssb2
.base
.pptr
== ssb2
.base
.base
+ 3, "wrong put pointer, expected %p got %p\n", ssb2
.base
.base
+ 3, ssb2
.base
.pptr
);
1998 ok(ssb2
.base
.epptr
== ssb2
.base
.base
+ 28, "wrong put end, expected %p got %p\n", ssb2
.base
.base
+ 28, ssb2
.base
.epptr
);
1999 ok(*(ssb2
.base
.pptr
- 1) == 'G', "expected 'G' got %d\n", *(ssb2
.base
.pptr
- 1));
2002 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 0, SEEKDIR_beg
, OPENMODE_in
);
2003 ok(ret
== 0, "expected 0 got %d\n", ret
);
2004 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
, ssb1
.base
.gptr
);
2005 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 3, SEEKDIR_beg
, OPENMODE_in
);
2006 ok(ret
== 3, "expected 3 got %d\n", ret
);
2007 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 3, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 3, ssb1
.base
.gptr
);
2008 ssb1
.base
.egptr
= ssb1
.base
.pbase
;
2009 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 25, SEEKDIR_beg
, OPENMODE_in
);
2010 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2011 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 3, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 3, ssb1
.base
.gptr
);
2012 ssb1
.base
.gptr
= ssb1
.base
.egptr
;
2013 ssb1
.base
.pptr
= ssb1
.base
.pbase
+ 10;
2014 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 25, SEEKDIR_beg
, OPENMODE_in
);
2015 ok(ret
== 25, "expected 25 got %d\n", ret
);
2016 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 25, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 25, ssb1
.base
.gptr
);
2017 ok(ssb1
.base
.egptr
== ssb1
.base
.pptr
, "wrong get end, expected %p got %p\n", ssb1
.base
.pptr
, ssb1
.base
.egptr
);
2018 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -24, SEEKDIR_cur
, OPENMODE_in
);
2019 ok(ret
== 1, "expected 1 got %d\n", ret
);
2020 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 1, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 1, ssb1
.base
.gptr
);
2021 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -5, SEEKDIR_cur
, OPENMODE_in
);
2022 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2023 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 1, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 1, ssb1
.base
.gptr
);
2024 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 0, SEEKDIR_end
, OPENMODE_in
);
2025 ok(ret
== 30, "expected 30 got %d\n", ret
);
2026 ok(ssb1
.base
.gptr
== ssb1
.base
.egptr
, "wrong get pointer, expected %p got %p\n", ssb1
.base
.egptr
, ssb1
.base
.gptr
);
2027 ssb1
.base
.gptr
= ssb1
.base
.eback
;
2028 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -2, SEEKDIR_end
, OPENMODE_in
);
2029 ok(ret
== 28, "expected 28 got %d\n", ret
);
2030 ok(ssb1
.base
.gptr
== ssb1
.base
.egptr
- 2, "wrong get pointer, expected %p got %p\n", ssb1
.base
.egptr
- 2, ssb1
.base
.gptr
);
2031 ssb1
.base
.gptr
= ssb1
.base
.egptr
;
2032 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -5, SEEKDIR_end
, OPENMODE_in
);
2033 ok(ret
== 25, "expected 25 got %d\n", ret
);
2034 ok(ssb1
.base
.gptr
== ssb1
.base
.egptr
- 5, "wrong get pointer, expected %p got %p\n", ssb1
.base
.egptr
- 5, ssb1
.base
.gptr
);
2035 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 1, SEEKDIR_end
, OPENMODE_in
);
2036 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2037 ok(ssb1
.base
.gptr
== ssb1
.base
.egptr
- 5, "wrong get pointer, expected %p got %p\n", ssb1
.base
.egptr
- 5, ssb1
.base
.gptr
);
2038 ssb1
.base
.gptr
= ssb1
.base
.egptr
;
2039 ssb1
.base
.pptr
= ssb1
.base
.egptr
+ 5;
2040 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 1, SEEKDIR_end
, OPENMODE_in
);
2041 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2042 ok(ssb1
.base
.gptr
== ssb1
.base
.egptr
- 5, "wrong get pointer, expected %p got %p\n", ssb1
.base
.egptr
- 5, ssb1
.base
.gptr
);
2043 ok(ssb1
.base
.egptr
== ssb1
.base
.pptr
, "wrong get end, expected %p got %p\n", ssb1
.base
.pptr
, ssb1
.base
.egptr
);
2044 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 3, SEEKDIR_beg
, OPENMODE_out
);
2045 ok(ret
== 3, "expected 3 got %d\n", ret
);
2046 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 3, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 3, ssb1
.base
.pptr
);
2047 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -2, SEEKDIR_beg
, OPENMODE_out
);
2048 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2049 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 3, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 3, ssb1
.base
.pptr
);
2050 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 50, SEEKDIR_beg
, OPENMODE_out
);
2051 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2052 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 3, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 3, ssb1
.base
.pptr
);
2053 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 5, SEEKDIR_cur
, OPENMODE_out
);
2054 ok(ret
== 8, "expected 8 got %d\n", ret
);
2055 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 8, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 8, ssb1
.base
.pptr
);
2056 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, -2, SEEKDIR_end
, OPENMODE_out
);
2057 ok(ret
== 42, "expected 42 got %d\n", ret
);
2058 ok(ssb1
.base
.pptr
== ssb1
.base
.epptr
- 2, "wrong put pointer, expected %p got %p\n", ssb1
.base
.epptr
- 2, ssb1
.base
.pptr
);
2059 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 0, SEEKDIR_end
, OPENMODE_out
);
2060 ok(ret
== 44, "expected 44 got %d\n", ret
);
2061 ok(ssb1
.base
.pptr
== ssb1
.base
.epptr
, "wrong put pointer, expected %p got %p\n", ssb1
.base
.epptr
, ssb1
.base
.pptr
);
2062 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 5, SEEKDIR_beg
, OPENMODE_in
|OPENMODE_out
);
2063 ok(ret
== 5, "expected 5 got %d\n", ret
);
2064 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 5, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 5, ssb1
.base
.gptr
);
2065 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 5, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 5, ssb1
.base
.pptr
);
2066 ssb1
.base
.egptr
= ssb1
.base
.pbase
;
2067 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 21, SEEKDIR_beg
, OPENMODE_in
|OPENMODE_out
);
2068 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2069 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 5, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 5, ssb1
.base
.gptr
);
2070 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 5, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 5, ssb1
.base
.pptr
);
2071 ssb1
.base
.egptr
= ssb1
.base
.epptr
;
2072 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 50, SEEKDIR_beg
, OPENMODE_in
|OPENMODE_out
);
2073 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2074 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 50, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 50, ssb1
.base
.gptr
);
2075 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 5, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 5, ssb1
.base
.pptr
);
2076 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb1
, 2, SEEKDIR_cur
, OPENMODE_in
|OPENMODE_out
);
2077 ok(ret
== 7, "expected 7 got %d\n", ret
);
2078 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 52, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 52, ssb1
.base
.gptr
);
2079 ok(ssb1
.base
.pptr
== ssb1
.base
.pbase
+ 7, "wrong put pointer, expected %p got %p\n", ssb1
.base
.pbase
+ 7, ssb1
.base
.pptr
);
2080 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb2
, 0, SEEKDIR_beg
, OPENMODE_in
|OPENMODE_out
);
2081 ok(ret
== 0, "expected 0 got %d\n", ret
);
2082 ok(ssb2
.base
.gptr
== ssb2
.base
.eback
, "wrong get pointer, expected %p got %p\n", ssb2
.base
.eback
, ssb2
.base
.gptr
);
2083 ok(ssb2
.base
.pptr
== ssb2
.base
.pbase
, "wrong put pointer, expected %p got %p\n", ssb2
.base
.pbase
, ssb2
.base
.pptr
);
2084 ssb2
.base
.gptr
= ssb2
.base
.egptr
;
2085 ssb2
.base
.pptr
+= 10;
2086 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb2
, 5, SEEKDIR_cur
, OPENMODE_in
|OPENMODE_out
);
2087 ok(ret
== 15, "expected 15 got %d\n", ret
);
2088 ok(ssb2
.base
.gptr
== ssb2
.base
.eback
+ 7, "wrong get pointer, expected %p got %p\n", ssb2
.base
.eback
+ 7, ssb2
.base
.gptr
);
2089 ok(ssb2
.base
.egptr
== ssb2
.base
.eback
+ 12, "wrong get end, expected %p got %p\n", ssb2
.base
.eback
+ 12, ssb2
.base
.egptr
);
2090 ok(ssb2
.base
.pptr
== ssb2
.base
.pbase
+ 15, "wrong put pointer, expected %p got %p\n", ssb2
.base
.pbase
+ 15, ssb2
.base
.pptr
);
2091 ssb2
.base
.pptr
= ssb2
.base
.epptr
;
2092 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb2
, -1, SEEKDIR_cur
, OPENMODE_in
|OPENMODE_out
);
2093 ok(ret
== 25, "expected 25 got %d\n", ret
);
2094 ok(ssb2
.base
.gptr
== ssb2
.base
.eback
+ 6, "wrong get pointer, expected %p got %p\n", ssb2
.base
.eback
+ 6, ssb2
.base
.gptr
);
2095 ok(ssb2
.base
.pptr
== ssb2
.base
.pbase
+ 25, "wrong put pointer, expected %p got %p\n", ssb2
.base
.pbase
+ 25, ssb2
.base
.pptr
);
2096 pbuffer
= ssb2
.base
.pbase
;
2097 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb2
, 50, SEEKDIR_beg
, OPENMODE_out
);
2098 ok(ret
== 50, "expected 50 got %d\n", ret
);
2099 ok(ssb2
.base
.gptr
== ssb2
.base
.eback
+ 6, "wrong get pointer, expected %p got %p\n", ssb2
.base
.eback
+ 6, ssb2
.base
.gptr
);
2100 ok(ssb2
.base
.pptr
== pbuffer
+ 50, "wrong put pointer, expected %p got %p\n", pbuffer
+ 50, ssb2
.base
.pptr
);
2101 ok(ssb2
.increase
== 50, "expected 50 got %d\n", ssb2
.increase
);
2102 ssb2
.base
.epptr
= NULL
;
2104 ret
= (int) call_func4(p_strstreambuf_seekoff
, &ssb2
, 0, SEEKDIR_end
, OPENMODE_out
);
2105 ok(ret
== 74, "expected 74 got %d\n", ret
);
2106 ok(ssb2
.base
.pptr
== ssb2
.base
.epptr
, "wrong put pointer, expected %p got %p\n", ssb2
.base
.epptr
, ssb2
.base
.pptr
);
2109 *(ssb1
.base
.gptr
-1) = 'A';
2110 ret
= (int) call_func2(p_streambuf_pbackfail
, &ssb1
.base
, 'X');
2111 ok(ret
== 'X', "wrong return, expected 'X' got %d\n", ret
);
2112 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
+ 51, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
+ 51, ssb1
.base
.gptr
);
2113 ok(*ssb1
.base
.gptr
== 'X', "expected 'X' got '%c'\n", *ssb1
.base
.gptr
);
2114 ssb1
.base
.gptr
= ssb1
.base
.eback
;
2115 ret
= (int) call_func2(p_streambuf_pbackfail
, &ssb1
.base
, 'Y');
2116 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
2117 ssb1
.base
.gptr
= ssb1
.base
.eback
+ 1;
2118 ret
= (int) call_func2(p_streambuf_pbackfail
, &ssb1
.base
, EOF
);
2119 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
2120 ok(ssb1
.base
.gptr
== ssb1
.base
.eback
, "wrong get pointer, expected %p got %p\n", ssb1
.base
.eback
, ssb1
.base
.gptr
);
2121 ok((signed char)*ssb1
.base
.gptr
== EOF
, "expected EOF got '%c'\n", *ssb1
.base
.gptr
);
2123 call_func1(p_strstreambuf_dtor
, &ssb1
);
2124 call_func1(p_strstreambuf_dtor
, &ssb2
);
2127 static void test_stdiobuf(void)
2129 stdiobuf stb1
, stb2
;
2130 FILE *file1
, *file2
;
2131 const char filename1
[] = "stdiobuf_test1";
2132 const char filename2
[] = "stdiobuf_test2";
2136 memset(&stb1
, 0xab, sizeof(stdiobuf
));
2137 memset(&stb2
, 0xab, sizeof(stdiobuf
));
2139 file1
= fopen(filename1
, "w");
2140 fputs("Never gonna give you up, never gonna let you down", file1
);
2142 file1
= fopen(filename1
, "r");
2143 ok(file1
!= NULL
, "Couldn't open the file named '%s'\n", filename1
);
2144 file2
= fopen(filename2
, "w+");
2145 ok(file2
!= NULL
, "Couldn't open the file named '%s'\n", filename2
);
2147 /* constructors/destructor */
2148 call_func2(p_stdiobuf_file_ctor
, &stb1
, NULL
);
2149 ok(stb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", stb1
.base
.allocated
);
2150 ok(stb1
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", stb1
.base
.unbuffered
);
2151 ok(stb1
.file
== NULL
, "wrong file pointer, expected %p got %p\n", NULL
, stb1
.file
);
2152 call_func1(p_stdiobuf_dtor
, &stb1
);
2153 call_func2(p_stdiobuf_file_ctor
, &stb1
, file1
);
2154 ok(stb1
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", stb1
.base
.allocated
);
2155 ok(stb1
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", stb1
.base
.unbuffered
);
2156 ok(stb1
.file
== file1
, "wrong file pointer, expected %p got %p\n", file1
, stb1
.file
);
2157 call_func2(p_stdiobuf_file_ctor
, &stb2
, file2
);
2158 ok(stb2
.base
.allocated
== 0, "wrong allocate value, expected 0 got %d\n", stb2
.base
.allocated
);
2159 ok(stb2
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", stb2
.base
.unbuffered
);
2160 ok(stb2
.file
== file2
, "wrong file pointer, expected %p got %p\n", file2
, stb2
.file
);
2163 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, EOF
);
2164 ok(ret
== 1, "expected 1 got %d\n", ret
);
2165 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, 'a');
2166 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2167 stb1
.base
.unbuffered
= 0;
2168 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, 'a');
2169 ok(ret
== 1, "expected 1 got %d\n", ret
);
2170 ok(stb1
.base
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", stb1
.base
.allocated
);
2171 ok(stb1
.base
.ebuf
== stb1
.base
.base
+ 512, "expected %p got %p\n", stb1
.base
.base
+ 512, stb1
.base
.ebuf
);
2172 ok(stb1
.base
.pbase
== stb1
.base
.base
+ 256, "wrong put base, expected %p got %p\n", stb1
.base
.base
+ 256, stb1
.base
.pbase
);
2173 ok(stb1
.base
.pptr
== stb1
.base
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", stb1
.base
.pbase
+ 1, stb1
.base
.pptr
);
2174 ok(stb1
.base
.epptr
== stb1
.base
.ebuf
, "wrong put end, expected %p got %p\n", stb1
.base
.ebuf
, stb1
.base
.epptr
);
2175 ok(*(stb1
.base
.pptr
-1) == 'a', "expected 'a', got '%c'\n", *(stb1
.base
.pptr
-1));
2176 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, EOF
);
2177 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2178 ok(stb1
.base
.pptr
== stb1
.base
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", stb1
.base
.pbase
+ 1, stb1
.base
.pptr
);
2179 stb1
.base
.pptr
= stb1
.base
.pbase
;
2180 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, EOF
);
2181 ok(ret
== 1, "expected 1 got %d\n", ret
);
2182 ok(stb1
.base
.pptr
== stb1
.base
.pbase
, "wrong put pointer, expected %p got %p\n", stb1
.base
.pbase
, stb1
.base
.pptr
);
2183 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb1
, 'b');
2184 ok(ret
== 1, "expected 1 got %d\n", ret
);
2185 ok(stb1
.base
.pptr
== stb1
.base
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", stb1
.base
.pbase
+ 1, stb1
.base
.pptr
);
2186 ok(*(stb1
.base
.pptr
-1) == 'b', "expected 'b', got '%c'\n", *(stb1
.base
.pptr
-1));
2187 stb1
.base
.unbuffered
= 1;
2188 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb2
, EOF
);
2189 ok(ret
== 1, "expected 1 got %d\n", ret
);
2190 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb2
, 'a');
2191 ok(ret
== 'a', "expected 'a' got %d\n", ret
);
2192 stb2
.base
.unbuffered
= 0;
2193 stb2
.base
.base
= buffer
;
2194 stb2
.base
.pbase
= stb2
.base
.pptr
= buffer
+ 32;
2195 stb2
.base
.ebuf
= stb2
.base
.epptr
= buffer
+ 64;
2196 ret
= (int) call_func3(p_streambuf_xsputn
, &stb2
.base
, "Never gonna run around", 22);
2197 ok(ret
== 22, "expected 22 got %d\n", ret
);
2198 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb2
, 'c');
2199 ok(ret
== 1, "expected 1 got %d\n", ret
);
2200 ok(stb2
.base
.pptr
== stb2
.base
.pbase
+ 1, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
+ 1, stb2
.base
.pptr
);
2201 ok(*(stb2
.base
.pptr
-1) == 'c', "expected 'c', got '%c'\n", *(stb2
.base
.pptr
-1));
2202 stb2
.base
.pbase
= stb2
.base
.pptr
+ 3;
2203 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb2
, 'd');
2204 ok(ret
== 1, "expected 1 got %d\n", ret
);
2205 ok(stb2
.base
.pptr
== stb2
.base
.pbase
- 2, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
- 2, stb2
.base
.pptr
);
2206 ok(*(stb2
.base
.pptr
-1) == 'd', "expected 'd', got '%c'\n", *(stb2
.base
.pptr
-1));
2207 stb2
.base
.pbase
= stb2
.base
.pptr
= buffer
+ 32;
2208 stb2
.base
.epptr
= buffer
+ 30;
2209 ret
= (int) call_func2(p_stdiobuf_overflow
, &stb2
, 'd');
2210 ok(ret
== 'd', "expected 'd' got %d\n", ret
);
2211 ok(stb2
.base
.pptr
== stb2
.base
.pbase
, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
, stb2
.base
.pptr
);
2212 stb2
.base
.epptr
= buffer
+ 64;
2213 stb2
.base
.unbuffered
= 1;
2216 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2217 ok(ret
== 'N', "expected 'N' got %d\n", ret
);
2218 stb1
.base
.unbuffered
= 0;
2219 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2220 ok(ret
== 'e', "expected 'e' got %d\n", ret
);
2221 ok(stb1
.base
.eback
== stb1
.base
.base
, "wrong get base, expected %p got %p\n", stb1
.base
.base
, stb1
.base
.eback
);
2222 ok(stb1
.base
.gptr
== stb1
.base
.egptr
- 47, "wrong get pointer, expected %p got %p\n", stb1
.base
.egptr
- 47, stb1
.base
.gptr
);
2223 ok(stb1
.base
.egptr
== stb1
.base
.base
+ 256, "wrong get end, expected %p got %p\n", stb1
.base
.base
+ 256, stb1
.base
.egptr
);
2224 ok(*stb1
.base
.gptr
== 'v', "expected 'v' got '%c'\n", *stb1
.base
.gptr
);
2225 stb1
.base
.pbase
= stb1
.base
.pptr
= stb1
.base
.epptr
= NULL
;
2226 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2227 ok(ret
== 'v', "expected 'v' got %d\n", ret
);
2228 ok(stb1
.base
.gptr
== stb1
.base
.egptr
- 46, "wrong get pointer, expected %p got %p\n", stb1
.base
.egptr
- 46, stb1
.base
.gptr
);
2229 *stb1
.base
.gptr
= -50;
2230 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2231 ok(ret
== 206, "expected 206 got %d\n", ret
);
2232 ok(stb1
.base
.gptr
== stb1
.base
.egptr
- 45, "wrong get pointer, expected %p got %p\n", stb1
.base
.egptr
- 45, stb1
.base
.gptr
);
2233 stb1
.base
.gptr
= stb1
.base
.egptr
;
2234 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2235 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2236 stb1
.base
.unbuffered
= 1;
2237 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb1
);
2238 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2240 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb2
);
2241 ok(ret
== 'a', "expected 'a' got %d\n", ret
);
2242 stb2
.base
.unbuffered
= 0;
2243 stb2
.base
.eback
= stb2
.base
.gptr
= buffer
+ 16;
2244 stb2
.base
.egptr
= buffer
+ 32;
2245 strcpy(buffer
+ 16, "and desert you");
2246 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb2
);
2247 ok(ret
== 'a', "expected 'a' got %d\n", ret
);
2248 ok(stb2
.base
.gptr
== buffer
+ 17, "wrong get pointer, expected %p got %p\n", buffer
+ 17, stb2
.base
.gptr
);
2249 stb2
.base
.eback
= buffer
;
2250 stb2
.base
.gptr
= stb2
.base
.egptr
;
2251 stb2
.base
.pbase
= stb2
.base
.pptr
= stb2
.base
.epptr
= NULL
;
2252 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb2
);
2253 ok(ret
== 'N', "expected 'N' got %d\n", ret
);
2254 ok(stb2
.base
.gptr
== stb2
.base
.egptr
- 22, "wrong get pointer, expected %p got %p\n", stb2
.base
.egptr
- 22, stb2
.base
.gptr
);
2255 ok(ftell(stb2
.file
) == 24, "ftell failed\n");
2256 stb2
.base
.gptr
= stb2
.base
.egptr
;
2257 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb2
);
2258 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2259 stb2
.base
.unbuffered
= 1;
2260 ret
= (int) call_func1(p_stdiobuf_underflow
, &stb2
);
2261 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2264 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2265 ok(ret
== 0, "expected 0 got %d\n", ret
);
2266 stb1
.base
.gptr
= stb1
.base
.eback
;
2267 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2268 ok(ret
== 0, "expected 0 got %d\n", ret
);
2269 stb1
.base
.unbuffered
= 0;
2270 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2271 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2272 ok(stb1
.base
.pbase
== stb1
.base
.base
+ 256, "wrong put base, expected %p got %p\n", stb1
.base
.base
+ 256, stb1
.base
.pbase
);
2273 ok(stb1
.base
.pptr
== stb1
.base
.base
+ 256, "wrong put pointer, expected %p got %p\n", stb1
.base
.base
+ 256, stb1
.base
.pptr
);
2274 ok(stb1
.base
.epptr
== stb1
.base
.base
+ 512, "wrong put end, expected %p got %p\n", stb1
.base
.base
+ 512, stb1
.base
.epptr
);
2275 stb1
.base
.gptr
= stb1
.base
.egptr
;
2276 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2277 ok(ret
== 0, "expected 0 got %d\n", ret
);
2278 stb1
.base
.eback
= stb1
.base
.gptr
= stb1
.base
.egptr
= NULL
;
2279 stb1
.base
.pptr
= stb1
.base
.epptr
;
2280 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2281 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2282 ok(stb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, stb1
.base
.gptr
);
2283 stb1
.base
.pptr
= stb1
.base
.pbase
;
2284 ret
= (int) call_func1(p_stdiobuf_sync
, &stb1
);
2285 ok(ret
== 0, "expected 0 got %d\n", ret
);
2286 ok(stb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, stb1
.base
.gptr
);
2287 stb1
.base
.unbuffered
= 1;
2288 stb2
.base
.unbuffered
= 0;
2289 stb2
.base
.egptr
= stb2
.base
.ebuf
;
2290 ret
= (int) call_func1(p_stdiobuf_sync
, &stb2
);
2291 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2292 ok(stb2
.base
.pbase
== stb2
.base
.base
+ 32, "wrong put base, expected %p got %p\n", stb2
.base
.base
+ 32, stb2
.base
.pbase
);
2293 ok(stb2
.base
.pptr
== stb2
.base
.base
+ 32, "wrong put pointer, expected %p got %p\n", stb2
.base
.base
+ 32, stb2
.base
.pptr
);
2294 ok(stb2
.base
.epptr
== stb2
.base
.base
+ 64, "wrong put end, expected %p got %p\n", stb2
.base
.base
+ 64, stb2
.base
.epptr
);
2295 stb2
.base
.egptr
= stb2
.base
.pbase
;
2296 stb2
.base
.gptr
= stb2
.base
.egptr
- 25;
2297 ret
= (int) call_func1(p_stdiobuf_sync
, &stb2
);
2298 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2299 ret
= (int) call_func3(p_streambuf_xsputn
, &stb2
.base
, "Never gonna make you cry", 24);
2300 ok(ret
== 24, "expected 24 got %d\n", ret
);
2301 ret
= (int) call_func1(p_stdiobuf_sync
, &stb2
);
2302 ok(ret
== 0, "expected 0 got %d\n", ret
);
2303 ok(ftell(stb2
.file
) == 23, "ftell failed\n");
2304 ok(fseek(stb2
.file
, 3, SEEK_SET
) == 0, "fseek failed\n");
2305 stb2
.base
.gptr
= stb2
.base
.egptr
- 3;
2306 strcpy(stb2
.base
.gptr
, "a\nc");
2307 ret
= (int) call_func1(p_stdiobuf_sync
, &stb2
);
2308 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2309 ok(stb2
.base
.gptr
== stb2
.base
.egptr
- 3, "wrong get pointer, expected %p got %p\n", stb2
.base
.egptr
- 3, stb2
.base
.gptr
);
2310 *(stb2
.base
.gptr
+1) = 'b';
2311 ret
= (int) call_func1(p_stdiobuf_sync
, &stb2
);
2312 ok(ret
== 0, "expected 0 got %d\n", ret
);
2313 ok(stb2
.base
.gptr
== stb2
.base
.egptr
, "wrong get pointer, expected %p got %p\n", stb2
.base
.egptr
, stb2
.base
.gptr
);
2314 stb2
.base
.unbuffered
= 1;
2317 ret
= (int) call_func3(p_stdiobuf_setrwbuf
, &stb1
, 100, 60);
2318 ok(ret
== 1, "expected 1 got %d\n", ret
);
2319 ok(stb1
.base
.allocated
== 1, "wrong allocate value, expected 1 got %d\n", stb1
.base
.allocated
);
2320 ok(stb1
.base
.unbuffered
== 0, "wrong unbuffered value, expected 0 got %d\n", stb1
.base
.unbuffered
);
2321 ok(stb1
.base
.ebuf
== stb1
.base
.base
+ 160, "expected %p got %p\n", stb1
.base
.base
+ 160, stb1
.base
.ebuf
);
2322 ok(stb1
.base
.eback
== stb1
.base
.base
, "wrong get base, expected %p got %p\n", stb1
.base
.base
, stb1
.base
.eback
);
2323 ok(stb1
.base
.gptr
== stb1
.base
.base
+ 100, "wrong get pointer, expected %p got %p\n", stb1
.base
.base
+ 100, stb1
.base
.gptr
);
2324 ok(stb1
.base
.egptr
== stb1
.base
.base
+ 100, "wrong get end, expected %p got %p\n", stb1
.base
.base
+ 100, stb1
.base
.egptr
);
2325 ok(stb1
.base
.pbase
== stb1
.base
.base
+ 100, "wrong put base, expected %p got %p\n", stb1
.base
.base
+ 100, stb1
.base
.pbase
);
2326 ok(stb1
.base
.pptr
== stb1
.base
.base
+ 100, "wrong put pointer, expected %p got %p\n", stb1
.base
.base
+ 100, stb1
.base
.pptr
);
2327 ok(stb1
.base
.epptr
== stb1
.base
.base
+ 160, "wrong put end, expected %p got %p\n", stb1
.base
.base
+ 160, stb1
.base
.epptr
);
2328 ret
= (int) call_func3(p_stdiobuf_setrwbuf
, &stb1
, -1, 64);
2329 ok(ret
== 0 || ret
== 1, "expected 0 or 1, got %d\n", ret
);
2330 ret
= (int) call_func3(p_stdiobuf_setrwbuf
, &stb1
, 32, -8);
2331 ok(ret
== 0 || ret
== 1, "expected 0 or 1, got %d\n", ret
);
2332 ret
= (int) call_func3(p_stdiobuf_setrwbuf
, &stb1
, 0, 64);
2333 ok(ret
== 1, "expected 1 got %d\n", ret
);
2334 ok(stb1
.base
.ebuf
== stb1
.base
.base
+ 64, "expected %p got %p\n", stb1
.base
.base
+ 64, stb1
.base
.ebuf
);
2335 ok(stb1
.base
.eback
== NULL
, "wrong get base, expected %p got %p\n", NULL
, stb1
.base
.eback
);
2336 ok(stb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, stb1
.base
.gptr
);
2337 ok(stb1
.base
.egptr
== NULL
, "wrong get end, expected %p got %p\n", NULL
, stb1
.base
.egptr
);
2338 ok(stb1
.base
.pbase
== stb1
.base
.base
, "wrong put base, expected %p got %p\n", stb1
.base
.base
, stb1
.base
.pbase
);
2339 ok(stb1
.base
.pptr
== stb1
.base
.base
, "wrong put pointer, expected %p got %p\n", stb1
.base
.base
, stb1
.base
.pptr
);
2340 ok(stb1
.base
.epptr
== stb1
.base
.base
+ 64, "wrong put end, expected %p got %p\n", stb1
.base
.base
+ 64, stb1
.base
.epptr
);
2341 ret
= (int) call_func3(p_stdiobuf_setrwbuf
, &stb1
, 0, 0);
2342 ok(ret
== 0, "expected 0 got %d\n", ret
);
2343 ok(stb1
.base
.unbuffered
== 1, "wrong unbuffered value, expected 1 got %d\n", stb1
.base
.unbuffered
);
2346 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 0, SEEKDIR_beg
, OPENMODE_in
);
2347 ok(ret
== 0, "expected 0 got %d\n", ret
);
2348 stb1
.base
.unbuffered
= 0;
2349 ret
= (int) call_func3(p_streambuf_xsputn
, &stb1
.base
, "Never gonna say goodbye", 22);
2350 ok(ret
== 22, "expected 22 got %d\n", ret
);
2351 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 5, SEEKDIR_beg
, OPENMODE_in
);
2352 ok(ret
== 5, "expected 5 got %d\n", ret
);
2353 ok(stb1
.base
.pptr
== stb1
.base
.pbase
+ 22, "wrong put pointer, expected %p got %p\n", stb1
.base
.pbase
+ 22, stb1
.base
.pptr
);
2354 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 300, SEEKDIR_beg
, OPENMODE_in
);
2355 ok(ret
== 300, "expected 300 got %d\n", ret
);
2356 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, -310, SEEKDIR_cur
, OPENMODE_in
);
2357 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2358 stb1
.base
.eback
= stb1
.base
.base
;
2359 stb1
.base
.gptr
= stb1
.base
.egptr
= stb1
.base
.pbase
= stb1
.base
.base
+ 10;
2360 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, -280, SEEKDIR_cur
, OPENMODE_in
);
2361 ok(ret
== 20, "expected 20 got %d\n", ret
);
2362 stb1
.base
.gptr
= stb1
.base
.eback
;
2363 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 80, SEEKDIR_cur
, OPENMODE_in
);
2364 ok(ret
== 100, "expected 100 got %d\n", ret
);
2365 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 0, SEEKDIR_end
, OPENMODE_in
);
2366 ok(ret
== 49, "expected 49 got %d\n", ret
);
2367 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, 1, SEEKDIR_end
, OPENMODE_in
);
2368 ok(ret
== 50, "expected 50 got %d\n", ret
);
2369 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, -60, SEEKDIR_end
, OPENMODE_in
);
2370 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2371 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb1
, -20, SEEKDIR_end
, OPENMODE_out
);
2372 ok(ret
== 29, "expected 29 got %d\n", ret
);
2373 stb1
.base
.eback
= stb1
.base
.gptr
= stb1
.base
.egptr
= NULL
;
2374 stb1
.base
.pptr
= stb1
.base
.pbase
;
2375 stb1
.base
.unbuffered
= 1;
2376 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, 0, SEEKDIR_beg
, OPENMODE_in
);
2377 ok(ret
== 0, "expected 0 got %d\n", ret
);
2378 stb2
.base
.pptr
+= 10;
2379 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, 20, SEEKDIR_beg
, OPENMODE_in
);
2380 ok(ret
== 20, "expected 20 got %d\n", ret
);
2381 ok(stb2
.base
.pptr
== stb2
.base
.pbase
+ 10, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
+ 10, stb2
.base
.pptr
);
2382 stb2
.base
.unbuffered
= 0;
2383 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, 10, SEEKDIR_cur
, OPENMODE_in
);
2384 ok(ret
== 40, "expected 40 got %d\n", ret
);
2385 ok(stb2
.base
.pptr
== stb2
.base
.pbase
, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
, stb2
.base
.pptr
);
2386 stb2
.base
.gptr
= stb2
.base
.eback
;
2387 stb2
.base
.pptr
+= 5;
2388 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, -50, SEEKDIR_cur
, OPENMODE_in
|OPENMODE_out
);
2389 ok(ret
== EOF
, "expected EOF got %d\n", ret
);
2390 ok(stb2
.base
.pptr
== stb2
.base
.pbase
, "wrong put pointer, expected %p got %p\n", stb2
.base
.pbase
, stb2
.base
.pptr
);
2391 stb2
.base
.pbase
= stb2
.base
.pptr
= stb2
.base
.epptr
= NULL
;
2392 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, 0, SEEKDIR_end
, OPENMODE_in
|OPENMODE_out
);
2393 ok(ret
== 48, "expected 48 got %d\n", ret
);
2394 ok(stb2
.base
.pbase
== stb2
.base
.base
+ 32, "wrong put pointer, expected %p got %p\n", stb2
.base
.base
+ 32, stb2
.base
.pbase
);
2395 ok(stb2
.base
.pptr
== stb2
.base
.base
+ 32, "wrong put pointer, expected %p got %p\n", stb2
.base
.base
+ 32, stb2
.base
.pptr
);
2396 ok(stb2
.base
.epptr
== stb2
.base
.ebuf
, "wrong put pointer, expected %p got %p\n", stb2
.base
.ebuf
, stb2
.base
.epptr
);
2397 ret
= (int) call_func4(p_stdiobuf_seekoff
, &stb2
, -28, SEEKDIR_end
, -1);
2398 ok(ret
== 20, "expected 20 got %d\n", ret
);
2399 stb2
.base
.gptr
= stb2
.base
.egptr
;
2400 stb2
.base
.unbuffered
= 1;
2403 last
= fgetc(stb1
.file
);
2404 ok(last
== 'r', "expected 'r' got %d\n", last
);
2405 ok(ftell(stb1
.file
) == 30, "ftell failed\n");
2406 ret
= (int) call_func2(p_stdiobuf_pbackfail
, &stb1
, 'i');
2407 ok(ret
== 'i', "expected 'i' got %d\n", ret
);
2408 ok(ftell(stb1
.file
) == 29, "ftell failed\n");
2409 last
= fgetc(stb1
.file
);
2410 ok(last
== 'r', "expected 'r' got %d\n", last
);
2411 ok(ftell(stb1
.file
) == 30, "ftell failed\n");
2412 stb1
.base
.eback
= stb1
.base
.base
;
2413 stb1
.base
.gptr
= stb1
.base
.egptr
= stb1
.base
.base
+ 9;
2414 strcpy(stb1
.base
.eback
, "pbackfail");
2415 ret
= (int) call_func2(p_stdiobuf_pbackfail
, &stb1
, 'j');
2416 ok(ret
== 'j', "expected 'j' got %d\n", ret
);
2417 ok(stb1
.base
.gptr
== stb1
.base
.base
+ 8, "wrong get pointer, expected %p got %p\n", stb1
.base
.base
+ 8, stb1
.base
.gptr
);
2418 ok(strncmp(stb1
.base
.eback
, "pbackfaij", 9) == 0, "strncmp failed\n");
2419 ok(ftell(stb1
.file
) == 30, "ftell failed\n");
2420 stb1
.base
.gptr
= stb1
.base
.eback
;
2421 ret
= (int) call_func2(p_stdiobuf_pbackfail
, &stb1
, 'k');
2422 ok(ret
== 'k', "expected 'k' got %d\n", ret
);
2423 ok(stb1
.base
.gptr
== stb1
.base
.base
, "wrong get pointer, expected %p got %p\n", stb1
.base
.base
, stb1
.base
.gptr
);
2424 ok(strncmp(stb1
.base
.eback
, "pbackfaij", 9) == 0, "strncmp failed\n");
2425 ok(ftell(stb1
.file
) == 29, "ftell failed\n");
2426 stb1
.base
.unbuffered
= 0;
2427 ret
= (int) call_func2(p_stdiobuf_pbackfail
, &stb1
, 'l');
2428 ok(ret
== 'l', "expected 'l' got %d\n", ret
);
2429 ok(strncmp(stb1
.base
.eback
, "lpbackfai", 9) == 0, "strncmp failed\n");
2430 ok(ftell(stb1
.file
) == 28, "ftell failed\n");
2431 stb1
.base
.egptr
= NULL
;
2432 ret
= (int) call_func2(p_stdiobuf_pbackfail
, &stb1
, 'm');
2433 ok(ret
== 'm', "expected 'm' got %d\n", ret
);
2434 ok(strncmp(stb1
.base
.eback
, "lpbackfai", 9) == 0, "strncmp failed\n");
2435 ok(ftell(stb1
.file
) == 27, "ftell failed\n");
2436 stb1
.base
.unbuffered
= 1;
2438 call_func1(p_stdiobuf_dtor
, &stb1
);
2439 call_func1(p_stdiobuf_dtor
, &stb2
);
2442 ok(_unlink(filename1
) == 0, "Couldn't unlink file named '%s'\n", filename1
);
2443 ok(_unlink(filename2
) == 0, "Couldn't unlink file named '%s'\n", filename2
);
2453 static DWORD WINAPI
lock_ios(void *arg
)
2455 struct ios_lock_arg
*lock_arg
= arg
;
2456 p_ios_lock(lock_arg
->ios_obj
);
2457 p_ios_lockbuf(lock_arg
->ios_obj
);
2459 SetEvent(lock_arg
->lock
);
2460 WaitForSingleObject(lock_arg
->release
[0], INFINITE
);
2462 WaitForSingleObject(lock_arg
->release
[1], INFINITE
);
2463 p_ios_unlockbuf(lock_arg
->ios_obj
);
2464 WaitForSingleObject(lock_arg
->release
[2], INFINITE
);
2465 p_ios_unlock(lock_arg
->ios_obj
);
2469 static void test_ios(void)
2471 ios ios_obj
, ios_obj2
;
2473 struct ios_lock_arg lock_arg
;
2476 LONG
*pret
, expected
, ret
;
2480 memset(&ios_obj
, 0xab, sizeof(ios
));
2481 memset(&ios_obj2
, 0xab, sizeof(ios
));
2482 psb
= p_operator_new(sizeof(streambuf
));
2483 ok(psb
!= NULL
, "failed to allocate streambuf object\n");
2484 call_func1(p_streambuf_ctor
, psb
);
2486 /* constructor/destructor */
2487 ok(*p_ios_fLockcInit
== 4, "expected 4 got %d\n", *p_ios_fLockcInit
);
2488 call_func2(p_ios_sb_ctor
, &ios_obj
, NULL
);
2489 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2490 ok(ios_obj
.state
== IOSTATE_badbit
, "expected %x got %x\n", IOSTATE_badbit
, ios_obj
.state
);
2491 ok(ios_obj
.special
[0] == 0, "expected 0 got %d\n", ios_obj
.special
[0]);
2492 ok(ios_obj
.special
[1] == 0, "expected 0 got %d\n", ios_obj
.special
[1]);
2493 ok(ios_obj
.delbuf
== 0, "expected 0 got %d\n", ios_obj
.delbuf
);
2494 ok(ios_obj
.tie
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.tie
);
2495 ok(ios_obj
.flags
== 0, "expected 0 got %x\n", ios_obj
.flags
);
2496 ok(ios_obj
.precision
== 6, "expected 6 got %d\n", ios_obj
.precision
);
2497 ok(ios_obj
.fill
== ' ', "expected ' ' got %d\n", ios_obj
.fill
);
2498 ok(ios_obj
.width
== 0, "expected 0 got %d\n", ios_obj
.width
);
2499 ok(ios_obj
.do_lock
== -1, "expected -1 got %d\n", ios_obj
.do_lock
);
2500 ok(ios_obj
.lock
.LockCount
== -1, "expected -1 got %d\n", ios_obj
.lock
.LockCount
);
2501 ok(*p_ios_fLockcInit
== 5, "expected 5 got %d\n", *p_ios_fLockcInit
);
2502 ios_obj
.state
= 0x8;
2503 call_func1(p_ios_dtor
, &ios_obj
);
2504 ok(ios_obj
.state
== IOSTATE_badbit
, "expected %x got %x\n", IOSTATE_badbit
, ios_obj
.state
);
2505 ok(*p_ios_fLockcInit
== 4, "expected 4 got %d\n", *p_ios_fLockcInit
);
2506 ios_obj
.state
= 0x8;
2507 call_func2(p_ios_sb_ctor
, &ios_obj
, psb
);
2508 ok(ios_obj
.sb
== psb
, "expected %p got %p\n", psb
, ios_obj
.sb
);
2509 ok(ios_obj
.state
== IOSTATE_goodbit
, "expected %x got %x\n", IOSTATE_goodbit
, ios_obj
.state
);
2510 ok(ios_obj
.delbuf
== 0, "expected 0 got %d\n", ios_obj
.delbuf
);
2511 ok(*p_ios_fLockcInit
== 5, "expected 5 got %d\n", *p_ios_fLockcInit
);
2512 ios_obj
.state
= 0x8;
2513 call_func1(p_ios_dtor
, &ios_obj
);
2514 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2515 ok(ios_obj
.state
== IOSTATE_badbit
, "expected %x got %x\n", IOSTATE_badbit
, ios_obj
.state
);
2516 ok(*p_ios_fLockcInit
== 4, "expected 4 got %d\n", *p_ios_fLockcInit
);
2518 ios_obj
.state
= 0x8;
2519 call_func1(p_ios_ctor
, &ios_obj
);
2520 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2521 ok(ios_obj
.state
== IOSTATE_badbit
, "expected %x got %x\n", IOSTATE_badbit
, ios_obj
.state
);
2522 ok(*p_ios_fLockcInit
== 5, "expected 5 got %d\n", *p_ios_fLockcInit
);
2525 ios_obj
.state
|= 0x8;
2526 call_func2(p_ios_init
, &ios_obj
, psb
);
2527 ok(ios_obj
.sb
== psb
, "expected %p got %p\n", psb
, ios_obj
.sb
);
2528 ok(ios_obj
.state
== 0x8, "expected %x got %x\n", 0x8, ios_obj
.state
);
2529 call_func2(p_ios_init
, &ios_obj
, NULL
);
2530 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2531 ok(ios_obj
.state
== (0x8|IOSTATE_badbit
), "expected %x got %x\n", (0x8|IOSTATE_badbit
), ios_obj
.state
);
2534 call_func2(p_ios_init
, &ios_obj
, psb
);
2535 ok(ios_obj
.sb
== psb
, "expected %p got %p\n", psb
, ios_obj
.sb
);
2536 ok(ios_obj
.state
== 0x8, "expected %x got %x\n", 0x8, ios_obj
.state
);
2537 call_func1(p_ios_dtor
, &ios_obj
);
2539 /* copy constructor */
2540 call_func2(p_ios_copy_ctor
, &ios_obj
, &ios_obj2
);
2541 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2542 ok(ios_obj
.state
== (ios_obj2
.state
|IOSTATE_badbit
), "expected %x got %x\n", (ios_obj2
.state
|IOSTATE_badbit
), ios_obj
.state
);
2543 ok(ios_obj
.delbuf
== 0, "expected 0 got %d\n", ios_obj
.delbuf
);
2544 ok(ios_obj
.tie
== ios_obj2
.tie
, "expected %p got %p\n", ios_obj2
.tie
, ios_obj
.tie
);
2545 ok(ios_obj
.flags
== ios_obj2
.flags
, "expected %x got %x\n", ios_obj2
.flags
, ios_obj
.flags
);
2546 ok(ios_obj
.precision
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.precision
);
2547 ok(ios_obj
.fill
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.fill
);
2548 ok(ios_obj
.width
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.width
);
2549 ok(ios_obj
.do_lock
== -1, "expected -1 got %d\n", ios_obj
.do_lock
);
2550 ok(*p_ios_fLockcInit
== 5, "expected 5 got %d\n", *p_ios_fLockcInit
);
2553 ios_obj
.state
= 0x8;
2557 ios_obj
.precision
= 6;
2560 ios_obj
.do_lock
= 2;
2561 call_func2(p_ios_assign
, &ios_obj
, &ios_obj2
);
2562 ok(ios_obj
.sb
== NULL
, "expected %p got %p\n", NULL
, ios_obj
.sb
);
2563 ok(ios_obj
.state
== (ios_obj2
.state
|IOSTATE_badbit
), "expected %x got %x\n", (ios_obj2
.state
|IOSTATE_badbit
), ios_obj
.state
);
2564 ok(ios_obj
.delbuf
== 2, "expected 2 got %d\n", ios_obj
.delbuf
);
2565 ok(ios_obj
.tie
== ios_obj2
.tie
, "expected %p got %p\n", ios_obj2
.tie
, ios_obj
.tie
);
2566 ok(ios_obj
.flags
== ios_obj2
.flags
, "expected %x got %x\n", ios_obj2
.flags
, ios_obj
.flags
);
2567 ok(ios_obj
.precision
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.precision
);
2568 ok(ios_obj
.fill
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.fill
);
2569 ok(ios_obj
.width
== (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj
.width
);
2570 ok(ios_obj
.do_lock
== 2, "expected 2 got %d\n", ios_obj
.do_lock
);
2574 ios_obj
.do_lock
= 1;
2575 ios_obj
.sb
->do_lock
= 0;
2576 p_ios_clrlock(&ios_obj
);
2577 ok(ios_obj
.do_lock
== 1, "expected 1 got %d\n", ios_obj
.do_lock
);
2578 ok(ios_obj
.sb
->do_lock
== 1, "expected 1 got %d\n", ios_obj
.sb
->do_lock
);
2579 ios_obj
.do_lock
= 0;
2580 p_ios_clrlock(&ios_obj
);
2581 ok(ios_obj
.do_lock
== 1, "expected 1 got %d\n", ios_obj
.do_lock
);
2582 ok(ios_obj
.sb
->do_lock
== 1, "expected 1 got %d\n", ios_obj
.sb
->do_lock
);
2583 p_ios_setlock(&ios_obj
);
2584 ok(ios_obj
.do_lock
== 0, "expected 0 got %d\n", ios_obj
.do_lock
);
2585 ok(ios_obj
.sb
->do_lock
== 0, "expected 0 got %d\n", ios_obj
.sb
->do_lock
);
2586 ios_obj
.do_lock
= -1;
2587 p_ios_setlock(&ios_obj
);
2588 ok(ios_obj
.do_lock
== -2, "expected -2 got %d\n", ios_obj
.do_lock
);
2589 ok(ios_obj
.sb
->do_lock
== -1, "expected -1 got %d\n", ios_obj
.sb
->do_lock
);
2591 lock_arg
.ios_obj
= &ios_obj
;
2592 lock_arg
.lock
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2593 ok(lock_arg
.lock
!= NULL
, "CreateEventW failed\n");
2594 lock_arg
.release
[0] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2595 ok(lock_arg
.release
[0] != NULL
, "CreateEventW failed\n");
2596 lock_arg
.release
[1] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2597 ok(lock_arg
.release
[1] != NULL
, "CreateEventW failed\n");
2598 lock_arg
.release
[2] = CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2599 ok(lock_arg
.release
[2] != NULL
, "CreateEventW failed\n");
2600 thread
= CreateThread(NULL
, 0, lock_ios
, (void*)&lock_arg
, 0, NULL
);
2601 ok(thread
!= NULL
, "CreateThread failed\n");
2602 WaitForSingleObject(lock_arg
.lock
, INFINITE
);
2604 locked
= TryEnterCriticalSection(&ios_obj
.lock
);
2605 ok(locked
== 0, "the ios object was not locked before\n");
2606 locked
= TryEnterCriticalSection(&ios_obj
.sb
->lock
);
2607 ok(locked
== 0, "the streambuf was not locked before\n");
2608 locked
= TryEnterCriticalSection(p_ios_static_lock
);
2609 ok(locked
== 0, "the static critical section was not locked before\n");
2612 ios_obj
.flags
= 0x8000;
2613 ret
= (LONG
) call_func1(p_ios_flags_get
, &ios_obj
);
2614 ok(ret
== 0x8000, "expected %x got %x\n", 0x8000, ret
);
2615 ret
= (LONG
) call_func2(p_ios_flags_set
, &ios_obj
, 0x444);
2616 ok(ret
== 0x8000, "expected %x got %x\n", 0x8000, ret
);
2617 ok(ios_obj
.flags
== 0x444, "expected %x got %x\n", 0x444, ios_obj
.flags
);
2618 ret
= (LONG
) call_func2(p_ios_flags_set
, &ios_obj
, 0);
2619 ok(ret
== 0x444, "expected %x got %x\n", 0x444, ret
);
2620 ok(ios_obj
.flags
== 0, "expected %x got %x\n", 0, ios_obj
.flags
);
2623 ios_obj
.do_lock
= 0;
2624 ios_obj
.flags
= 0x8400;
2625 ret
= (LONG
) call_func2(p_ios_setf
, &ios_obj
, 0x444);
2626 ok(ret
== 0x8400, "expected %x got %x\n", 0x8400, ret
);
2627 ok(ios_obj
.flags
== 0x8444, "expected %x got %x\n", 0x8444, ios_obj
.flags
);
2628 ret
= (LONG
) call_func3(p_ios_setf_mask
, &ios_obj
, 0x111, 0);
2629 ok(ret
== 0x8444, "expected %x got %x\n", 0x8444, ret
);
2630 ok(ios_obj
.flags
== 0x8444, "expected %x got %x\n", 0x8444, ios_obj
.flags
);
2631 ret
= (LONG
) call_func3(p_ios_setf_mask
, &ios_obj
, 0x111, 0x105);
2632 ok(ret
== 0x8444, "expected %x got %x\n", 0x8444, ret
);
2633 ok(ios_obj
.flags
== 0x8541, "expected %x got %x\n", 0x8541, ios_obj
.flags
);
2636 ret
= (LONG
) call_func2(p_ios_unsetf
, &ios_obj
, 0x1111);
2637 ok(ret
== 0x8541, "expected %x got %x\n", 0x8541, ret
);
2638 ok(ios_obj
.flags
== 0x8440, "expected %x got %x\n", 0x8440, ios_obj
.flags
);
2639 ret
= (LONG
) call_func2(p_ios_unsetf
, &ios_obj
, 0x8008);
2640 ok(ret
== 0x8440, "expected %x got %x\n", 0x8440, ret
);
2641 ok(ios_obj
.flags
== 0x440, "expected %x got %x\n", 0x440, ios_obj
.flags
);
2642 ios_obj
.do_lock
= -1;
2645 ios_obj
.state
= 0x8;
2646 ret
= (LONG
) call_func1(p_ios_good
, &ios_obj
);
2647 ok(ret
== 0, "expected 0 got %d\n", ret
);
2648 ios_obj
.state
= IOSTATE_goodbit
;
2649 ret
= (LONG
) call_func1(p_ios_good
, &ios_obj
);
2650 ok(ret
== 1, "expected 1 got %d\n", ret
);
2651 ret
= (LONG
) call_func1(p_ios_bad
, &ios_obj
);
2652 ok(ret
== 0, "expected 0 got %d\n", ret
);
2653 ios_obj
.state
= (IOSTATE_eofbit
|IOSTATE_badbit
);
2654 ret
= (LONG
) call_func1(p_ios_bad
, &ios_obj
);
2655 ok(ret
== IOSTATE_badbit
, "expected 4 got %d\n", ret
);
2656 ret
= (LONG
) call_func1(p_ios_eof
, &ios_obj
);
2657 ok(ret
== IOSTATE_eofbit
, "expected 1 got %d\n", ret
);
2658 ios_obj
.state
= 0x8;
2659 ret
= (LONG
) call_func1(p_ios_eof
, &ios_obj
);
2660 ok(ret
== 0, "expected 0 got %d\n", ret
);
2661 ret
= (LONG
) call_func1(p_ios_fail
, &ios_obj
);
2662 ok(ret
== 0, "expected 0 got %d\n", ret
);
2663 ios_obj
.state
= IOSTATE_badbit
;
2664 ret
= (LONG
) call_func1(p_ios_fail
, &ios_obj
);
2665 ok(ret
== IOSTATE_badbit
, "expected 4 got %d\n", ret
);
2666 ios_obj
.state
= (IOSTATE_eofbit
|IOSTATE_failbit
);
2667 ret
= (LONG
) call_func1(p_ios_fail
, &ios_obj
);
2668 ok(ret
== IOSTATE_failbit
, "expected 2 got %d\n", ret
);
2669 ios_obj
.state
= (IOSTATE_eofbit
|IOSTATE_failbit
|IOSTATE_badbit
);
2670 ret
= (LONG
) call_func1(p_ios_fail
, &ios_obj
);
2671 ok(ret
== (IOSTATE_failbit
|IOSTATE_badbit
), "expected 6 got %d\n", ret
);
2672 ios_obj
.do_lock
= 0;
2673 call_func2(p_ios_clear
, &ios_obj
, 0);
2674 ok(ios_obj
.state
== IOSTATE_goodbit
, "expected 0 got %d\n", ios_obj
.state
);
2675 call_func2(p_ios_clear
, &ios_obj
, 0x8|IOSTATE_eofbit
);
2676 ok(ios_obj
.state
== (0x8|IOSTATE_eofbit
), "expected 9 got %d\n", ios_obj
.state
);
2677 ios_obj
.do_lock
= -1;
2679 SetEvent(lock_arg
.release
[0]);
2683 for (i
= 0; i
< 20; i
++) {
2684 ret
= p_ios_bitalloc();
2685 ok(ret
== expected
, "expected %x got %x\n", expected
, ret
);
2686 ok(*p_ios_maxbit
== expected
, "expected %x got %x\n", expected
, *p_ios_maxbit
);
2690 /* xalloc/pword/iword */
2691 ok(*p_ios_curindex
== -1, "expected -1 got %d\n", *p_ios_curindex
);
2693 for (i
= 0; i
< 8; i
++) {
2694 ret
= p_ios_xalloc();
2695 ok(ret
== expected
, "expected %d got %d\n", expected
, ret
);
2696 ok(*p_ios_curindex
== expected
, "expected %d got %d\n", expected
, *p_ios_curindex
);
2697 pret
= call_func2(p_ios_iword
, &ios_obj
, ret
);
2698 ok(pret
== &p_ios_statebuf
[ret
], "expected %p got %p\n", &p_ios_statebuf
[ret
], pret
);
2699 ok(*pret
== 0, "expected 0 got %d\n", *pret
);
2700 pret2
= call_func2(p_ios_pword
, &ios_obj
, ret
);
2701 ok(pret2
== (void**)&p_ios_statebuf
[ret
], "expected %p got %p\n", (void**)&p_ios_statebuf
[ret
], pret2
);
2704 ret
= p_ios_xalloc();
2705 ok(ret
== -1, "expected -1 got %d\n", ret
);
2706 ok(*p_ios_curindex
== 7, "expected 7 got %d\n", *p_ios_curindex
);
2708 SetEvent(lock_arg
.release
[1]);
2709 SetEvent(lock_arg
.release
[2]);
2710 WaitForSingleObject(thread
, INFINITE
);
2713 call_func1(p_ios_dtor
, &ios_obj
);
2714 ok(ios_obj
.state
== IOSTATE_badbit
, "expected %x got %x\n", IOSTATE_badbit
, ios_obj
.state
);
2715 ok(*p_ios_fLockcInit
== 4, "expected 4 got %d\n", *p_ios_fLockcInit
);
2716 CloseHandle(lock_arg
.lock
);
2717 CloseHandle(lock_arg
.release
[0]);
2718 CloseHandle(lock_arg
.release
[1]);
2719 CloseHandle(lock_arg
.release
[2]);
2720 CloseHandle(thread
);
2723 static void test_ostream(void) {
2724 ostream os1
, os2
, *pos
;
2725 filebuf fb1
, fb2
, *pfb
;
2726 const char filename1
[] = "test1";
2727 const char filename2
[] = "test2";
2730 memset(&os1
, 0xab, sizeof(ostream
));
2731 memset(&os2
, 0xab, sizeof(ostream
));
2732 memset(&fb1
, 0xab, sizeof(filebuf
));
2733 memset(&fb2
, 0xab, sizeof(filebuf
));
2735 /* constructors/destructors */
2736 pos
= call_func2(p_ostream_ctor
, &os1
, TRUE
);
2737 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2738 ok(os1
.unknown
== 0, "expected 0 got %d\n", os1
.unknown
);
2739 ok(os1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, os1
.base_ios
.sb
);
2740 ok(os1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os1
.base_ios
.state
);
2741 call_func1(p_ostream_vbase_dtor
, &os1
);
2742 pos
= call_func3(p_ostream_sb_ctor
, &os1
, &fb1
.base
, TRUE
);
2743 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2744 ok(os1
.unknown
== 0, "expected 0 got %d\n", os1
.unknown
);
2745 ok(os1
.base_ios
.sb
== &fb1
.base
, "expected %p got %p\n", &fb1
.base
, os1
.base_ios
.sb
);
2746 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2747 ok(fb1
.base
.allocated
== 0xabababab, "expected %d got %d\n", 0xabababab, fb1
.base
.allocated
);
2748 call_func1(p_filebuf_ctor
, &fb1
);
2749 pfb
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_out
, filebuf_openprot
);
2750 ok(pfb
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pfb
);
2751 ok(fb1
.base
.allocated
== 1, "expected %d got %d\n", 1, fb1
.base
.allocated
);
2752 call_func1(p_ostream_vbase_dtor
, &os1
);
2753 ok(os1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, os1
.base_ios
.sb
);
2754 ok(os1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os1
.base_ios
.state
);
2755 memset(&os1
.base_ios
, 0xab, sizeof(ios
));
2756 os1
.unknown
= 0xabababab;
2757 pos
= call_func2(p_ostream_ctor
, &os1
, FALSE
);
2758 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2759 ok(os1
.unknown
== 0, "expected 0 got %d\n", os1
.unknown
);
2760 ok(os1
.base_ios
.sb
== os2
.base_ios
.sb
, "expected %p got %p\n", os2
.base_ios
.sb
, os1
.base_ios
.sb
);
2761 ok(os1
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, os1
.base_ios
.state
);
2762 call_func1(p_ostream_dtor
, &os1
.base_ios
);
2763 os1
.unknown
= 0xabababab;
2764 os1
.base_ios
.state
= 0xabababab | IOSTATE_badbit
;
2765 os1
.base_ios
.delbuf
= 0;
2766 pos
= call_func3(p_ostream_sb_ctor
, &os1
, &fb1
.base
, FALSE
);
2767 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2768 ok(os1
.unknown
== 0, "expected 0 got %d\n", os1
.unknown
);
2769 ok(os1
.base_ios
.sb
== &fb1
.base
, "expected %p got %p\n", &fb1
.base
, os1
.base_ios
.sb
);
2770 ok(os1
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, os1
.base_ios
.state
);
2771 call_func1(p_ostream_dtor
, &os1
.base_ios
);
2772 memset(&os1
, 0xab, sizeof(ostream
));
2773 pos
= call_func3(p_ostream_sb_ctor
, &os1
, NULL
, TRUE
);
2774 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2775 ok(os1
.unknown
== 0, "expected 0 got %d\n", os1
.unknown
);
2776 ok(os1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, os1
.base_ios
.sb
);
2777 ok(os1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os1
.base_ios
.state
);
2778 call_func1(p_ostream_vbase_dtor
, &os1
);
2779 os1
.unknown
= 0xcdcdcdcd;
2780 memset(&os1
.base_ios
, 0xcd, sizeof(ios
));
2781 memset(&os2
, 0xab, sizeof(ostream
));
2782 os2
.vbtable
= os1
.vbtable
;
2783 os2
.base_ios
.delbuf
= 0;
2784 os2
.base_ios
.tie
= &os2
;
2785 pos
= call_func3(p_ostream_copy_ctor
, &os2
, &os1
, FALSE
);
2786 ok(pos
== &os2
, "wrong return, expected %p got %p\n", &os2
, pos
);
2787 ok(os2
.unknown
== 0, "expected 0 got %d\n", os2
.unknown
);
2788 ok(os2
.base_ios
.sb
== os1
.base_ios
.sb
, "expected %p got %p\n", os1
.base_ios
.sb
, os2
.base_ios
.sb
);
2789 ok(os2
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, os2
.base_ios
.state
);
2790 ok(os2
.base_ios
.delbuf
== 0, "expected 0 got %d\n", os2
.base_ios
.delbuf
);
2791 ok(os2
.base_ios
.tie
== &os2
, "expected %p got %p\n", &os2
, os2
.base_ios
.tie
);
2792 ok(os2
.base_ios
.flags
== 0xabababab, "expected %x got %x\n", 0xabababab, os2
.base_ios
.flags
);
2793 ok(os2
.base_ios
.precision
== 0xabababab, "expected %d got %d\n", 0xabababab, os2
.base_ios
.precision
);
2794 ok(os2
.base_ios
.fill
== (char) 0xab, "expected -85 got %d\n", os2
.base_ios
.fill
);
2795 ok(os2
.base_ios
.width
== 0xabababab, "expected %d got %d\n", 0xabababab, os2
.base_ios
.width
);
2796 call_func1(p_ostream_dtor
, &os2
.base_ios
);
2797 pos
= call_func3(p_ostream_copy_ctor
, &os2
, &os1
, TRUE
);
2798 ok(pos
== &os2
, "wrong return, expected %p got %p\n", &os2
, pos
);
2799 ok(os2
.unknown
== 0, "expected 0 got %d\n", os2
.unknown
);
2800 ok(os2
.base_ios
.sb
== os1
.base_ios
.sb
, "expected %p got %p\n", os1
.base_ios
.sb
, os2
.base_ios
.sb
);
2801 ok(os2
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os2
.base_ios
.state
);
2802 ok(os2
.base_ios
.delbuf
== 0, "expected 0 got %d\n", os2
.base_ios
.delbuf
);
2803 ok(os2
.base_ios
.tie
== NULL
, "expected %p got %p\n", NULL
, os2
.base_ios
.tie
);
2804 ok(os2
.base_ios
.flags
== 0, "expected 0 got %x\n", os2
.base_ios
.flags
);
2805 ok(os2
.base_ios
.precision
== 6, "expected 6 got %d\n", os2
.base_ios
.precision
);
2806 ok(os2
.base_ios
.fill
== ' ', "expected 32 got %d\n", os2
.base_ios
.fill
);
2807 ok(os2
.base_ios
.width
== 0, "expected 0 got %d\n", os2
.base_ios
.width
);
2810 pos
= call_func2(p_ostream_ctor
, &os1
, TRUE
);
2811 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2812 os1
.unknown
= 0xabababab;
2813 os1
.base_ios
.state
= 0xabababab;
2814 os1
.base_ios
.special
[0] = 0xabababab;
2815 os1
.base_ios
.delbuf
= 0xabababab;
2816 os1
.base_ios
.tie
= (ostream
*) 0xabababab;
2817 os1
.base_ios
.flags
= 0xabababab;
2818 os1
.base_ios
.precision
= 0xabababab;
2819 os1
.base_ios
.width
= 0xabababab;
2820 pos
= call_func2(p_ostream_assign_sb
, &os1
, &fb1
.base
);
2821 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2822 ok(os1
.unknown
== 0xabababab, "expected 0 got %d\n", os1
.unknown
);
2823 ok(os1
.base_ios
.sb
== &fb1
.base
, "expected %p got %p\n", &fb1
.base
, os1
.base_ios
.sb
);
2824 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2825 ok(os1
.base_ios
.special
[0] == 0xabababab, "expected %d got %d\n", 0xabababab, os1
.base_ios
.fill
);
2826 ok(os1
.base_ios
.delbuf
== 0, "expected 0 got %d\n", os1
.base_ios
.delbuf
);
2827 ok(os1
.base_ios
.tie
== NULL
, "expected %p got %p\n", NULL
, os1
.base_ios
.tie
);
2828 ok(os1
.base_ios
.flags
== 0, "expected 0 got %x\n", os1
.base_ios
.flags
);
2829 ok(os1
.base_ios
.precision
== 6, "expected 6 got %d\n", os1
.base_ios
.precision
);
2830 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
2831 os1
.base_ios
.state
= 0x8000;
2832 pos
= call_func2(p_ostream_assign_sb
, &os1
, NULL
);
2833 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2834 ok(os1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, os1
.base_ios
.sb
);
2835 ok(os1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os1
.base_ios
.state
);
2836 os2
.unknown
= 0xcdcdcdcd;
2837 os2
.base_ios
.state
= 0xcdcdcdcd;
2838 os2
.base_ios
.special
[0] = 0xcdcdcdcd;
2839 pos
= call_func2(p_ostream_assign
, &os2
, &os1
);
2840 ok(pos
== &os2
, "wrong return, expected %p got %p\n", &os2
, pos
);
2841 ok(os2
.unknown
== 0xcdcdcdcd, "expected 0 got %d\n", os2
.unknown
);
2842 ok(os2
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, os2
.base_ios
.sb
);
2843 ok(os2
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os2
.base_ios
.state
);
2844 ok(os2
.base_ios
.special
[0] == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, os2
.base_ios
.fill
);
2847 if (0) /* crashes on native */
2848 pos
= call_func1(p_ostream_flush
, &os1
);
2849 os1
.base_ios
.sb
= &fb2
.base
;
2850 call_func1(p_filebuf_ctor
, &fb2
);
2851 pos
= call_func1(p_ostream_flush
, &os1
);
2852 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2853 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2854 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2855 os1
.base_ios
.sb
= &fb1
.base
;
2856 os1
.base_ios
.state
= IOSTATE_eofbit
;
2857 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "Never gonna tell a lie", 22);
2858 ok(ret
== 22, "expected 22 got %d\n", ret
);
2859 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
2860 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 22, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 22, fb1
.base
.pptr
);
2861 pos
= call_func1(p_ostream_flush
, &os1
);
2862 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2863 ok(os1
.base_ios
.state
== IOSTATE_eofbit
, "expected %d got %d\n", IOSTATE_eofbit
, os1
.base_ios
.state
);
2864 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2865 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2866 os1
.base_ios
.tie
= &os2
;
2867 os2
.base_ios
.sb
= &fb2
.base
;
2868 os2
.base_ios
.state
= IOSTATE_goodbit
;
2869 pfb
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_out
, filebuf_openprot
);
2870 ok(pfb
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pfb
);
2871 ret
= (int) call_func3(p_streambuf_xsputn
, &fb2
.base
, "and hurt you", 12);
2872 ok(ret
== 12, "expected 12 got %d\n", ret
);
2873 ok(fb2
.base
.pbase
== fb2
.base
.base
, "wrong put base, expected %p got %p\n", fb2
.base
.base
, fb2
.base
.pbase
);
2874 ok(fb2
.base
.pptr
== fb2
.base
.base
+ 12, "wrong put pointer, expected %p got %p\n", fb2
.base
.base
+ 12, fb2
.base
.pptr
);
2875 pos
= call_func1(p_ostream_flush
, &os1
);
2876 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2877 ok(fb2
.base
.pbase
== fb2
.base
.base
, "wrong put base, expected %p got %p\n", fb2
.base
.base
, fb2
.base
.pbase
);
2878 ok(fb2
.base
.pptr
== fb2
.base
.base
+ 12, "wrong put pointer, expected %p got %p\n", fb2
.base
.base
+ 12, fb2
.base
.pptr
);
2881 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2882 ok(ret
== 0, "expected 0 got %d\n", ret
);
2883 ok(os1
.base_ios
.state
== (IOSTATE_eofbit
|IOSTATE_failbit
), "expected %d got %d\n",
2884 IOSTATE_eofbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2885 os1
.base_ios
.state
= IOSTATE_badbit
;
2886 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2887 ok(ret
== 0, "expected 0 got %d\n", ret
);
2888 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2889 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2890 os1
.base_ios
.sb
= &fb1
.base
;
2891 os1
.base_ios
.state
= IOSTATE_badbit
;
2892 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2893 ok(ret
== 0, "expected 0 got %d\n", ret
);
2894 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2895 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2896 os1
.base_ios
.state
= IOSTATE_failbit
;
2897 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2898 ok(ret
== 0, "expected 0 got %d\n", ret
);
2899 ok(os1
.base_ios
.state
== IOSTATE_failbit
, "expected %d got %d\n", IOSTATE_failbit
, os1
.base_ios
.state
);
2900 os1
.base_ios
.state
= IOSTATE_goodbit
;
2901 os1
.base_ios
.tie
= &os2
;
2902 os2
.base_ios
.sb
= NULL
;
2903 if (0) /* crashes on native */
2904 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2905 os2
.base_ios
.sb
= &fb2
.base
;
2906 os2
.base_ios
.state
= IOSTATE_badbit
;
2907 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "We've known each other", 22);
2908 ok(ret
== 22, "expected 22 got %d\n", ret
);
2909 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2910 ok(ret
== 1, "expected 1 got %d\n", ret
);
2911 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2912 ok(os2
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os2
.base_ios
.state
);
2913 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
2914 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 22, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 22, fb1
.base
.pptr
);
2915 ok(fb2
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb2
.base
.pbase
);
2916 ok(fb2
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb2
.base
.pptr
);
2919 os1
.base_ios
.state
= IOSTATE_badbit
;
2920 os1
.base_ios
.width
= 0xab;
2921 call_func1(p_ostream_osfx
, &os1
);
2922 ok(os1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, os1
.base_ios
.state
);
2923 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
2924 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
2925 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 22, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 22, fb1
.base
.pptr
);
2926 os1
.base_ios
.state
= IOSTATE_goodbit
;
2927 ret
= (int) call_func1(p_ostream_opfx
, &os1
);
2928 ok(ret
== 1, "expected 1 got %d\n", ret
);
2929 os1
.base_ios
.sb
= NULL
;
2930 if (0) /* crashes on native */
2931 call_func1(p_ostream_osfx
, &os1
);
2932 os1
.base_ios
.sb
= &fb1
.base
;
2933 os1
.base_ios
.flags
= FLAGS_unitbuf
;
2934 call_func1(p_ostream_osfx
, &os1
);
2935 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2936 ok(os1
.base_ios
.flags
== FLAGS_unitbuf
, "expected %d got %d\n", FLAGS_unitbuf
, os1
.base_ios
.flags
);
2937 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2938 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2941 ret
= (int) call_func3(p_streambuf_xsputn
, &fb2
.base
, "for so long", 11);
2942 ok(ret
== 11, "expected 11 got %d\n", ret
);
2943 os1
.base_ios
.state
= IOSTATE_badbit
;
2944 os1
.base_ios
.width
= 2;
2945 pos
= call_func2(p_ostream_put_char
, &os1
, 'a');
2946 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2947 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2948 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2949 ok(os1
.base_ios
.width
== 2, "expected 2 got %d\n", os1
.base_ios
.width
);
2950 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2951 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2952 ok(fb2
.base
.pbase
== fb2
.base
.base
, "wrong put base, expected %p got %p\n", fb2
.base
.base
, fb2
.base
.pbase
);
2953 ok(fb2
.base
.pptr
== fb2
.base
.base
+ 11, "wrong put pointer, expected %p got %p\n", fb2
.base
.base
+ 11, fb2
.base
.pptr
);
2954 os1
.base_ios
.state
= IOSTATE_goodbit
;
2955 pos
= call_func2(p_ostream_put_char
, &os1
, 'a');
2956 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2957 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2958 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
2959 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2960 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2961 ok(fb2
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb2
.base
.pbase
);
2962 ok(fb2
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb2
.base
.pptr
);
2963 os1
.base_ios
.flags
= 0;
2964 pos
= call_func2(p_ostream_put_char
, &os1
, 'b');
2965 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2966 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2967 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
2968 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 1, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 1, fb1
.base
.pptr
);
2969 os1
.base_ios
.sb
= NULL
;
2970 if (0) /* crashes on native */
2971 pos
= call_func2(p_ostream_put_char
, &os1
, 'c');
2972 os1
.base_ios
.sb
= &fb1
.base
;
2973 os1
.base_ios
.width
= 5;
2974 call_func1(p_filebuf_sync
, &fb1
);
2977 pos
= call_func2(p_ostream_put_char
, &os1
, 'c');
2978 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2979 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2980 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2981 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
2982 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2983 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2987 pos
= call_func3(p_ostream_write_char
, &os1
, "Your", 4);
2988 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2989 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
2990 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
2991 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
2992 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
2993 os1
.base_ios
.state
= IOSTATE_goodbit
;
2994 os1
.base_ios
.width
= 1;
2995 pos
= call_func3(p_ostream_write_char
, &os1
, "heart's", 7);
2996 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
2997 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
2998 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
2999 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
3000 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 7, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 7, fb1
.base
.pptr
);
3001 os1
.base_ios
.sb
= NULL
;
3002 if (0) /* crashes on native */
3003 pos
= call_func3(p_ostream_write_char
, &os1
, "been", 4);
3004 os1
.base_ios
.sb
= &fb1
.base
;
3005 os1
.base_ios
.width
= 5;
3006 call_func1(p_filebuf_sync
, &fb1
);
3009 pos
= call_func3(p_ostream_write_char
, &os1
, "aching,", 7);
3010 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3011 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3012 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3013 ok(os1
.base_ios
.width
== 0, "expected 0 got %d\n", os1
.base_ios
.width
);
3014 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
3015 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
3019 os1
.base_ios
.state
= IOSTATE_eofbit
;
3020 pos
= call_func3(p_ostream_seekp_offset
, &os1
, 0, SEEKDIR_beg
);
3021 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3022 ok(os1
.base_ios
.state
== IOSTATE_eofbit
, "expected %d got %d\n", IOSTATE_eofbit
, os1
.base_ios
.state
);
3023 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "but", 3);
3024 ok(ret
== 3, "expected 3 got %d\n", ret
);
3025 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
3026 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 3, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 3, fb1
.base
.pptr
);
3027 pos
= call_func3(p_ostream_seekp_offset
, &os1
, 0, SEEKDIR_end
);
3028 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3029 ok(os1
.base_ios
.state
== IOSTATE_eofbit
, "expected %d got %d\n", IOSTATE_eofbit
, os1
.base_ios
.state
);
3030 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
3031 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
3032 pos
= call_func3(p_ostream_seekp_offset
, &os1
, -1, SEEKDIR_beg
);
3033 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3034 ok(os1
.base_ios
.state
== (IOSTATE_eofbit
|IOSTATE_failbit
), "expected %d got %d\n",
3035 IOSTATE_eofbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3036 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "You're too shy", 14);
3037 ok(ret
== 14, "expected 14 got %d\n", ret
);
3038 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
3039 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 14, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 14, fb1
.base
.pptr
);
3040 pos
= call_func2(p_ostream_seekp
, &os1
, 0);
3041 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3042 ok(os1
.base_ios
.state
== (IOSTATE_eofbit
|IOSTATE_failbit
), "expected %d got %d\n",
3043 IOSTATE_eofbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3044 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
3045 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
3046 os1
.base_ios
.state
= IOSTATE_badbit
;
3047 pos
= call_func2(p_ostream_seekp
, &os1
, -1);
3048 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3049 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3050 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3053 ret
= (int) call_func1(p_ostream_tellp
, &os1
);
3054 ok(ret
== 0, "wrong return, expected 0 got %d\n", ret
);
3055 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3056 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3057 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "to say it", 9);
3058 ok(ret
== 9, "expected 9 got %d\n", ret
);
3059 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
3060 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 9, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 9, fb1
.base
.pptr
);
3061 ret
= (int) call_func1(p_ostream_tellp
, &os1
);
3062 ok(ret
== 9, "wrong return, expected 9 got %d\n", ret
);
3063 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3064 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3065 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
3066 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
3067 os1
.base_ios
.state
= IOSTATE_eofbit
;
3070 ret
= (int) call_func1(p_ostream_tellp
, &os1
);
3071 ok(ret
== EOF
, "wrong return, expected EOF got %d\n", ret
);
3072 ok(os1
.base_ios
.state
== (IOSTATE_eofbit
|IOSTATE_failbit
), "expected %d got %d\n",
3073 IOSTATE_eofbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3077 os1
.base_ios
.state
= IOSTATE_eofbit
;
3078 os1
.base_ios
.flags
=
3079 FLAGS_right
|FLAGS_hex
|FLAGS_showbase
|FLAGS_showpoint
|FLAGS_showpos
|FLAGS_uppercase
|FLAGS_fixed
;
3080 os1
.base_ios
.fill
= 'z';
3081 os1
.base_ios
.width
= 9;
3082 pos
= call_func3(p_ostream_writepad
, &os1
, "a", "b");
3083 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3084 ok(!strncmp(fb1
.base
.pptr
- 9, "zzzzzzzab", 9), "expected 'zzzzzzzab' got '%s'\n", fb1
.base
.pptr
- 9);
3085 pos
= call_func3(p_ostream_writepad
, &os1
, "aa", "bb");
3086 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3087 ok(!strncmp(fb1
.base
.pptr
- 9, "zzzzzaabb", 9), "expected 'zzzzzaabb' got '%s'\n", fb1
.base
.pptr
- 9);
3088 pos
= call_func3(p_ostream_writepad
, &os1
, "aaaaa", "bbbbb");
3089 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3090 ok(!strncmp(fb1
.base
.pptr
- 10, "aaaaabbbbb", 10), "expected 'aaaaabbbbb' got '%s'\n", fb1
.base
.pptr
- 10);
3091 os1
.base_ios
.flags
|= FLAGS_internal
;
3092 pos
= call_func3(p_ostream_writepad
, &os1
, "aa", "bb");
3093 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3094 ok(!strncmp(fb1
.base
.pptr
- 9, "aazzzzzbb", 9), "expected 'aazzzzzbb' got '%s'\n", fb1
.base
.pptr
- 9);
3095 os1
.base_ios
.flags
&= ~FLAGS_right
;
3096 pos
= call_func3(p_ostream_writepad
, &os1
, "a", "b");
3097 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3098 ok(!strncmp(fb1
.base
.pptr
- 9, "azzzzzzzb", 9), "expected 'azzzzzzzb' got '%s'\n", fb1
.base
.pptr
- 9);
3099 os1
.base_ios
.width
= 6;
3100 pos
= call_func3(p_ostream_writepad
, &os1
, "1", "2");
3101 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3102 ok(!strncmp(fb1
.base
.pptr
- 6, "1zzzz2", 6), "expected '1zzzz2' got '%s'\n", fb1
.base
.pptr
- 6);
3103 pos
= call_func3(p_ostream_writepad
, &os1
, "12345678", "");
3104 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3105 ok(!strncmp(fb1
.base
.pptr
- 8, "12345678", 8), "expected '12345678' got '%s'\n", fb1
.base
.pptr
- 8);
3106 os1
.base_ios
.flags
|= FLAGS_left
;
3107 pos
= call_func3(p_ostream_writepad
, &os1
, "z1", "2z");
3108 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3109 ok(!strncmp(fb1
.base
.pptr
- 6, "z1zz2z", 6), "expected 'z1zz2z' got '%s'\n", fb1
.base
.pptr
- 6);
3110 os1
.base_ios
.flags
&= ~FLAGS_internal
;
3111 pos
= call_func3(p_ostream_writepad
, &os1
, "hell", "o");
3112 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3113 ok(!strncmp(fb1
.base
.pptr
- 6, "helloz", 6), "expected 'helloz' got '%s'\n", fb1
.base
.pptr
- 6);
3114 os1
.base_ios
.flags
|= FLAGS_right
;
3115 pos
= call_func3(p_ostream_writepad
, &os1
, "a", "b");
3116 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3117 ok(!strncmp(fb1
.base
.pptr
- 6, "abzzzz", 6), "expected 'abzzzz' got '%s'\n", fb1
.base
.pptr
- 6);
3118 if (0) /* crashes on native */
3119 pos
= call_func3(p_ostream_writepad
, &os1
, NULL
, "o");
3120 pos
= call_func3(p_ostream_writepad
, &os1
, "", "hello");
3121 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3122 ok(!strncmp(fb1
.base
.pptr
- 6, "helloz", 6), "expected 'helloz' got '%s'\n", fb1
.base
.pptr
- 6);
3123 os1
.base_ios
.fill
= '*';
3124 pos
= call_func3(p_ostream_writepad
, &os1
, "", "");
3125 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3126 ok(!strncmp(fb1
.base
.pptr
- 6, "******", 6), "expected '******' got '%s'\n", fb1
.base
.pptr
- 6);
3127 pos
= call_func3(p_ostream_writepad
, &os1
, "aa", "");
3128 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3129 ok(!strncmp(fb1
.base
.pptr
- 6, "aa****", 6), "expected 'aa****' got '%s'\n", fb1
.base
.pptr
- 6);
3130 os1
.base_ios
.flags
= 0;
3131 pos
= call_func3(p_ostream_writepad
, &os1
, "a", "b");
3132 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3133 ok(!strncmp(fb1
.base
.pptr
- 6, "****ab", 6), "expected '****ab' got '%s'\n", fb1
.base
.pptr
- 6);
3134 call_func1(p_filebuf_sync
, &fb1
);
3136 pos
= call_func3(p_ostream_writepad
, &os1
, "aa", "bb");
3137 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3138 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
|IOSTATE_eofbit
), "expected %d got %d\n",
3139 IOSTATE_badbit
|IOSTATE_failbit
|IOSTATE_eofbit
, os1
.base_ios
.state
);
3140 os1
.base_ios
.state
= IOSTATE_goodbit
;
3141 pos
= call_func3(p_ostream_writepad
, &os1
, "", "");
3142 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3143 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3144 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3145 os1
.base_ios
.state
= IOSTATE_goodbit
;
3146 os1
.base_ios
.width
= 0;
3147 pos
= call_func3(p_ostream_writepad
, &os1
, "", "");
3148 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3149 ok(os1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, os1
.base_ios
.state
);
3150 pos
= call_func3(p_ostream_writepad
, &os1
, "a", "");
3151 ok(pos
== &os1
, "wrong return, expected %p got %p\n", &os1
, pos
);
3152 ok(os1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_failbit
), "expected %d got %d\n",
3153 IOSTATE_badbit
|IOSTATE_failbit
, os1
.base_ios
.state
);
3156 call_func1(p_ostream_vbase_dtor
, &os1
);
3157 call_func1(p_ostream_vbase_dtor
, &os2
);
3158 call_func1(p_filebuf_dtor
, &fb1
);
3159 call_func1(p_filebuf_dtor
, &fb2
);
3160 ok(_unlink(filename1
) == 0, "Couldn't unlink file named '%s'\n", filename1
);
3161 ok(_unlink(filename2
) == 0, "Couldn't unlink file named '%s'\n", filename2
);
3164 static void test_ostream_print(void)
3166 const BOOL is_64
= (sizeof(void*) == 8);
3168 strstreambuf ssb
, ssb_test1
, ssb_test2
, ssb_test3
, *pssb
;
3169 LONG length
, expected_length
;
3172 char param_char
[] = {'a', '9', 'e'};
3173 const char* param_str
[] = {"Test", "800", "3.14159", " Test"};
3174 int param_int
[] = {0, 7, 10, 24 ,55, 1024, 1023, 65536, 2147483647, 2147483648u, 4294967295u, -20};
3175 float param_float
[] = {1.0f
, 0.0f
, 4.25f
, 3.999f
, 12.0005f
, 15.33582f
, 15.0f
, 15.22f
, 21.123f
, 0.1f
,
3176 13.14159f
, 0.00013f
, 0.000013f
, INFINITY
, -INFINITY
, NAN
};
3177 double param_double
[] = {1.0, 3.141592653589793238, 314.1592653589793238, 314.159265358979,
3178 1231314.269811862199, 9.961472e6
, 8.98846567431e307
, DBL_MAX
};
3179 void* param_ptr
[] = {NULL
, (void*) 0xdeadbeef, (void*) 0x1234cdef, (void*) 0x1, (void*) 0xffffffff};
3180 streambuf
* param_streambuf
[] = {NULL
, &ssb_test1
.base
, &ssb_test2
.base
, &ssb_test3
.base
};
3181 struct ostream_print_test
{
3182 enum { type_chr
, type_str
, type_int
, type_flt
, type_dbl
, type_ptr
, type_sbf
} type
;
3189 const char *expected_text
;
3190 ios_io_state expected_flags
;
3193 {type_chr
, /* 'a' */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3194 {type_chr
, /* 'a' */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3195 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, 0, 6, ' ', 0, "a", IOSTATE_goodbit
},
3196 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, 0, 6, ' ', 4, " a", IOSTATE_goodbit
},
3197 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, 0, 6, 'x', 3, "xxa", IOSTATE_goodbit
},
3198 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, FLAGS_left
, 6, ' ', 4, "a ", IOSTATE_goodbit
},
3199 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, FLAGS_left
|FLAGS_internal
, 6, ' ', 4, " a", IOSTATE_goodbit
},
3200 {type_chr
, /* 'a' */ 0, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_hex
|FLAGS_showbase
, 6, ' ', 4, " a", IOSTATE_goodbit
},
3201 {type_chr
, /* '9' */ 1, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_showbase
|FLAGS_uppercase
, 6, 'i', 2, "i9", IOSTATE_goodbit
},
3202 {type_chr
, /* '9' */ 1, IOSTATE_goodbit
, FLAGS_showpos
|FLAGS_scientific
, 0, 'i', 2, "i9", IOSTATE_goodbit
},
3203 {type_chr
, /* 'e' */ 2, IOSTATE_goodbit
, FLAGS_left
|FLAGS_right
|FLAGS_uppercase
, 0, '*', 8, "e*******", IOSTATE_goodbit
},
3205 {type_str
, /* "Test" */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3206 {type_str
, /* "Test" */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3207 {type_str
, /* "Test" */ 0, IOSTATE_goodbit
, 0, 6, ' ', 0, "Test", IOSTATE_goodbit
},
3208 {type_str
, /* "Test" */ 0, IOSTATE_goodbit
, 0, 6, ' ', 6, " Test", IOSTATE_goodbit
},
3209 {type_str
, /* "Test" */ 0, IOSTATE_goodbit
, FLAGS_internal
, 6, 'x', 6, "xxTest", IOSTATE_goodbit
},
3210 {type_str
, /* "Test" */ 0, IOSTATE_goodbit
, FLAGS_left
, 6, ' ', 5, "Test ", IOSTATE_goodbit
},
3211 {type_str
, /* "Test" */ 0, IOSTATE_goodbit
, FLAGS_left
|FLAGS_hex
|FLAGS_showpoint
, 6, '?', 6, "Test??", IOSTATE_goodbit
},
3212 {type_str
, /* "800" */ 1, IOSTATE_goodbit
, FLAGS_showbase
|FLAGS_showpos
, 6, ' ', 4, " 800", IOSTATE_goodbit
},
3213 {type_str
, /* "3.14159" */ 2, IOSTATE_goodbit
, FLAGS_scientific
, 2, 'x', 2, "3.14159", IOSTATE_goodbit
},
3214 {type_str
, /* " Test" */ 3, IOSTATE_goodbit
, FLAGS_skipws
, 6, 'x', 2, " Test", IOSTATE_goodbit
},
3216 {type_int
, /* 0 */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3217 {type_int
, /* 0 */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3218 {type_int
, /* 0 */ 0, IOSTATE_goodbit
, 0, 6, ' ', 4, " 0", IOSTATE_goodbit
},
3219 {type_int
, /* 7 */ 1, IOSTATE_goodbit
, 0, 6, '0', 3, "007", IOSTATE_goodbit
},
3220 {type_int
, /* 10 */ 2, IOSTATE_goodbit
, FLAGS_left
, 6, ' ', 5, "10 ", IOSTATE_goodbit
},
3221 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_left
|FLAGS_hex
, 6, ' ', 0, "18", IOSTATE_goodbit
},
3222 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_left
|FLAGS_hex
|FLAGS_showbase
, 6, ' ', 0, "0x18", IOSTATE_goodbit
},
3223 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_hex
|FLAGS_showbase
, 6, '*', 8, "0x****18", IOSTATE_goodbit
},
3224 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_showbase
, 6, '*', 4, "*030", IOSTATE_goodbit
},
3225 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_dec
|FLAGS_showbase
, 6, ' ', 0, "030", IOSTATE_goodbit
},
3226 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_dec
|FLAGS_hex
|FLAGS_showbase
, 6, ' ', 0, "0x18", IOSTATE_goodbit
},
3227 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_left
|FLAGS_oct
|FLAGS_hex
, 6, ' ', 5, "18 ", IOSTATE_goodbit
},
3228 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_dec
|FLAGS_hex
|FLAGS_showbase
, 6, ' ', 0, "0x18", IOSTATE_goodbit
},
3229 {type_int
, /* 24 */ 3, IOSTATE_goodbit
, FLAGS_dec
|FLAGS_showbase
, 6, ' ', 0, "24", IOSTATE_goodbit
},
3230 {type_int
, /* 55 */ 4, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
|FLAGS_uppercase
, 6, ' ', 0, "0X37", IOSTATE_goodbit
},
3231 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
|FLAGS_showpoint
|FLAGS_uppercase
, 6, ' ', 0, "0X400", IOSTATE_goodbit
},
3232 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
|FLAGS_showpos
, 6, ' ', 0, "0x400", IOSTATE_goodbit
},
3233 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showpos
, 6, ' ', 0, "400", IOSTATE_goodbit
},
3234 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_showpos
, 6, ' ', 0, "2000", IOSTATE_goodbit
},
3235 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_oct
|FLAGS_showbase
, 6, 'x', 8, "0xxx2000", IOSTATE_goodbit
},
3236 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_showbase
|FLAGS_showpoint
|FLAGS_showpos
, 6, ' ', 0, "+1024", IOSTATE_goodbit
},
3237 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_dec
|FLAGS_showbase
|FLAGS_showpos
, 6, 'a', 6, "a+1024", IOSTATE_goodbit
},
3238 {type_int
, /* 1024 */ 5, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_showbase
|FLAGS_showpos
, 6, ' ', 8, "+ 1024", IOSTATE_goodbit
},
3239 {type_int
, /* 1023 */ 6, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
|FLAGS_uppercase
, 6, ' ', 0, "0X3FF", IOSTATE_goodbit
},
3240 {type_int
, /* 1023 */ 6, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
|FLAGS_scientific
, 6, ' ', 0, "0x3ff", IOSTATE_goodbit
},
3241 {type_int
, /* 65536 */ 7, IOSTATE_goodbit
, FLAGS_right
|FLAGS_showpos
|FLAGS_fixed
, 6, ' ', 8, " +65536", IOSTATE_goodbit
},
3242 {type_int
, /* 2147483647 */ 8, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showbase
, 6, ' ', 0, "0x7fffffff", IOSTATE_goodbit
},
3243 {type_int
, /* 2147483648 */ 9, IOSTATE_goodbit
, FLAGS_dec
, 6, ' ', 0, "-2147483648", IOSTATE_goodbit
},
3244 {type_int
, /* 4294967295 */ 10, IOSTATE_goodbit
, FLAGS_internal
, 6, ' ', 8, " -1", IOSTATE_goodbit
},
3245 {type_int
, /* -20 */ 11, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_oct
|FLAGS_showbase
, 6, ' ', 8, "037777777754", IOSTATE_goodbit
},
3246 {type_int
, /* -20 */ 11, IOSTATE_goodbit
, FLAGS_dec
|FLAGS_showpos
, 6, ' ', 0, "-20", IOSTATE_goodbit
},
3247 {type_int
, /* 0 */ 0, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_showpos
, 6, ' ', 8, " 0", IOSTATE_goodbit
},
3249 {type_flt
, /* 1.0f */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3250 {type_flt
, /* 1.0f */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3251 {type_flt
, /* 1.0f */ 0, IOSTATE_goodbit
, 0, 6, ' ', 0, "1", IOSTATE_goodbit
},
3252 {type_flt
, /* 0.0f */ 1, IOSTATE_goodbit
, 0, 6, ' ', 0, "0", IOSTATE_goodbit
},
3253 {type_flt
, /* 4.25f */ 2, IOSTATE_goodbit
, 0, 6, ' ', 0, "4.25", IOSTATE_goodbit
},
3254 {type_flt
, /* 3.999f */ 3, IOSTATE_goodbit
, 0, 6, ' ', 0, "3.999", IOSTATE_goodbit
},
3255 {type_flt
, /* 3.999f */ 3, IOSTATE_goodbit
, 0, 3, ' ', 0, "4", IOSTATE_goodbit
},
3256 {type_flt
, /* 12.0005f */ 4, IOSTATE_goodbit
, 0, 6, ' ', 0, "12.0005", IOSTATE_goodbit
},
3257 {type_flt
, /* 12.0005f */ 4, IOSTATE_goodbit
, 0, 5, ' ', 0, "12", IOSTATE_goodbit
},
3258 {type_flt
, /* 15.33582f */ 5, IOSTATE_goodbit
, 0, 4, ' ', 0, "15.34", IOSTATE_goodbit
},
3259 {type_flt
, /* 15.0f */ 6, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_hex
|FLAGS_showbase
, 6, ' ', 4, " 15", IOSTATE_goodbit
},
3260 {type_flt
, /* 15.22f */ 7, IOSTATE_goodbit
, FLAGS_left
|FLAGS_hex
|FLAGS_showbase
, 3, ' ', 6, "15.2 ", IOSTATE_goodbit
},
3261 {type_flt
, /* 15.22 */ 7, IOSTATE_goodbit
, FLAGS_internal
, 3, 'x', 6, "xx15.2", IOSTATE_goodbit
},
3262 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_showpoint
, 9, ' ', 0, "21.1230", IOSTATE_goodbit
},
3263 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_showpos
, 9, ' ', 0, "+21.123", IOSTATE_goodbit
},
3264 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_showpos
, 9, ' ', 8, "+ 21.123", IOSTATE_goodbit
},
3265 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_showpos
, 0, ' ', 0, "+2e+001", IOSTATE_goodbit
},
3266 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, 0, 1, ' ', 0, "2e+001", IOSTATE_goodbit
},
3267 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_showpos
, 2, ' ', 0, "+21", IOSTATE_goodbit
},
3268 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, 0, 4, ' ', 0, "21.12", IOSTATE_goodbit
},
3269 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_scientific
, 2, ' ', 0, "2.11e+001", IOSTATE_goodbit
},
3270 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_scientific
, 4, ' ', 0, "2.1123e+001", IOSTATE_goodbit
},
3271 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_scientific
, 6, ' ', 0, "2.112300e+001", IOSTATE_goodbit
},
3272 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_scientific
|FLAGS_uppercase
, 2, ' ', 0, "2.11E+001", IOSTATE_goodbit
},
3273 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_scientific
|FLAGS_uppercase
, 2, '*', 10, "*2.11E+001", IOSTATE_goodbit
},
3274 {type_flt
, /* 21.123f */ 8, IOSTATE_goodbit
, FLAGS_fixed
, 6, ' ', 0, "21.122999", IOSTATE_goodbit
},
3275 {type_flt
, /* 0.1f */ 9, IOSTATE_goodbit
, FLAGS_fixed
, 6, ' ', 0, "0.100000", IOSTATE_goodbit
},
3276 {type_flt
, /* 0.1f */ 9, IOSTATE_goodbit
, FLAGS_scientific
, 6, ' ', 0, "1.000000e-001", IOSTATE_goodbit
},
3277 {type_flt
, /* 13.14159f */ 10, IOSTATE_goodbit
, FLAGS_fixed
, 3, ' ', 0, "13.142", IOSTATE_goodbit
},
3278 {type_flt
, /* 13.14159f */ 10, IOSTATE_goodbit
, FLAGS_fixed
, 8, ' ', 0, "13.141590", IOSTATE_goodbit
},
3279 {type_flt
, /* 13.14159f */ 10, IOSTATE_goodbit
, FLAGS_fixed
|FLAGS_showpoint
, 8, ' ', 0, "13.141590", IOSTATE_goodbit
},
3280 {type_flt
, /* 13.14159f */ 10, IOSTATE_goodbit
, FLAGS_scientific
|FLAGS_fixed
, 8, ' ', 0, "13.1416", IOSTATE_goodbit
},
3281 {type_flt
, /* 13.14159f */ 10, IOSTATE_goodbit
, FLAGS_scientific
|FLAGS_fixed
, 2, ' ', 0, "13", IOSTATE_goodbit
},
3282 {type_flt
, /* 0.00013f */ 11, IOSTATE_goodbit
, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit
},
3283 {type_flt
, /* 0.00013f */ 11, IOSTATE_goodbit
, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit
},
3284 {type_flt
, /* 0.00013f */ 11, IOSTATE_goodbit
, 0, -1, ' ', 0, "0.00013", IOSTATE_goodbit
},
3285 {type_flt
, /* 0.000013f */ 12, IOSTATE_goodbit
, 0, 4, ' ', 0, "1.3e-005", IOSTATE_goodbit
},
3286 {type_flt
, /* 0.000013f */ 12, IOSTATE_goodbit
, FLAGS_showpoint
, 4, ' ', 0, "1.300e-005", IOSTATE_goodbit
},
3287 {type_flt
, /* 0.000013f */ 12, IOSTATE_goodbit
, FLAGS_showpoint
, 6, ' ', 0, "1.30000e-005", IOSTATE_goodbit
},
3288 {type_flt
, /* INFINITY */ 13, IOSTATE_goodbit
, 0, 6, ' ', 0, "1.#INF", IOSTATE_goodbit
},
3289 {type_flt
, /* INFINITY */ 13, IOSTATE_goodbit
, 0, 4, ' ', 0, "1.#IO", IOSTATE_goodbit
},
3290 {type_flt
, /* -INFINITY */ 14, IOSTATE_goodbit
, 0, 6, ' ', 0, "-1.#INF", IOSTATE_goodbit
},
3291 {type_flt
, /* NAN */ 15, IOSTATE_goodbit
, 0, 6, ' ', 0, "1.#QNAN", IOSTATE_goodbit
},
3293 {type_dbl
, /* 1.0 */ 0, IOSTATE_goodbit
, 0, 6, ' ', 0, "1", IOSTATE_goodbit
},
3294 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, 0, 6, ' ', 0, "3.14159", IOSTATE_goodbit
},
3295 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, 0, 9, ' ', 0, "3.14159265", IOSTATE_goodbit
},
3296 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, 0, 12, ' ', 0, "3.14159265359", IOSTATE_goodbit
},
3297 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, 0, 15, ' ', 0, "3.14159265358979", IOSTATE_goodbit
},
3298 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, 0, 16, ' ', 0, "3.14159265358979", IOSTATE_goodbit
},
3299 {type_dbl
, /* 314.1592653589793238 */ 2, IOSTATE_goodbit
, 0, 16, ' ', 0, "314.159265358979", IOSTATE_goodbit
},
3300 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, FLAGS_scientific
, 16, ' ', 0, "3.141592653589793e+000", IOSTATE_goodbit
},
3301 {type_dbl
, /* 314.1592653589793238 */ 2, IOSTATE_goodbit
, FLAGS_scientific
, 16, ' ', 0, "3.141592653589793e+002", IOSTATE_goodbit
},
3302 {type_dbl
, /* 3.141592653589793238 */ 1, IOSTATE_goodbit
, FLAGS_fixed
, -1, ' ', 0, "3.141592653589793", IOSTATE_goodbit
},
3303 {type_dbl
, /* 314.159265358979 */ 3, IOSTATE_goodbit
, FLAGS_fixed
, 12, ' ', 0, "314.159265358979", IOSTATE_goodbit
},
3304 {type_dbl
, /* 1231314.269811862199 */ 4, IOSTATE_goodbit
, FLAGS_fixed
, 10, ' ', 0, "1231314.2698118621", IOSTATE_goodbit
},
3305 {type_dbl
, /* 9.961472e6 */ 5, IOSTATE_goodbit
, FLAGS_fixed
, 500, ' ', 0, "9961472.000000000000000", IOSTATE_goodbit
},
3306 /* crashes on XP/2k3 {type_dbl, 8.98846567431e307 6, IOSTATE_goodbit, FLAGS_fixed, 500, ' ', 0, "", IOSTATE_goodbit}, */
3307 /* crashes on XP/2k3 {type_dbl, DBL_MAX 7, IOSTATE_goodbit, FLAGS_fixed|FLAGS_showpos, 500, ' ', 5, " ", IOSTATE_goodbit}, */
3308 {type_dbl
, /* DBL_MAX */ 7, IOSTATE_goodbit
, FLAGS_showpoint
, 500, ' ', 0, "1.79769313486232e+308", IOSTATE_goodbit
},
3310 {type_ptr
, /* NULL */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3311 {type_ptr
, /* NULL */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3312 {type_ptr
, /* NULL */ 0, IOSTATE_goodbit
, 0, 6, ' ', 0,
3313 is_64
? "0x0000000000000000" : "0x00000000", IOSTATE_goodbit
},
3314 {type_ptr
, /* 0xdeadbeef */ 1, IOSTATE_goodbit
, 0, 6, ' ', 0,
3315 is_64
? "0x00000000DEADBEEF" : "0xDEADBEEF", IOSTATE_goodbit
},
3316 {type_ptr
, /* 0xdeadbeef */ 1, IOSTATE_goodbit
, 0, 6, '*', 12,
3317 is_64
? "0x00000000DEADBEEF" : "**0xDEADBEEF", IOSTATE_goodbit
},
3318 {type_ptr
, /* 0xdeadbeef */ 1, IOSTATE_goodbit
, FLAGS_internal
, 6, ' ', 14,
3319 is_64
? "0x00000000DEADBEEF" : "0x DEADBEEF", IOSTATE_goodbit
},
3320 {type_ptr
, /* 0xdeadbeef */ 1, IOSTATE_goodbit
, FLAGS_left
, 6, 'x', 11,
3321 is_64
? "0x00000000DEADBEEF" : "0xDEADBEEFx", IOSTATE_goodbit
},
3322 {type_ptr
, /* 0x1234cdef */ 2, IOSTATE_goodbit
, FLAGS_dec
|FLAGS_showpos
, 6, ' ', 0,
3323 is_64
? "0x000000001234CDEF" : "0x1234CDEF", IOSTATE_goodbit
},
3324 {type_ptr
, /* 0x1 */ 3, IOSTATE_goodbit
, FLAGS_oct
|FLAGS_showbase
, 6, ' ', 0,
3325 is_64
? "0x0000000000000001" : "0x00000001", IOSTATE_goodbit
},
3326 {type_ptr
, /* 0xffffffff */ 4, IOSTATE_goodbit
, FLAGS_hex
|FLAGS_showpoint
, 6, ' ', 0,
3327 is_64
? "0x00000000FFFFFFFF" : "0xFFFFFFFF", IOSTATE_goodbit
},
3328 {type_ptr
, /* 0xffffffff */ 4, IOSTATE_goodbit
, FLAGS_uppercase
|FLAGS_fixed
, 6, ' ', 0,
3329 is_64
? "0X00000000FFFFFFFF" : "0XFFFFFFFF", IOSTATE_goodbit
},
3330 {type_ptr
, /* 0x1 */ 3, IOSTATE_goodbit
, FLAGS_uppercase
, 6, ' ', 0,
3331 is_64
? "0X0000000000000001" : "0X00000001", IOSTATE_goodbit
},
3332 {type_ptr
, /* NULL */ 0, IOSTATE_goodbit
, FLAGS_uppercase
, 6, ' ', 0,
3333 is_64
? "0x0000000000000000" : "0x00000000", IOSTATE_goodbit
},
3334 {type_ptr
, /* NULL */ 0, IOSTATE_goodbit
, FLAGS_uppercase
|FLAGS_showbase
, 12, 'x', 12,
3335 is_64
? "0x0000000000000000" : "xx0x00000000", IOSTATE_goodbit
},
3336 {type_ptr
, /* NULL */ 0, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_uppercase
|FLAGS_showbase
, 6, '?', 20,
3337 is_64
? "0x??0000000000000000" : "0x??????????00000000", IOSTATE_goodbit
},
3339 {type_sbf
, /* NULL */ 0, IOSTATE_badbit
, 0, 6, ' ', 0, "", IOSTATE_badbit
|IOSTATE_failbit
},
3340 {type_sbf
, /* NULL */ 0, IOSTATE_eofbit
, 0, 6, ' ', 0, "", IOSTATE_eofbit
|IOSTATE_failbit
},
3341 /* crashes on native {STREAMBUF, NULL 0, IOSTATE_goodbit, 0, 6, ' ', 0, "", IOSTATE_goodbit}, */
3342 {type_sbf
, /* &ssb_test1.base */ 1, IOSTATE_goodbit
, FLAGS_skipws
|FLAGS_showpos
|FLAGS_uppercase
,
3343 6, ' ', 0, " we both know what's been going on ", IOSTATE_goodbit
},
3344 {type_sbf
, /* &ssb_test1.base */ 2, IOSTATE_goodbit
, FLAGS_left
|FLAGS_hex
|FLAGS_showbase
,
3345 6, '*', 50, "123 We know the game and", IOSTATE_goodbit
},
3346 {type_sbf
, /* &ssb_test1.base */ 3, IOSTATE_goodbit
, FLAGS_internal
|FLAGS_scientific
|FLAGS_showpoint
,
3347 6, '*', 50, "we're gonna play it 3.14159", IOSTATE_goodbit
}
3350 pssb
= call_func1(p_strstreambuf_ctor
, &ssb
);
3351 ok(pssb
== &ssb
, "wrong return, expected %p got %p\n", &ssb
, pssb
);
3352 pos
= call_func3(p_ostream_sb_ctor
, &os
, &ssb
.base
, TRUE
);
3353 ok(pos
== &os
, "wrong return, expected %p got %p\n", &os
, pos
);
3354 pssb
= call_func1(p_strstreambuf_ctor
, &ssb_test1
);
3355 ok(pssb
== &ssb_test1
, "wrong return, expected %p got %p\n", &ssb_test1
, pssb
);
3356 ret
= (int) call_func3(p_streambuf_xsputn
, &ssb_test1
.base
, " we both know what's been going on ", 36);
3357 ok(ret
== 36, "expected 36 got %d\n", ret
);
3358 pssb
= call_func1(p_strstreambuf_ctor
, &ssb_test2
);
3359 ok(pssb
== &ssb_test2
, "wrong return, expected %p got %p\n", &ssb_test2
, pssb
);
3360 ret
= (int) call_func3(p_streambuf_xsputn
, &ssb_test2
.base
, "123 We know the game and", 24);
3361 ok(ret
== 24, "expected 24 got %d\n", ret
);
3362 pssb
= call_func1(p_strstreambuf_ctor
, &ssb_test3
);
3363 ok(pssb
== &ssb_test3
, "wrong return, expected %p got %p\n", &ssb_test3
, pssb
);
3364 ret
= (int) call_func3(p_streambuf_xsputn
, &ssb_test3
.base
, "we're gonna play it 3.14159", 27);
3365 ok(ret
== 27, "expected 27 got %d\n", ret
);
3367 for (i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); i
++) {
3368 os
.base_ios
.state
= tests
[i
].state
;
3369 os
.base_ios
.flags
= tests
[i
].flags
;
3370 os
.base_ios
.precision
= tests
[i
].precision
;
3371 os
.base_ios
.fill
= tests
[i
].fill
;
3372 os
.base_ios
.width
= tests
[i
].width
;
3373 ssb
.base
.pptr
= ssb
.base
.pbase
;
3375 switch (tests
[i
].type
) {
3377 pos
= call_func2(p_ostream_print_char
, &os
, (int) param_char
[tests
[i
].param_index
]); break;
3379 pos
= call_func2(p_ostream_print_str
, &os
, param_str
[tests
[i
].param_index
]); break;
3381 pos
= call_func2(p_ostream_print_int
, &os
, param_int
[tests
[i
].param_index
]); break;
3383 pos
= call_func2_ptr_flt(p_ostream_print_float
, &os
, param_float
[tests
[i
].param_index
]); break;
3385 pos
= call_func2_ptr_dbl(p_ostream_print_double
, &os
, param_double
[tests
[i
].param_index
]); break;
3387 pos
= call_func2(p_ostream_print_ptr
, &os
, param_ptr
[tests
[i
].param_index
]); break;
3389 pos
= call_func2(p_ostream_print_streambuf
, &os
, param_streambuf
[tests
[i
].param_index
]); break;
3392 length
= ssb
.base
.pptr
- ssb
.base
.pbase
;
3393 expected_length
= strlen(tests
[i
].expected_text
);
3394 ok(pos
== &os
, "Test %d: wrong return, expected %p got %p\n", i
, &os
, pos
);
3395 ok(os
.base_ios
.state
== tests
[i
].expected_flags
, "Test %d: expected %d got %d\n", i
,
3396 tests
[i
].expected_flags
, os
.base_ios
.state
);
3397 ok(os
.base_ios
.width
== 0, "Test %d: expected 0 got %d\n", i
, os
.base_ios
.width
);
3398 ok(expected_length
== length
, "Test %d: wrong output length, expected %d got %d\n", i
, expected_length
, length
);
3399 ok(!strncmp(tests
[i
].expected_text
, ssb
.base
.pbase
, length
),
3400 "Test %d: wrong output, expected '%s' got '%s'\n", i
, tests
[i
].expected_text
, ssb
.base
.pbase
);
3403 call_func1(p_ostream_vbase_dtor
, &os
);
3404 call_func1(p_strstreambuf_dtor
, &ssb
);
3405 call_func1(p_strstreambuf_dtor
, &ssb_test1
);
3406 call_func1(p_strstreambuf_dtor
, &ssb_test2
);
3407 call_func1(p_strstreambuf_dtor
, &ssb_test3
);
3410 static void test_istream(void)
3412 istream is1
, is2
, *pis
;
3413 filebuf fb1
, fb2
, *pfb
;
3414 const char filename1
[] = "test1";
3415 const char filename2
[] = "test2";
3418 memset(&is1
, 0xab, sizeof(istream
));
3419 memset(&is2
, 0xab, sizeof(istream
));
3420 memset(&fb1
, 0xab, sizeof(filebuf
));
3421 memset(&fb2
, 0xab, sizeof(filebuf
));
3423 /* constructors/destructors */
3424 pis
= call_func3(p_istream_sb_ctor
, &is1
, NULL
, TRUE
);
3425 ok(pis
== &is1
, "wrong return, expected %p got %p\n", &is1
, pis
);
3426 ok(is1
.extract_delim
== 0, "expected 0 got %d\n", is1
.extract_delim
);
3427 ok(is1
.count
== 0, "expected 0 got %d\n", is1
.count
);
3428 ok(is1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, is1
.base_ios
.sb
);
3429 ok(is1
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, is1
.base_ios
.state
);
3430 ok(is1
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is1
.base_ios
.flags
);
3431 call_func1(p_istream_vbase_dtor
, &is1
);
3432 is1
.extract_delim
= is1
.count
= 0xabababab;
3433 memset(&is1
.base_ios
, 0xab, sizeof(ios
));
3434 is1
.base_ios
.delbuf
= 0;
3435 pis
= call_func3(p_istream_sb_ctor
, &is1
, NULL
, FALSE
);
3436 ok(pis
== &is1
, "wrong return, expected %p got %p\n", &is1
, pis
);
3437 ok(is1
.extract_delim
== 0, "expected 0 got %d\n", is1
.extract_delim
);
3438 ok(is1
.count
== 0, "expected 0 got %d\n", is1
.count
);
3439 ok(is1
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, is1
.base_ios
.sb
);
3440 ok(is1
.base_ios
.state
== (0xabababab|IOSTATE_badbit
), "expected %d got %d\n",
3441 0xabababab|IOSTATE_badbit
, is1
.base_ios
.state
);
3442 ok(is1
.base_ios
.flags
== 0xabababab, "expected %d got %d\n", 0xabababab, is1
.base_ios
.flags
);
3443 call_func1(p_istream_dtor
, &is1
.base_ios
);
3444 pis
= call_func3(p_istream_sb_ctor
, &is1
, &fb1
.base
, FALSE
);
3445 ok(pis
== &is1
, "wrong return, expected %p got %p\n", &is1
, pis
);
3446 ok(is1
.extract_delim
== 0, "expected 0 got %d\n", is1
.extract_delim
);
3447 ok(is1
.count
== 0, "expected 0 got %d\n", is1
.count
);
3448 ok(is1
.base_ios
.sb
== &fb1
.base
, "expected %p got %p\n", &fb1
.base
, is1
.base_ios
.sb
);
3449 ok(is1
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, is1
.base_ios
.state
);
3450 ok(is1
.base_ios
.flags
== 0xabababab, "expected %d got %d\n", 0xabababab, is1
.base_ios
.flags
);
3451 call_func1(p_istream_dtor
, &is1
.base_ios
);
3452 call_func1(p_filebuf_ctor
, &fb1
);
3453 pfb
= call_func4(p_filebuf_open
, &fb1
, filename1
, OPENMODE_in
|OPENMODE_out
, filebuf_openprot
);
3454 ok(pfb
== &fb1
, "wrong return, expected %p got %p\n", &fb1
, pfb
);
3455 ok(fb1
.base
.allocated
== 1, "expected %d got %d\n", 1, fb1
.base
.allocated
);
3456 pis
= call_func3(p_istream_sb_ctor
, &is1
, &fb1
.base
, TRUE
);
3457 ok(pis
== &is1
, "wrong return, expected %p got %p\n", &is1
, pis
);
3458 ok(is1
.extract_delim
== 0, "expected 0 got %d\n", is1
.extract_delim
);
3459 ok(is1
.count
== 0, "expected 0 got %d\n", is1
.count
);
3460 ok(is1
.base_ios
.sb
== &fb1
.base
, "expected %p got %p\n", &fb1
.base
, is1
.base_ios
.sb
);
3461 ok(is1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is1
.base_ios
.state
);
3462 ok(is1
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is1
.base_ios
.flags
);
3463 pis
= call_func2(p_istream_ctor
, &is2
, TRUE
);
3464 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3465 ok(is2
.extract_delim
== 0, "expected 0 got %d\n", is2
.extract_delim
);
3466 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3467 ok(is2
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, is2
.base_ios
.sb
);
3468 ok(is2
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, is2
.base_ios
.state
);
3469 ok(is2
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is2
.base_ios
.flags
);
3470 call_func1(p_istream_vbase_dtor
, &is2
);
3471 is2
.extract_delim
= is2
.count
= 0xabababab;
3472 memset(&is2
.base_ios
, 0xab, sizeof(ios
));
3473 is2
.base_ios
.flags
&= ~FLAGS_skipws
;
3474 pis
= call_func2(p_istream_ctor
, &is2
, FALSE
);
3475 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3476 ok(is2
.extract_delim
== 0, "expected 0 got %d\n", is2
.extract_delim
);
3477 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3478 ok(is2
.base_ios
.sb
!= NULL
, "expected not %p got %p\n", NULL
, is2
.base_ios
.sb
);
3479 ok(is2
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.state
);
3480 ok(is2
.base_ios
.flags
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.flags
);
3481 call_func1(p_istream_dtor
, &is2
.base_ios
);
3482 is1
.extract_delim
= is1
.count
= 0xcdcdcdcd;
3483 is1
.base_ios
.state
= 0xcdcdcdcd;
3484 is1
.base_ios
.flags
&= ~FLAGS_skipws
;
3485 is2
.extract_delim
= is2
.count
= 0xabababab;
3486 memset(&is2
.base_ios
, 0xab, sizeof(ios
));
3487 is2
.base_ios
.flags
&= ~FLAGS_skipws
;
3488 is2
.base_ios
.delbuf
= 0;
3489 pis
= call_func3(p_istream_copy_ctor
, &is2
, &is1
, FALSE
);
3490 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3491 ok(is2
.extract_delim
== 0, "expected 0 got %d\n", is2
.extract_delim
);
3492 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3493 ok(is2
.base_ios
.sb
== is1
.base_ios
.sb
, "expected %p got %p\n", is1
.base_ios
.sb
, is2
.base_ios
.sb
);
3494 ok(is2
.base_ios
.state
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.state
);
3495 ok(is2
.base_ios
.flags
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.flags
);
3496 call_func1(p_istream_dtor
, &is2
.base_ios
);
3497 is2
.extract_delim
= is2
.count
= 0xabababab;
3498 memset(&is2
.base_ios
, 0xab, sizeof(ios
));
3499 pis
= call_func3(p_istream_copy_ctor
, &is2
, &is1
, TRUE
);
3500 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3501 ok(is2
.extract_delim
== 0, "expected 0 got %d\n", is2
.extract_delim
);
3502 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3503 ok(is2
.base_ios
.sb
== is1
.base_ios
.sb
, "expected %p got %p\n", is1
.base_ios
.sb
, is2
.base_ios
.sb
);
3504 ok(is2
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is2
.base_ios
.state
);
3505 ok(is2
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is2
.base_ios
.flags
);
3508 is2
.extract_delim
= is2
.count
= 0xabababab;
3509 is2
.base_ios
.sb
= (streambuf
*) 0xabababab;
3510 is2
.base_ios
.state
= 0xabababab;
3511 is2
.base_ios
.special
[0] = 0xabababab;
3512 is2
.base_ios
.delbuf
= 0;
3513 is2
.base_ios
.tie
= (ostream
*) 0xabababab;
3514 is2
.base_ios
.flags
= 0xabababab;
3515 is2
.base_ios
.precision
= 0xabababab;
3516 is2
.base_ios
.width
= 0xabababab;
3517 pis
= call_func2(p_istream_assign
, &is2
, &is1
);
3518 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3519 ok(is2
.extract_delim
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.extract_delim
);
3520 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3521 ok(is2
.base_ios
.sb
== is1
.base_ios
.sb
, "expected %p got %p\n", is1
.base_ios
.sb
, is2
.base_ios
.sb
);
3522 ok(is2
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is2
.base_ios
.state
);
3523 ok(is2
.base_ios
.special
[0] == 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.fill
);
3524 ok(is2
.base_ios
.delbuf
== 0, "expected 0 got %d\n", is2
.base_ios
.delbuf
);
3525 ok(is2
.base_ios
.tie
== NULL
, "expected %p got %p\n", NULL
, is2
.base_ios
.tie
);
3526 ok(is2
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is2
.base_ios
.flags
);
3527 ok(is2
.base_ios
.precision
== 6, "expected 6 got %d\n", is2
.base_ios
.precision
);
3528 ok(is2
.base_ios
.width
== 0, "expected 0 got %d\n", is2
.base_ios
.width
);
3529 if (0) /* crashes on native */
3530 pis
= call_func2(p_istream_assign
, &is2
, NULL
);
3531 is2
.extract_delim
= is2
.count
= 0xabababab;
3532 is2
.base_ios
.sb
= (streambuf
*) 0xabababab;
3533 is2
.base_ios
.state
= 0xabababab;
3534 is2
.base_ios
.special
[0] = 0xabababab;
3535 is2
.base_ios
.delbuf
= 0;
3536 is2
.base_ios
.tie
= (ostream
*) 0xabababab;
3537 is2
.base_ios
.flags
= 0xabababab;
3538 is2
.base_ios
.precision
= 0xabababab;
3539 is2
.base_ios
.width
= 0xabababab;
3540 pis
= call_func2(p_istream_assign_sb
, &is2
, NULL
);
3541 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3542 ok(is2
.extract_delim
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.extract_delim
);
3543 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3544 ok(is2
.base_ios
.sb
== NULL
, "expected %p got %p\n", NULL
, is2
.base_ios
.sb
);
3545 ok(is2
.base_ios
.state
== IOSTATE_badbit
, "expected %d got %d\n", IOSTATE_badbit
, is2
.base_ios
.state
);
3546 ok(is2
.base_ios
.special
[0] == 0xabababab, "expected %d got %d\n", 0xabababab, is2
.base_ios
.fill
);
3547 ok(is2
.base_ios
.delbuf
== 0, "expected 0 got %d\n", is2
.base_ios
.delbuf
);
3548 ok(is2
.base_ios
.tie
== NULL
, "expected %p got %p\n", NULL
, is2
.base_ios
.tie
);
3549 ok(is2
.base_ios
.flags
== FLAGS_skipws
, "expected %d got %d\n", FLAGS_skipws
, is2
.base_ios
.flags
);
3550 ok(is2
.base_ios
.precision
== 6, "expected 6 got %d\n", is2
.base_ios
.precision
);
3551 ok(is2
.base_ios
.width
== 0, "expected 0 got %d\n", is2
.base_ios
.width
);
3552 call_func1(p_filebuf_ctor
, &fb2
);
3553 pfb
= call_func4(p_filebuf_open
, &fb2
, filename2
, OPENMODE_in
|OPENMODE_out
, filebuf_openprot
);
3554 ok(pfb
== &fb2
, "wrong return, expected %p got %p\n", &fb2
, pfb
);
3555 ok(fb2
.base
.allocated
== 1, "expected %d got %d\n", 1, fb2
.base
.allocated
);
3556 pis
= call_func2(p_istream_assign_sb
, &is2
, &fb2
.base
);
3557 ok(pis
== &is2
, "wrong return, expected %p got %p\n", &is2
, pis
);
3558 ok(is2
.extract_delim
== 0xabababab, "expected %d got %d\n", 0xabababab, is2
.extract_delim
);
3559 ok(is2
.count
== 0, "expected 0 got %d\n", is2
.count
);
3560 ok(is2
.base_ios
.sb
== &fb2
.base
, "expected %p got %p\n", &fb2
.base
, is2
.base_ios
.sb
);
3561 ok(is2
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is2
.base_ios
.state
);
3564 is1
.extract_delim
= is1
.count
= 0;
3565 if (0) /* crashes on native */
3566 is1
.base_ios
.sb
= NULL
;
3567 is1
.base_ios
.state
= IOSTATE_badbit
;
3568 is1
.base_ios
.flags
= 0;
3569 call_func1(p_istream_eatwhite
, &is1
);
3570 ok(is1
.base_ios
.state
== (IOSTATE_badbit
|IOSTATE_eofbit
), "expected %d got %d\n",
3571 IOSTATE_badbit
|IOSTATE_eofbit
, is1
.base_ios
.state
);
3572 is1
.base_ios
.state
= IOSTATE_failbit
;
3573 call_func1(p_istream_eatwhite
, &is1
);
3574 ok(is1
.base_ios
.state
== (IOSTATE_failbit
|IOSTATE_eofbit
), "expected %d got %d\n",
3575 IOSTATE_failbit
|IOSTATE_eofbit
, is1
.base_ios
.state
);
3576 is1
.base_ios
.state
= IOSTATE_goodbit
;
3577 ret
= (int) call_func3(p_streambuf_xsputn
, &fb1
.base
, "And if \tyou ask\n\v\f\r me", 23);
3578 ok(ret
== 23, "expected 23 got %d\n", ret
);
3579 ok(fb1
.base
.pbase
== fb1
.base
.base
, "wrong put base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.pbase
);
3580 ok(fb1
.base
.pptr
== fb1
.base
.base
+ 23, "wrong put pointer, expected %p got %p\n", fb1
.base
.base
+ 23, fb1
.base
.pptr
);
3581 call_func1(p_istream_eatwhite
, &is1
);
3582 ok(is1
.base_ios
.state
== IOSTATE_eofbit
, "expected %d got %d\n", IOSTATE_eofbit
, is1
.base_ios
.state
);
3583 ok(fb1
.base
.pbase
== NULL
, "wrong put base, expected %p got %p\n", NULL
, fb1
.base
.pbase
);
3584 ok(fb1
.base
.pptr
== NULL
, "wrong put pointer, expected %p got %p\n", NULL
, fb1
.base
.pptr
);
3585 ok(fb1
.base
.epptr
== NULL
, "wrong put end, expected %p got %p\n", NULL
, fb1
.base
.epptr
);
3586 is1
.base_ios
.state
= IOSTATE_goodbit
;
3587 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 0, SEEKDIR_beg
, 0);
3588 ok(ret
== 0, "expected 0 got %d\n", ret
);
3589 call_func1(p_istream_eatwhite
, &is1
);
3590 ok(is1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is1
.base_ios
.state
);
3591 ok(fb1
.base
.eback
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.eback
);
3592 ok(fb1
.base
.gptr
== fb1
.base
.base
, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.gptr
);
3593 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 23, "wrong get end, expected %p got %p\n", fb1
.base
.base
+ 23, fb1
.base
.egptr
);
3594 ret
= (int) call_func4(p_filebuf_seekoff
, &fb1
, 3, SEEKDIR_beg
, 0);
3595 ok(ret
== 3, "expected 3 got %d\n", ret
);
3596 call_func1(p_istream_eatwhite
, &is1
);
3597 ok(is1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is1
.base_ios
.state
);
3598 ok(fb1
.base
.eback
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.eback
);
3599 ok(fb1
.base
.gptr
== fb1
.base
.base
+ 1, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
+ 1, fb1
.base
.gptr
);
3600 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 20, "wrong get end, expected %p got %p\n", fb1
.base
.base
+ 20, fb1
.base
.egptr
);
3602 call_func1(p_istream_eatwhite
, &is1
);
3603 ok(is1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is1
.base_ios
.state
);
3604 ok(fb1
.base
.eback
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.eback
);
3605 ok(fb1
.base
.gptr
== fb1
.base
.base
+ 5, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
+ 5, fb1
.base
.gptr
);
3606 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 20, "wrong get end, expected %p got %p\n", fb1
.base
.base
+ 20, fb1
.base
.egptr
);
3608 call_func1(p_istream_eatwhite
, &is1
);
3609 ok(is1
.base_ios
.state
== IOSTATE_goodbit
, "expected %d got %d\n", IOSTATE_goodbit
, is1
.base_ios
.state
);
3610 ok(fb1
.base
.eback
== fb1
.base
.base
, "wrong get base, expected %p got %p\n", fb1
.base
.base
, fb1
.base
.eback
);
3611 ok(fb1
.base
.gptr
== fb1
.base
.base
+ 18, "wrong get pointer, expected %p got %p\n", fb1
.base
.base
+ 18, fb1
.base
.gptr
);
3612 ok(fb1
.base
.egptr
== fb1
.base
.base
+ 20, "wrong get end, expected %p got %p\n", fb1
.base
.base
+ 20, fb1
.base
.egptr
);
3614 call_func1(p_istream_eatwhite
, &is1
);
3615 ok(is1
.base_ios
.state
== IOSTATE_eofbit
, "expected %d got %d\n", IOSTATE_eofbit
, is1
.base_ios
.state
);
3616 ok(fb1
.base
.eback
== NULL
, "wrong get base, expected %p got %p\n", NULL
, fb1
.base
.eback
);
3617 ok(fb1
.base
.gptr
== NULL
, "wrong get pointer, expected %p got %p\n", NULL
, fb1
.base
.gptr
);
3618 ok(fb1
.base
.egptr
== NULL
, "wrong get end, expected %p got %p\n", NULL
, fb1
.base
.egptr
);
3620 call_func1(p_istream_vbase_dtor
, &is1
);
3621 call_func1(p_istream_vbase_dtor
, &is2
);
3622 call_func1(p_filebuf_dtor
, &fb1
);
3623 call_func1(p_filebuf_dtor
, &fb2
);
3624 ok(_unlink(filename1
) == 0, "Couldn't unlink file named '%s'\n", filename1
);
3625 ok(_unlink(filename2
) == 0, "Couldn't unlink file named '%s'\n", filename2
);
3635 test_strstreambuf();
3639 test_ostream_print();
3642 FreeLibrary(msvcrt
);
3643 FreeLibrary(msvcirt
);