2 * Copyright 2010 Piotr Caban for CodeWeavers
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
26 #include "wine/test.h"
30 #define __thiscall __stdcall
32 #define __thiscall __cdecl
35 typedef unsigned char MSVCP_bool
;
36 typedef SIZE_T MSVCP_size_t
;
37 typedef SSIZE_T streamoff
;
38 typedef SSIZE_T streamsize
;
40 typedef void (*vtable_ptr
)(void);
42 /* basic_string<char, char_traits<char>, allocator<char>> */
62 struct _locale__Locimp
*ptr
;
65 /* class locale::facet */
67 const vtable_ptr
*vtable
;
71 /* class codecvt_base */
76 /* class codecvt<char> */
86 /* class codecvt<wchar> */
93 FMTFLAG_skipws
= 0x0001,
94 FMTFLAG_unitbuf
= 0x0002,
95 FMTFLAG_uppercase
= 0x0004,
96 FMTFLAG_showbase
= 0x0008,
97 FMTFLAG_showpoint
= 0x0010,
98 FMTFLAG_showpos
= 0x0020,
99 FMTFLAG_left
= 0x0040,
100 FMTFLAG_right
= 0x0080,
101 FMTFLAG_internal
= 0x0100,
102 FMTFLAG_dec
= 0x0200,
103 FMTFLAG_oct
= 0x0400,
104 FMTFLAG_hex
= 0x0800,
105 FMTFLAG_scientific
= 0x1000,
106 FMTFLAG_fixed
= 0x2000,
107 FMTFLAG_hexfloat
= 0x3000,
108 FMTFLAG_boolalpha
= 0x4000,
109 FMTFLAG_stdio
= 0x8000,
110 FMTFLAG_adjustfield
= FMTFLAG_left
|FMTFLAG_right
|FMTFLAG_internal
,
111 FMTFLAG_basefield
= FMTFLAG_dec
|FMTFLAG_oct
|FMTFLAG_hex
,
112 FMTFLAG_floatfield
= FMTFLAG_scientific
|FMTFLAG_fixed
,
113 FMTFLAG_mask
= 0xffff
121 OPENMODE_trunc
= 0x10,
122 OPENMODE__Nocreate
= 0x40,
123 OPENMODE__Noreplace
= 0x80,
124 OPENMODE_binary
= 0x20,
136 IOSTATE_goodbit
= 0x00,
137 IOSTATE_eofbit
= 0x01,
138 IOSTATE_failbit
= 0x02,
139 IOSTATE_badbit
= 0x04,
140 IOSTATE__Hardfail
= 0x10,
144 typedef struct _iosarray
{
145 struct _iosarray
*next
;
158 typedef void (CDECL
*IOS_BASE_event_callback
)(IOS_BASE_event
, struct _ios_base
*, int);
159 typedef struct _fnarray
{
160 struct _fnarray
*next
;
162 IOS_BASE_event_callback event_handler
;
166 typedef struct _ios_base
{
167 const vtable_ptr
*vtable
;
173 IOS_BASE_iosarray
*arr
;
174 IOS_BASE_fnarray
*calls
;
179 /* class basic_streambuf<char> */
181 const vtable_ptr
*vtable
;
195 } basic_streambuf_char
;
197 /* class basic_streambuf<wchar> */
199 const vtable_ptr
*vtable
;
213 } basic_streambuf_wchar
;
216 basic_streambuf_char base
;
220 basic_string_char
*str
;
224 } basic_filebuf_char
;
227 basic_streambuf_wchar base
;
231 basic_string_char
*str
;
235 } basic_filebuf_wchar
;
238 basic_streambuf_char base
;
243 char allocator
; /* empty struct */
244 } basic_stringbuf_char
;
247 basic_streambuf_wchar base
;
252 char allocator
; /* empty struct */
253 } basic_stringbuf_wchar
;
257 basic_streambuf_char
*strbuf
;
258 struct _basic_ostream_char
*stream
;
264 basic_streambuf_wchar
*strbuf
;
265 struct _basic_ostream_wchar
*stream
;
269 typedef struct _basic_ostream_char
{
271 /* virtual inheritance
272 * basic_ios_char basic_ios;
274 } basic_ostream_char
;
276 typedef struct _basic_ostream_wchar
{
278 /* virtual inheritance
279 * basic_ios_wchar basic_ios;
281 } basic_ostream_wchar
;
286 /* virtual inheritance
287 * basic_ios_char basic_ios;
289 } basic_istream_char
;
294 /* virtual inheritance
295 * basic_ios_wchar basic_ios;
297 } basic_istream_wchar
;
300 basic_istream_char base1
;
301 basic_ostream_char base2
;
302 /* virtual inheritance
303 * basic_ios_char basic_ios;
305 } basic_iostream_char
;
308 basic_istream_wchar base1
;
309 basic_ostream_wchar base2
;
310 /* virtual inheritance
311 * basic_ios_wchar basic_ios;
313 } basic_iostream_wchar
;
316 basic_ostream_char base
;
317 basic_filebuf_char filebuf
;
318 /* virtual inheritance
319 * basic_ios_char basic_ios;
321 } basic_ofstream_char
;
324 basic_ostream_wchar base
;
325 basic_filebuf_wchar filebuf
;
326 /* virtual inheritance
327 * basic_ios_wchar basic_ios;
329 } basic_ofstream_wchar
;
332 basic_istream_char base
;
333 basic_filebuf_char filebuf
;
334 /* virtual inheritance
335 * basic_ios_char basic_ios;
337 } basic_ifstream_char
;
340 basic_istream_wchar base
;
341 basic_filebuf_wchar filebuf
;
342 /* virtual inheritance
343 * basic_ios_wchar basic_ios;
345 } basic_ifstream_wchar
;
348 basic_iostream_char base
;
349 basic_filebuf_char filebuf
;
350 /* virtual inheritance */
351 basic_ios_char basic_ios
; /* here to reserve correct stack size */
352 } basic_fstream_char
;
355 basic_iostream_wchar base
;
356 basic_filebuf_wchar filebuf
;
357 /* virtual inheritance */
358 basic_ios_wchar basic_ios
; /* here to reserve correct stack size */
359 } basic_fstream_wchar
;
362 basic_ostream_char base
;
363 basic_stringbuf_char strbuf
;
364 /* virtual inheritance
365 * basic_ios_char basic_ios;
367 } basic_ostringstream_char
;
370 basic_ostream_wchar base
;
371 basic_stringbuf_wchar strbuf
;
372 /* virtual inheritance
373 * basic_ios_wchar basic_ios;
375 } basic_ostringstream_wchar
;
378 basic_istream_char base
;
379 basic_stringbuf_char strbuf
;
380 /* virtual inheritance
381 * basic_ios_char basic_ios;
383 } basic_istringstream_char
;
386 basic_istream_wchar base
;
387 basic_stringbuf_wchar strbuf
;
388 /* virtual inheritance
389 * basic_ios_wchar basic_ios;
391 } basic_istringstream_wchar
;
394 basic_iostream_char base
;
395 basic_stringbuf_char strbuf
;
396 /* virtual inheritance */
397 basic_ios_char basic_ios
; /* here to reserve correct stack size */
398 } basic_stringstream_char
;
401 basic_iostream_wchar base
;
402 basic_stringbuf_wchar strbuf
;
403 /* virtual inheritance */
404 basic_ios_wchar basic_ios
; /* here to reserve correct stack size */
405 } basic_stringstream_wchar
;
409 __int64
DECLSPEC_ALIGN(8) pos
;
414 static basic_stringstream_char
* (*__thiscall p_basic_stringstream_char_ctor_mode
)(basic_stringstream_char
*, int, MSVCP_bool
);
415 static basic_stringstream_char
* (*__thiscall p_basic_stringstream_char_ctor_str
)(basic_stringstream_char
*, const basic_string_char
*, int, MSVCP_bool
);
416 static basic_string_char
* (*__thiscall p_basic_stringstream_char_str_get
)(const basic_stringstream_char
*, basic_string_char
*);
417 static void (*__thiscall p_basic_stringstream_char_vbase_dtor
)(basic_stringstream_char
*);
419 static basic_stringstream_wchar
* (*__thiscall p_basic_stringstream_wchar_ctor_mode
)(basic_stringstream_wchar
*, int, MSVCP_bool
);
420 static basic_stringstream_wchar
* (*__thiscall p_basic_stringstream_wchar_ctor_str
)(basic_stringstream_wchar
*, const basic_string_wchar
*, int, MSVCP_bool
);
421 static basic_string_wchar
* (*__thiscall p_basic_stringstream_wchar_str_get
)(const basic_stringstream_wchar
*, basic_string_wchar
*);
422 static void (*__thiscall p_basic_stringstream_wchar_vbase_dtor
)(basic_stringstream_wchar
*);
425 static basic_fstream_char
* (*__thiscall p_basic_fstream_char_ctor_name
)(basic_fstream_char
*, const char*, int, MSVCP_bool
);
426 static void (*__thiscall p_basic_fstream_char_vbase_dtor
)(basic_fstream_char
*);
428 static basic_fstream_wchar
* (*__thiscall p_basic_fstream_wchar_ctor_name
)(basic_fstream_wchar
*, const char*, int, MSVCP_bool
);
429 static void (*__thiscall p_basic_fstream_wchar_vbase_dtor
)(basic_fstream_wchar
*);
432 static basic_istream_char
* (*__thiscall p_basic_istream_char_read_double
)(basic_istream_char
*, double*);
433 static int (*__thiscall p_basic_istream_char_get
)(basic_istream_char
*);
434 static MSVCP_bool (*__thiscall p_basic_istream_char_ipfx
)(basic_istream_char
*, MSVCP_bool
);
435 static basic_istream_char
* (*__thiscall p_basic_istream_char_ignore
)(basic_istream_char
*, streamsize
, int);
436 static basic_istream_char
* (*__thiscall p_basic_istream_char_seekg
)(basic_istream_char
*, streamoff
, int);
437 static basic_istream_char
* (*__thiscall p_basic_istream_char_seekg_fpos
)(basic_istream_char
*, fpos_int
);
438 static int (*__thiscall p_basic_istream_char_peek
)(basic_istream_char
*);
439 static fpos_int
* (*__thiscall p_basic_istream_char_tellg
)(basic_istream_char
*, fpos_int
*);
440 static basic_istream_char
* (*__cdecl p_basic_istream_char_getline_bstr_delim
)(basic_istream_char
*, basic_string_char
*, char);
442 static basic_istream_wchar
* (*__thiscall p_basic_istream_wchar_read_double
)(basic_istream_wchar
*, double *);
443 static int (*__thiscall p_basic_istream_wchar_get
)(basic_istream_wchar
*);
444 static MSVCP_bool (*__thiscall p_basic_istream_wchar_ipfx
)(basic_istream_wchar
*, MSVCP_bool
);
445 static basic_istream_wchar
* (*__thiscall p_basic_istream_wchar_ignore
)(basic_istream_wchar
*, streamsize
, unsigned short);
446 static basic_istream_wchar
* (*__thiscall p_basic_istream_wchar_seekg
)(basic_istream_wchar
*, streamoff
, int);
447 static basic_istream_wchar
* (*__thiscall p_basic_istream_wchar_seekg_fpos
)(basic_istream_wchar
*, fpos_int
);
448 static unsigned short (*__thiscall p_basic_istream_wchar_peek
)(basic_istream_wchar
*);
449 static fpos_int
* (*__thiscall p_basic_istream_wchar_tellg
)(basic_istream_wchar
*, fpos_int
*);
450 static basic_istream_wchar
* (*__cdecl p_basic_istream_wchar_getline_bstr_delim
)(basic_istream_wchar
*, basic_string_wchar
*, wchar_t);
453 static basic_ostream_char
* (*__thiscall p_basic_ostream_char_print_double
)(basic_ostream_char
*, double);
455 static basic_ostream_wchar
* (*__thiscall p_basic_ostream_wchar_print_double
)(basic_ostream_wchar
*, double);
457 static basic_ostream_wchar
* (*__thiscall p_basic_ostream_short_print_ushort
)(basic_ostream_wchar
*, unsigned short);
460 static locale
* (*__thiscall p_basic_ios_char_imbue
)(basic_ios_char
*, locale
*, const locale
*);
462 static locale
* (*__thiscall p_basic_ios_wchar_imbue
)(basic_ios_wchar
*, locale
*, const locale
*);
465 static IOSB_iostate (*__thiscall p_ios_base_rdstate
)(const ios_base
*);
466 static IOSB_fmtflags (*__thiscall p_ios_base_setf_mask
)(ios_base
*, IOSB_fmtflags
, IOSB_fmtflags
);
467 static void (*__thiscall p_ios_base_unsetf
)(ios_base
*, IOSB_fmtflags
);
468 static streamsize (*__thiscall p_ios_base_precision_set
)(ios_base
*, streamsize
);
471 static locale
* (*__thiscall p_locale_ctor_cstr
)(locale
*, const char*, int /* FIXME: category */);
472 static void (*__thiscall p_locale_dtor
)(locale
*this);
475 static basic_string_char
* (__thiscall
*p_basic_string_char_ctor_cstr_alloc
)(basic_string_char
*, const char*, void*);
476 static const char* (__thiscall
*p_basic_string_char_cstr
)(basic_string_char
*);
477 static void (__thiscall
*p_basic_string_char_dtor
)(basic_string_char
*);
479 static basic_string_wchar
* (__thiscall
*p_basic_string_wchar_ctor_cstr_alloc
)(basic_string_wchar
*, const wchar_t*, void*);
480 static const wchar_t* (__thiscall
*p_basic_string_wchar_cstr
)(basic_string_wchar
*);
481 static void (__thiscall
*p_basic_string_wchar_dtor
)(basic_string_wchar
*);
483 /* Emulate a __thiscall */
486 #include "pshpack1.h"
487 struct thiscall_thunk
489 BYTE pop_eax
; /* popl %eax (ret addr) */
490 BYTE pop_edx
; /* popl %edx (func) */
491 BYTE pop_ecx
; /* popl %ecx (this) */
492 BYTE push_eax
; /* pushl %eax */
493 WORD jmp_edx
; /* jmp *%edx */
497 static void * (WINAPI
*call_thiscall_func1
)( void *func
, void *this );
498 static void * (WINAPI
*call_thiscall_func2
)( void *func
, void *this, const void *a
);
499 static void * (WINAPI
*call_thiscall_func3
)( void *func
, void *this, const void *a
, const void *b
);
500 static void * (WINAPI
*call_thiscall_func4
)( void *func
, void *this, const void *a
, const void *b
,
502 static void * (WINAPI
*call_thiscall_func5
)( void *func
, void *this, const void *a
, const void *b
,
503 const void *c
, const void *d
);
505 /* to silence compiler errors */
506 static void * (WINAPI
*call_thiscall_func2_ptr_dbl
)( void *func
, void *this, double a
);
507 static void * (WINAPI
*call_thiscall_func2_ptr_fpos
)( void *func
, void *this, fpos_int a
);
509 struct thiscall_thunk_retptr
*thunk_retptr
;
511 static void init_thiscall_thunk(void)
513 struct thiscall_thunk
*thunk
= VirtualAlloc( NULL
, sizeof(*thunk
),
514 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
515 thunk
->pop_eax
= 0x58; /* popl %eax */
516 thunk
->pop_edx
= 0x5a; /* popl %edx */
517 thunk
->pop_ecx
= 0x59; /* popl %ecx */
518 thunk
->push_eax
= 0x50; /* pushl %eax */
519 thunk
->jmp_edx
= 0xe2ff; /* jmp *%edx */
520 call_thiscall_func1
= (void *)thunk
;
521 call_thiscall_func2
= (void *)thunk
;
522 call_thiscall_func3
= (void *)thunk
;
523 call_thiscall_func4
= (void *)thunk
;
524 call_thiscall_func5
= (void *)thunk
;
526 call_thiscall_func2_ptr_dbl
= (void *)thunk
;
527 call_thiscall_func2_ptr_fpos
= (void *)thunk
;
530 #define call_func1(func,_this) call_thiscall_func1(func,_this)
531 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
532 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
533 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
535 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
536 (const void*)(c), (const void *)(d))
538 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
539 #define call_func2_ptr_fpos(func,_this,a) call_thiscall_func2_ptr_fpos(func,_this,a)
543 #define init_thiscall_thunk()
544 #define call_func1(func,_this) func(_this)
545 #define call_func2(func,_this,a) func(_this,a)
546 #define call_func3(func,_this,a,b) func(_this,a,b)
547 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
548 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
550 #define call_func2_ptr_dbl call_func2
551 #define call_func2_ptr_fpos call_func2
553 #endif /* __i386__ */
555 static HMODULE msvcp
;
556 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
557 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
558 static BOOL
init(void)
560 msvcp
= LoadLibraryA("msvcp60.dll");
562 win_skip("msvcp60.dll not installed\n");
566 if(sizeof(void*) == 8) { /* 64-bit initialization */
567 SET(p_basic_stringstream_char_ctor_mode
,
568 "??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z");
569 SET(p_basic_stringstream_char_ctor_str
,
570 "??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z");
571 SET(p_basic_stringstream_char_str_get
,
572 "?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
573 SET(p_basic_stringstream_char_vbase_dtor
,
574 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
576 SET(p_basic_stringstream_wchar_ctor_mode
,
577 "??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z");
578 SET(p_basic_stringstream_wchar_ctor_str
,
579 "??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z");
580 SET(p_basic_stringstream_wchar_str_get
,
581 "?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ");
582 SET(p_basic_stringstream_wchar_vbase_dtor
,
583 "??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ");
585 SET(p_basic_fstream_char_ctor_name
,
586 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z");
587 SET(p_basic_fstream_char_vbase_dtor
,
588 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ");
590 SET(p_basic_fstream_wchar_ctor_name
,
591 "??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z");
592 SET(p_basic_fstream_wchar_vbase_dtor
,
593 "??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ");
595 SET(p_basic_istream_char_read_double
,
596 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z");
597 SET(p_basic_istream_char_get
,
598 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
599 SET(p_basic_istream_char_ipfx
,
600 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z");
601 SET(p_basic_istream_char_ignore
,
602 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
603 SET(p_basic_istream_char_seekg
,
604 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z");
605 SET(p_basic_istream_char_seekg_fpos
,
606 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
607 SET(p_basic_istream_char_peek
,
608 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
609 SET(p_basic_istream_char_tellg
,
610 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
611 SETNOFAIL(p_basic_istream_char_getline_bstr_delim
,
612 "??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z");
614 SET(p_basic_istream_wchar_read_double
,
615 "??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z");
616 SET(p_basic_istream_wchar_get
,
617 "?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ");
618 SET(p_basic_istream_wchar_ipfx
,
619 "?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z");
620 SET(p_basic_istream_wchar_ignore
,
621 "?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z");
622 SET(p_basic_istream_wchar_seekg
,
623 "?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z");
624 SET(p_basic_istream_wchar_seekg_fpos
,
625 "?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
626 SET(p_basic_istream_wchar_peek
,
627 "?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ");
628 SET(p_basic_istream_wchar_tellg
,
629 "?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
630 SETNOFAIL(p_basic_istream_wchar_getline_bstr_delim
,
631 "??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@G@Z");
633 SET(p_basic_ostream_char_print_double
,
634 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z");
636 SET(p_basic_ostream_wchar_print_double
,
637 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z");
639 SET(p_basic_ostream_short_print_ushort
,
640 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@G@Z");
642 SET(p_ios_base_rdstate
,
643 "?rdstate@ios_base@std@@QEBAHXZ");
644 SET(p_ios_base_setf_mask
,
645 "?setf@ios_base@std@@QEAAHHH@Z");
646 SET(p_ios_base_unsetf
,
647 "?unsetf@ios_base@std@@QEAAXH@Z");
648 SET(p_ios_base_precision_set
,
649 "?precision@ios_base@std@@QEAA_JH@Z");
651 SET(p_basic_ios_char_imbue
,
652 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
654 SET(p_basic_ios_wchar_imbue
,
655 "?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
657 SET(p_locale_ctor_cstr
,
658 "??0locale@std@@QEAA@PEBDH@Z");
660 "??1locale@std@@QEAA@XZ");
662 SET(p_basic_string_char_ctor_cstr_alloc
,
663 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBDAEBV?$allocator@D@1@@Z");
664 SET(p_basic_string_char_cstr
,
665 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
666 SET(p_basic_string_char_dtor
,
667 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
669 SET(p_basic_string_wchar_ctor_cstr_alloc
,
670 "??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@PEBGAEBV?$allocator@G@1@@Z");
671 SET(p_basic_string_wchar_cstr
,
672 "?c_str@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBAPEBGXZ");
673 SET(p_basic_string_wchar_dtor
,
674 "??1?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@XZ");
676 SET(p_basic_stringstream_char_ctor_mode
,
677 "??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
678 SET(p_basic_stringstream_char_ctor_str
,
679 "??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z");
680 SET(p_basic_stringstream_char_str_get
,
681 "?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
682 SET(p_basic_stringstream_char_vbase_dtor
,
683 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
685 SET(p_basic_stringstream_wchar_ctor_mode
,
686 "??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z");
687 SET(p_basic_stringstream_wchar_ctor_str
,
688 "??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z");
689 SET(p_basic_stringstream_wchar_str_get
,
690 "?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ");
691 SET(p_basic_stringstream_wchar_vbase_dtor
,
692 "??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ");
694 SET(p_basic_fstream_char_ctor_name
,
695 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z");
696 SET(p_basic_fstream_char_vbase_dtor
,
697 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
699 SET(p_basic_fstream_wchar_ctor_name
,
700 "??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z");
701 SET(p_basic_fstream_wchar_vbase_dtor
,
702 "??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ");
704 SET(p_basic_istream_char_read_double
,
705 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z");
706 SET(p_basic_istream_char_get
,
707 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
708 SET(p_basic_istream_char_ipfx
,
709 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z");
710 SET(p_basic_istream_char_ignore
,
711 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
712 SET(p_basic_istream_char_seekg
,
713 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z");
714 SET(p_basic_istream_char_seekg_fpos
,
715 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
716 SET(p_basic_istream_char_peek
,
717 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
718 SET(p_basic_istream_char_tellg
,
719 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ");
720 SETNOFAIL(p_basic_istream_char_getline_bstr_delim
,
721 "??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z");
723 SET(p_basic_istream_wchar_read_double
,
724 "??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z");
725 SET(p_basic_istream_wchar_get
,
726 "?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ");
727 SET(p_basic_istream_wchar_ipfx
,
728 "?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z");
729 SET(p_basic_istream_wchar_ignore
,
730 "?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z");
731 SET(p_basic_istream_wchar_seekg
,
732 "?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z");
733 SET(p_basic_istream_wchar_seekg_fpos
,
734 "?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
735 SET(p_basic_istream_wchar_peek
,
736 "?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ");
737 SET(p_basic_istream_wchar_tellg
,
738 "?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ");
739 SETNOFAIL(p_basic_istream_wchar_getline_bstr_delim
,
740 "??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@G@Z");
742 SET(p_basic_ostream_char_print_double
,
743 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z");
745 SET(p_basic_ostream_wchar_print_double
,
746 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z");
748 SET(p_basic_ostream_short_print_ushort
,
749 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@G@Z");
751 SET(p_ios_base_rdstate
,
752 "?rdstate@ios_base@std@@QBEHXZ");
753 SET(p_ios_base_setf_mask
,
754 "?setf@ios_base@std@@QAEHHH@Z");
755 SET(p_ios_base_unsetf
,
756 "?unsetf@ios_base@std@@QAEXH@Z");
757 SET(p_ios_base_precision_set
,
758 "?precision@ios_base@std@@QAEHH@Z");
760 SET(p_basic_ios_char_imbue
,
761 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
763 SET(p_basic_ios_wchar_imbue
,
764 "?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
766 SET(p_locale_ctor_cstr
,
767 "??0locale@std@@QAE@PBDH@Z");
769 "??1locale@std@@QAE@XZ");
771 SET(p_basic_string_char_ctor_cstr_alloc
,
772 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z");
773 SET(p_basic_string_char_cstr
,
774 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
775 SET(p_basic_string_char_dtor
,
776 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
778 SET(p_basic_string_wchar_ctor_cstr_alloc
,
779 "??0?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@PBGABV?$allocator@G@1@@Z");
780 SET(p_basic_string_wchar_cstr
,
781 "?c_str@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEPBGXZ");
782 SET(p_basic_string_wchar_dtor
,
783 "??1?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@XZ");
786 init_thiscall_thunk();
792 /* convert a dll name A->W without depending on the current codepage */
793 static wchar_t *AtoW( wchar_t *nameW
, const char *nameA
, unsigned int len
)
797 for (i
= 0; i
< len
; i
++) nameW
[i
] = nameA
[i
];
802 static void test_num_get_get_double(void)
804 unsigned short testus
, nextus
;
805 basic_stringstream_wchar wss
;
806 basic_stringstream_char ss
;
807 basic_string_wchar wstr
;
808 basic_string_char str
;
815 /* makes tables narrower */
816 const IOSB_iostate IOSTATE_faileof
= IOSTATE_failbit
|IOSTATE_eofbit
;
818 struct _test_num_get
{
826 { "0", NULL
, IOSTATE_eofbit
, 0.0, EOF
},
827 { "10", NULL
, IOSTATE_eofbit
, 10.0, EOF
},
828 { "+10", NULL
, IOSTATE_eofbit
, 10.0, EOF
},
829 { "-10", NULL
, IOSTATE_eofbit
, -10.0, EOF
},
830 { "+010", NULL
, IOSTATE_eofbit
, 10.0, EOF
}, /* leading zero */
832 /* test grouping - default/"C" has no grouping, named English/German locales do */
833 { "1,000", NULL
, IOSTATE_goodbit
, 1.0, ',' }, /* with comma */
834 { "1,000", "English", IOSTATE_goodbit
, 1.0, ',' }, /* msvcp60 doesn't support grouping */
835 { "1,000", "German", IOSTATE_eofbit
, 1.0, EOF
},
837 /* extra digits and stuff */
838 { "00000.123456", NULL
, IOSTATE_eofbit
, 0.123456, EOF
},
839 { "0.1234560000", NULL
, IOSTATE_eofbit
, 0.123456, EOF
},
840 { "100aaaa", NULL
, IOSTATE_goodbit
, 100.0, 'a' },
843 { "10e10", NULL
, IOSTATE_eofbit
, 10e10
, EOF
}, /* lowercase e */
844 { "10E10", NULL
, IOSTATE_eofbit
, 10E10
, EOF
}, /* uppercase E */
845 { "10e+10", NULL
, IOSTATE_eofbit
, 10e10
, EOF
}, /* sign */
846 { "10e-10", NULL
, IOSTATE_eofbit
, 10e-10, EOF
},
847 { "10.e10", NULL
, IOSTATE_eofbit
, 10e10
, EOF
}, /* trailing decimal before exponent */
848 { "-10.e-10", NULL
, IOSTATE_eofbit
, -10e-10, EOF
},
849 { "-12.345e-10", NULL
, IOSTATE_eofbit
, -12.345e-10, EOF
},
850 { "1,234e10", NULL
, IOSTATE_goodbit
, 1.0, ',' },
851 { "1,234e10", "German", IOSTATE_eofbit
, 1.234e10
, EOF
},
852 { "1.0e999", NULL
, IOSTATE_faileof
, 42.0, EOF
}, /* too big */
853 { "1.0e-999", NULL
, IOSTATE_faileof
, 42.0, EOF
}, /* too small */
856 { "1.0ee10", NULL
, IOSTATE_failbit
, 42.0, EOF
}, /* dup exp */
857 { "1.0e1.0", NULL
, IOSTATE_goodbit
, 10.0, '.' }, /* decimal in exponent */
858 { "1.0e1,0", NULL
, IOSTATE_goodbit
, 10.0, ',' }, /* group in exponent */
861 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
863 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
864 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
867 call_func3(p_locale_ctor_cstr
, &lcl
, tests
[i
].lcl
, 0x3f /* FIXME: support categories */);
868 call_func3(p_basic_ios_char_imbue
, &ss
.basic_ios
, &retlcl
, &lcl
);
872 call_func2(p_basic_istream_char_read_double
, &ss
.base
.base1
, &val
);
873 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
874 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
876 if(tests
[i
].lcl
&& state
==IOSTATE_badbit
) {
877 win_skip("strange behavior when non-C locale is used\n");
881 ok(tests
[i
].state
== state
, "%d) wrong state, expected = %x found = %x\n", i
, tests
[i
].state
, state
);
882 ok(tests
[i
].val
== val
, "%d) wrong val, expected = %g found %g\n", i
, tests
[i
].val
, val
);
883 ok(tests
[i
].next
== next
, "%d) wrong next, expected = %c (%i) found = %c (%i)\n", i
, tests
[i
].next
, tests
[i
].next
, next
, next
);
886 call_func1(p_locale_dtor
, &lcl
);
888 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
889 call_func1(p_basic_string_char_dtor
, &str
);
891 /* wchar_t version */
892 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
893 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
894 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
897 call_func3(p_locale_ctor_cstr
, &lcl
, tests
[i
].lcl
, 0x3f /* FIXME: support categories */);
898 call_func3(p_basic_ios_wchar_imbue
, &wss
.basic_ios
, &retlcl
, &lcl
);
902 call_func2(p_basic_istream_wchar_read_double
, &wss
.base
.base1
, &val
);
903 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
904 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
906 ok(tests
[i
].state
== state
, "%d) wrong state, expected = %x found = %x\n", i
, tests
[i
].state
, state
);
907 ok(tests
[i
].val
== val
, "%d) wrong val, expected = %g found %g\n", i
, tests
[i
].val
, val
);
908 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
909 ok(testus
== nextus
, "%d) wrong next, expected = %c (%i) found = %c (%i)\n", i
, testus
, testus
, nextus
, nextus
);
912 call_func1(p_locale_dtor
, &lcl
);
914 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
915 call_func1(p_basic_string_wchar_dtor
, &wstr
);
920 static void test_num_put_put_double(void)
922 basic_stringstream_wchar wss
;
923 basic_stringstream_char ss
;
924 basic_string_wchar pwstr
;
925 basic_string_char pstr
;
932 struct _test_num_get
{
935 streamsize prec
; /* set to -1 for default */
936 IOSB_fmtflags fmtfl
; /* FMTFLAG_scientific, FMTFLAG_fixed */
939 { 0.0, NULL
, -1, 0, "0" },
942 { 0.123, NULL
, -1, 0, "0.123" },
943 { 0.123, NULL
, 6, 0, "0.123" },
944 { 0.123, NULL
, 0, 0, "0.123" },
947 { 0.123, NULL
, -1, FMTFLAG_fixed
, "0.123000" },
948 { 0.123, NULL
, 6, FMTFLAG_fixed
, "0.123000" },
949 { 0.123, NULL
, 0, FMTFLAG_fixed
, "0" },
951 /* scientific format */
952 { 123456.789, NULL
, -1, FMTFLAG_scientific
, "1.234568e+005" },
953 { 123456.789, NULL
, 0, FMTFLAG_scientific
, "1.234568e+005" },
954 { 123456.789, NULL
, 9, FMTFLAG_scientific
, "1.234567890e+005" },
955 { 123456.789, "German", 9, FMTFLAG_scientific
, "1,234567890e+005" },
957 /* different locales */
958 { 0.123, "C", -1, 0, "0.123" },
959 { 0.123, "English", -1, 0, "0.123" },
960 { 0.123, "German", -1, 0, "0,123" },
962 { 123456.789, "C", -1, 0, "123457" },
963 { 123456.789, "English", -1, 0, "123457" },
964 { 123456.789, "German", -1, 0, "123457" },
966 /* signs and exponents */
967 { 1.0e-9, NULL
, -1, 0, "1e-009" },
968 { 1.0e-9, NULL
, 9, 0, "1e-009" },
969 { -1.0e9
, NULL
, -1, 0, "-1e+009" },
970 { -1.0e9
, NULL
, 9, 0, "-1e+009" },
972 { 1.0e-9, NULL
, 0, FMTFLAG_fixed
, "0" },
973 { 1.0e-9, NULL
, 6, FMTFLAG_fixed
, "0.000000" },
974 { 1.0e-9, NULL
, 9, FMTFLAG_fixed
, "0.000000001" },
975 { -1.0e9
, NULL
, 0, FMTFLAG_fixed
, "-1000000000" },
976 { -1.0e9
, NULL
, 6, FMTFLAG_fixed
, "-1000000000.000000" },
978 { -1.23456789e9
, NULL
, 0, 0, "-1.23457e+009" },
979 { -1.23456789e9
, NULL
, 0, FMTFLAG_fixed
, "-1234567890" },
980 { -1.23456789e9
, NULL
, 6, FMTFLAG_fixed
, "-1234567890.000000" },
981 { -1.23456789e-9, NULL
, 6, FMTFLAG_fixed
, "-0.000000" },
982 { -1.23456789e-9, NULL
, 9, FMTFLAG_fixed
, "-0.000000001" }
985 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
987 call_func3(p_basic_stringstream_char_ctor_mode
, &ss
, OPENMODE_in
|OPENMODE_out
, TRUE
);
990 call_func3(p_locale_ctor_cstr
, &lcl
, tests
[i
].lcl
, 0x3f /* FIXME: support categories */);
991 call_func3(p_basic_ios_char_imbue
, &ss
.basic_ios
, &retlcl
, &lcl
);
994 /* set format and precision only if specified, so we can try defaults */
996 call_func3(p_ios_base_setf_mask
, &ss
.basic_ios
.base
, tests
[i
].fmtfl
, FMTFLAG_floatfield
);
997 if(tests
[i
].prec
!= -1)
998 call_func2(p_ios_base_precision_set
, &ss
.basic_ios
.base
, tests
[i
].prec
);
999 call_func2_ptr_dbl(p_basic_ostream_char_print_double
, &ss
.base
.base2
, tests
[i
].val
);
1001 call_func2(p_basic_stringstream_char_str_get
, &ss
, &pstr
);
1002 str
= call_func1(p_basic_string_char_cstr
, &pstr
);
1004 ok(!strcmp(tests
[i
].str
, str
), "wrong output, expected = %s found = %s\n", tests
[i
].str
, str
);
1005 call_func1(p_basic_string_char_dtor
, &pstr
);
1008 call_func1(p_locale_dtor
, &lcl
);
1010 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1012 /* wchar_t version */
1013 call_func3(p_basic_stringstream_wchar_ctor_mode
, &wss
, OPENMODE_in
|OPENMODE_out
, TRUE
);
1016 call_func3(p_locale_ctor_cstr
, &lcl
, tests
[i
].lcl
, 0x3f /* FIXME: support categories */);
1017 call_func3(p_basic_ios_wchar_imbue
, &wss
.basic_ios
, &retlcl
, &lcl
);
1020 /* set format and precision only if specified, so we can try defaults */
1022 call_func3(p_ios_base_setf_mask
, &wss
.basic_ios
.base
, tests
[i
].fmtfl
, FMTFLAG_floatfield
);
1023 if(tests
[i
].prec
!= -1)
1024 call_func2(p_ios_base_precision_set
, &wss
.basic_ios
.base
, tests
[i
].prec
);
1025 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double
, &wss
.base
.base2
, tests
[i
].val
);
1027 call_func2(p_basic_stringstream_wchar_str_get
, &wss
, &pwstr
);
1028 wstr
= call_func1(p_basic_string_wchar_cstr
, &pwstr
);
1030 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1031 ok(!lstrcmpW(wide
, wstr
), "wrong output, expected = %s found = %s\n", tests
[i
].str
, wine_dbgstr_w(wstr
));
1032 call_func1(p_basic_string_wchar_dtor
, &pwstr
);
1035 call_func1(p_locale_dtor
, &lcl
);
1037 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1042 static void test_istream_ipfx(void)
1044 unsigned short testus
, nextus
;
1045 basic_stringstream_wchar wss
;
1046 basic_stringstream_char ss
;
1047 basic_string_wchar wstr
;
1048 basic_string_char str
;
1054 struct _test_istream_ipfx
{
1062 /* string unset noskip return state next char */
1063 { "", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, EOF
}, /* empty string */
1064 { " ", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, EOF
}, /* just ws */
1065 { "\t \n \f ", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, EOF
}, /* different ws */
1066 { "simple", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, 's' },
1067 { " simple", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, 's' },
1068 { " simple", TRUE
, FALSE
, TRUE
, IOSTATE_goodbit
, ' ' }, /* unset skipws */
1069 { " simple", FALSE
, TRUE
, TRUE
, IOSTATE_goodbit
, ' ' }, /* ipfx(true) */
1070 { " simple", TRUE
, TRUE
, TRUE
, IOSTATE_goodbit
, ' ' }, /* both */
1071 { "\n\t ws", FALSE
, FALSE
, TRUE
, IOSTATE_goodbit
, 'w' },
1072 { "\n\t ws", TRUE
, FALSE
, TRUE
, IOSTATE_goodbit
, '\n' },
1075 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1077 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1078 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1080 /* set format and precision only if specified, so we can try defaults */
1081 if(tests
[i
].unset_skipws
)
1082 call_func2(p_ios_base_unsetf
, &ss
.basic_ios
.base
, TRUE
);
1084 ret
= (MSVCP_bool
)(INT_PTR
)call_func2(p_basic_istream_char_ipfx
, &ss
.base
.base1
, tests
[i
].noskip
);
1085 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1086 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
1088 ok(tests
[i
].ret
== ret
, "%d) wrong return, expected = %i found = %i\n", i
, tests
[i
].ret
, ret
);
1089 ok(tests
[i
].state
== state
, "%d) wrong state, expected = %x found = %x\n", i
, tests
[i
].state
, state
);
1090 ok(tests
[i
].next
== next
, "%d) wrong next, expected = %c (%i) found = %c (%i)\n", i
, tests
[i
].next
, tests
[i
].next
, next
, next
);
1092 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1093 call_func1(p_basic_string_char_dtor
, &str
);
1095 /* wchar_t version */
1096 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1097 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1098 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1100 /* set format and precision only if specified, so we can try defaults */
1101 if(tests
[i
].unset_skipws
)
1102 call_func2(p_ios_base_unsetf
, &wss
.basic_ios
.base
, TRUE
);
1104 ret
= (MSVCP_bool
)(INT_PTR
)call_func2(p_basic_istream_wchar_ipfx
, &wss
.base
.base1
, tests
[i
].noskip
);
1105 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1106 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
1108 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1109 ok(tests
[i
].ret
== ret
, "wrong return, expected = %i found = %i\n", tests
[i
].ret
, ret
);
1110 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
1111 ok(testus
== nextus
, "wrong next, expected = %c (%i) found = %c (%i)\n", testus
, testus
, nextus
, nextus
);
1113 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1114 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1119 static void test_istream_ignore(void)
1121 unsigned short testus
, nextus
;
1122 basic_stringstream_wchar wss
;
1123 basic_stringstream_char ss
;
1124 basic_string_wchar wstr
;
1125 basic_string_char str
;
1130 struct _test_istream_ignore
{
1137 /* string count delim state next */
1138 { "", 0, '\n', IOSTATE_goodbit
, EOF
}, /* empty string */
1140 /* different counts */
1141 { "ABCDEF", 2, '\n', IOSTATE_goodbit
, 'C' }, /* easy case */
1142 { "ABCDEF", 42, '\n', IOSTATE_eofbit
, EOF
}, /* ignore too much */
1143 { "ABCDEF", -2, '\n', IOSTATE_goodbit
, 'A' }, /* negative count */
1144 { "ABCDEF", 6, '\n', IOSTATE_goodbit
, EOF
}, /* is eof not set at end */
1145 { "ABCDEF", 7, '\n', IOSTATE_eofbit
, EOF
}, /* eof is set just after end */
1147 /* different delimiters */
1148 { "ABCDEF", 42, '\0', IOSTATE_eofbit
, EOF
}, /* null as delim */
1149 { "ABC DEF GHI", 0, ' ', IOSTATE_goodbit
, 'A' },
1150 { "ABC DEF GHI", 42, ' ', IOSTATE_goodbit
, 'D' },
1151 { "ABC DEF\tGHI", 42, '\t', IOSTATE_goodbit
, 'G' },
1152 { "ABC ", 42, ' ', IOSTATE_goodbit
, EOF
}, /* delim at end */
1155 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1157 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1158 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1160 call_func3(p_basic_istream_char_ignore
, &ss
.base
.base1
, tests
[i
].count
, tests
[i
].delim
);
1161 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1162 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
1164 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1165 ok(tests
[i
].next
== next
, "wrong next, expected = %c (%i) found = %c (%i)\n", tests
[i
].next
, tests
[i
].next
, next
, next
);
1167 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1168 call_func1(p_basic_string_char_dtor
, &str
);
1170 /* wchar_t version */
1171 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1172 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1173 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1175 call_func3(p_basic_istream_wchar_ignore
, &wss
.base
.base1
, tests
[i
].count
, tests
[i
].delim
);
1176 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1177 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
1179 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1180 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
1181 ok(testus
== nextus
, "wrong next, expected = %c (%i) found = %c (%i)\n", testus
, testus
, nextus
, nextus
);
1183 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1184 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1189 static void test_istream_seekg(void)
1191 unsigned short testus
, nextus
;
1192 basic_stringstream_wchar wss
;
1193 basic_stringstream_char ss
;
1194 basic_string_wchar wstr
;
1195 basic_string_char str
;
1200 struct _test_istream_seekg
{
1207 { "ABCDEFGHIJ", 0, SEEKDIR_beg
, IOSTATE_goodbit
, 'A' },
1208 { "ABCDEFGHIJ", 1, SEEKDIR_beg
, IOSTATE_goodbit
, 'B' },
1209 { "ABCDEFGHIJ", 5, SEEKDIR_cur
, IOSTATE_goodbit
, 'F' },
1210 { "ABCDEFGHIJ", -3, SEEKDIR_end
, IOSTATE_goodbit
, 'H' },
1213 { "ABCDEFGHIJ", -1, SEEKDIR_beg
, IOSTATE_goodbit
, 'A' },
1214 { "ABCDEFGHIJ", 42, SEEKDIR_cur
, IOSTATE_goodbit
, 'A' },
1215 { "ABCDEFGHIJ", 42, SEEKDIR_end
, IOSTATE_goodbit
, 'A' },
1216 { "", 0, SEEKDIR_beg
, IOSTATE_goodbit
, EOF
},
1219 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1221 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1222 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1224 call_func3(p_basic_istream_char_seekg
, &ss
.base
.base1
, tests
[i
].off
, tests
[i
].dir
);
1225 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1226 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
1228 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1229 ok(tests
[i
].next
== next
, "wrong next, expected = %c (%i) found = %c (%i)\n", tests
[i
].next
, tests
[i
].next
, next
, next
);
1231 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1232 call_func1(p_basic_string_char_dtor
, &str
);
1234 /* wchar_t version */
1235 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1236 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1237 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1239 call_func3(p_basic_istream_wchar_seekg
, &wss
.base
.base1
, tests
[i
].off
, tests
[i
].dir
);
1240 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1241 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
1243 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1244 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
1245 ok(testus
== nextus
, "wrong next, expected = %c (%i) found = %c (%i)\n", testus
, testus
, nextus
, nextus
);
1247 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1248 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1253 static void test_istream_seekg_fpos(void)
1255 unsigned short testus
, nextus
;
1256 basic_stringstream_wchar wss
;
1257 basic_stringstream_char ss
;
1258 basic_string_wchar wstr
;
1259 basic_string_char str
;
1265 struct _test_istream_seekg_fpos
{
1271 { "ABCDEFGHIJ", 0, IOSTATE_goodbit
, 'A' },
1272 { "ABCDEFGHIJ", 9, IOSTATE_goodbit
, 'J' },
1273 { "ABCDEFGHIJ", 10, IOSTATE_goodbit
, EOF
}, /* beyond end, but still good */
1274 { "ABCDEFGHIJ", -1, IOSTATE_goodbit
, 'A' },
1275 { "", 0, IOSTATE_goodbit
, EOF
},
1278 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1280 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1281 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1283 pos
.off
= tests
[i
].off
;
1284 pos
.pos
= 0; /* FIXME: a later patch will test this with filebuf */
1286 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos
, &ss
.base
.base1
, pos
);
1287 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1288 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
1290 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1291 ok(tests
[i
].next
== next
, "wrong next, expected = %c (%i) found = %c (%i)\n", tests
[i
].next
, tests
[i
].next
, next
, next
);
1293 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1294 call_func1(p_basic_string_char_dtor
, &str
);
1296 /* wchar_t version */
1297 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1298 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1299 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1301 pos
.off
= tests
[i
].off
;
1302 pos
.pos
= 0; /* FIXME: a later patch will test this with filebuf */
1304 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos
, &wss
.base
.base1
, pos
);
1305 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1306 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
1308 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1309 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
1310 ok(testus
== nextus
, "wrong next, expected = %c (%i) found = %c (%i)\n", testus
, testus
, nextus
, nextus
);
1312 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1313 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1318 static void test_istream_peek(void)
1320 unsigned short testus
, nextus
, peekus
;
1321 basic_stringstream_wchar wss
;
1322 basic_stringstream_char ss
;
1323 basic_string_wchar wstr
;
1324 basic_string_char str
;
1329 struct _test_istream_peek
{
1335 { "", EOF
, EOF
, IOSTATE_eofbit
},
1336 { "ABCDEF", 'A', 'A', IOSTATE_goodbit
},
1339 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1341 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1342 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1344 peek
= (int)call_func1(p_basic_istream_char_peek
, &ss
.base
.base1
);
1345 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1346 next
= (int)call_func1(p_basic_istream_char_get
, &ss
.base
.base1
);
1348 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1349 ok(tests
[i
].next
== next
, "wrong next, expected = %c (%i) found = %c (%i)\n", tests
[i
].next
, tests
[i
].next
, next
, next
);
1350 ok(peek
== next
, "wrong peek, expected %c (%i) found = %c (%i)\n", peek
, peek
, next
, next
);
1352 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1353 call_func1(p_basic_string_char_dtor
, &str
);
1355 /* wchar_t version */
1356 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1357 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1358 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1360 peekus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_peek
, &wss
.base
.base1
);
1361 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1362 nextus
= (unsigned short)(int)call_func1(p_basic_istream_wchar_get
, &wss
.base
.base1
);
1364 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1365 testus
= tests
[i
].next
== EOF
? WEOF
: (unsigned short)tests
[i
].next
;
1366 ok(testus
== nextus
, "wrong next, expected = %c (%i) found = %c (%i)\n", testus
, testus
, nextus
, nextus
);
1367 ok(peekus
== nextus
, "wrong peek, expected %c (%i) found = %c (%i)\n", peekus
, peekus
, nextus
, nextus
);
1369 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1370 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1375 static void test_istream_tellg(void)
1377 basic_stringstream_wchar wss
;
1378 basic_stringstream_char ss
;
1379 basic_fstream_wchar wfs
;
1380 basic_fstream_char fs
;
1381 basic_string_wchar wstr
;
1382 basic_string_char str
;
1383 fpos_int spos
, tpos
, *rpos
;
1388 const char *testfile
= "file.txt";
1390 struct _test_istream_tellg_fpos
{
1393 streamoff telloff_ss
; /* offset for stringstream */
1394 streamoff telloff_fs
; /* offset for fstream */
1398 { "", -1, -1, 0, 0 }, /* tellg on defaults */
1399 { "", 0, -1, 0, 0 }, /* tellg after seek 0 */
1400 { "", 42, -1, 0, 42 }, /* tellg after seek beyond end */
1401 { "", -6, -1, 0, 0 }, /* tellg after seek beyond beg */
1403 /* non-empty strings */
1404 { "ABCDEFGHIJ", -1, 0, 0, 0 },
1405 { "ABCDEFGHIJ", 3, 3, 0, 3 },
1406 { "ABCDEFGHIJ", 42, 0, 0, 42 },
1407 { "ABCDEFGHIJ", -6, 0, 0, 0 }
1410 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1411 /* stringstream<char> version */
1412 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1413 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1415 spos
.off
= tests
[i
].seekoff
;
1419 tpos
.off
= 0xdeadbeef;
1420 tpos
.pos
= 0xdeadbeef;
1421 tpos
.state
= 0xdeadbeef;
1423 if (tests
[i
].seekoff
!= -1) /* to test without seek */
1424 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos
, &ss
.base
.base1
, spos
);
1425 rpos
= call_func2(p_basic_istream_char_tellg
, &ss
.base
.base1
, &tpos
);
1427 ok(tests
[i
].telloff_ss
== tpos
.off
, "wrong offset, expected = %ld found = %ld\n", tests
[i
].telloff_ss
, tpos
.off
);
1428 ok(rpos
== &tpos
, "wrong return fpos, expected = %p found = %p\n", rpos
, &tpos
);
1429 ok(tpos
.pos
== 0, "wrong position, expected = 0 found = %s\n", wine_dbgstr_longlong(tpos
.pos
));
1430 ok(tpos
.state
== 0, "wrong state, expected = 0 found = %d\n", tpos
.state
);
1431 if(tests
[i
].seekoff
== -1) {
1432 ok(ss
.basic_ios
.base
.state
== IOSTATE_goodbit
,
1433 "ss.basic_ios.base.state = %x\n", ss
.basic_ios
.base
.state
);
1436 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1437 call_func1(p_basic_string_char_dtor
, &str
);
1439 /* stringstream<wchar_t> version */
1440 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1441 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1442 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1444 spos
.off
= tests
[i
].seekoff
;
1445 spos
.pos
= 0; /* FIXME: a later patch will test this with filebuf */
1448 tpos
.off
= 0xdeadbeef;
1449 tpos
.pos
= 0xdeadbeef;
1450 tpos
.state
= 0xdeadbeef;
1452 if (tests
[i
].seekoff
!= -1) /* to test without seek */
1453 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos
, &wss
.base
.base1
, spos
);
1454 rpos
= call_func2(p_basic_istream_wchar_tellg
, &wss
.base
.base1
, &tpos
);
1456 ok(tests
[i
].telloff_ss
== tpos
.off
, "wrong offset, expected = %ld found = %ld\n", tests
[i
].telloff_ss
, tpos
.off
);
1457 ok(rpos
== &tpos
, "wrong return fpos, expected = %p found = %p\n", rpos
, &tpos
);
1458 ok(tpos
.pos
== 0, "wrong position, expected = 0 found = %s\n", wine_dbgstr_longlong(tpos
.pos
));
1459 ok(tpos
.state
== 0, "wrong state, expected = 0 found = %d\n", tpos
.state
);
1460 if(tests
[i
].seekoff
== -1) {
1461 ok(ss
.basic_ios
.base
.state
== IOSTATE_goodbit
,
1462 "ss.basic_ios.base.state = %x\n", ss
.basic_ios
.base
.state
);
1465 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1466 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1469 file
= fopen(testfile
, "wt");
1470 fprintf(file
, "%s", tests
[i
].str
);
1473 /* fstream<char> version */
1474 call_func4(p_basic_fstream_char_ctor_name
, &fs
, testfile
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1476 spos
.off
= tests
[i
].seekoff
;
1480 tpos
.off
= 0xdeadbeef;
1481 tpos
.pos
= 0xdeadbeef;
1482 tpos
.state
= 0xdeadbeef;
1484 if (tests
[i
].seekoff
!= -1) /* to test without seek */
1485 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos
, &fs
.base
.base1
, spos
);
1486 rpos
= call_func2(p_basic_istream_char_tellg
, &fs
.base
.base1
, &tpos
);
1488 ok(tests
[i
].tellpos
== tpos
.pos
, "wrong filepos, expected = %s found = %s\n",
1489 wine_dbgstr_longlong(tests
[i
].tellpos
), wine_dbgstr_longlong(tpos
.pos
));
1490 ok(rpos
== &tpos
, "wrong return fpos, expected = %p found = %p\n", rpos
, &tpos
);
1491 ok(tpos
.off
== tests
[i
].telloff_fs
, "wrong offset, expected %ld found %ld\n", tests
[i
].telloff_fs
, tpos
.off
);
1492 ok(tpos
.state
== 0, "wrong state, expected = 0 found = %d\n", tpos
.state
);
1494 call_func1(p_basic_fstream_char_vbase_dtor
, &fs
);
1496 /* fstream<wchar_t> version */
1497 call_func4(p_basic_fstream_wchar_ctor_name
, &wfs
, testfile
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1499 spos
.off
= tests
[i
].seekoff
;
1503 tpos
.off
= 0xdeadbeef;
1504 tpos
.pos
= 0xdeadbeef;
1505 tpos
.state
= 0xdeadbeef;
1507 if (tests
[i
].seekoff
!= -1) /* to test without seek */
1508 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos
, &wfs
.base
.base1
, spos
);
1509 rpos
= call_func2(p_basic_istream_wchar_tellg
, &wfs
.base
.base1
, &tpos
);
1511 ok(tests
[i
].tellpos
== tpos
.pos
, "wrong filepos, expected = %s found = %s\n",
1512 wine_dbgstr_longlong(tests
[i
].tellpos
), wine_dbgstr_longlong(tpos
.pos
));
1513 ok(rpos
== &tpos
, "wrong return fpos, expected = %p found = %p\n", rpos
, &tpos
);
1514 ok(tpos
.off
== tests
[i
].telloff_fs
, "wrong offset, expected %ld found %ld\n", tests
[i
].telloff_fs
, tpos
.off
);
1515 ok(tpos
.state
== 0, "wrong state, expected = 0 found = %d\n", tpos
.state
);
1517 call_func1(p_basic_fstream_wchar_vbase_dtor
, &wfs
);
1524 static void test_istream_getline(void)
1526 basic_stringstream_wchar wss
;
1527 basic_stringstream_char ss
;
1528 basic_string_wchar wstr
;
1529 basic_string_char str
;
1534 const wchar_t *wcstr
;
1536 /* makes tables narrower */
1537 const IOSB_iostate IOSTATE_faileof
= IOSTATE_failbit
|IOSTATE_eofbit
;
1539 struct _test_istream_getline
{
1544 const char *nextline
;
1546 IOSB_iostate nextstate
;
1548 { "", "", '\n', IOSTATE_faileof
, "", '\n', IOSTATE_faileof
},
1550 { "this\n", "this", '\n', IOSTATE_goodbit
, "", '\n', IOSTATE_faileof
},
1551 { "this\nis\nsome\ntext\n", "this", '\n', IOSTATE_goodbit
, "is", '\n', IOSTATE_goodbit
},
1553 { "this is some text\n", "this", ' ', IOSTATE_goodbit
, "is", ' ', IOSTATE_goodbit
},
1554 { "this is some text\n", "this", ' ', IOSTATE_goodbit
, "is some text", '\n', IOSTATE_goodbit
},
1556 { "this is some text\n", "this is some text", '\n', IOSTATE_goodbit
, "", '\n', IOSTATE_faileof
},
1557 { "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit
, "", '\n', IOSTATE_faileof
},
1560 if(!p_basic_istream_char_getline_bstr_delim
|| !p_basic_istream_wchar_getline_bstr_delim
) {
1561 win_skip("basic_istream::getline(basic_string, delim) is not available\n");
1565 for(i
=0; i
<ARRAY_SIZE(tests
); i
++) {
1567 call_func3(p_basic_string_char_ctor_cstr_alloc
, &str
, tests
[i
].str
, &fake_allocator
);
1568 call_func4(p_basic_stringstream_char_ctor_str
, &ss
, &str
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1570 p_basic_istream_char_getline_bstr_delim(&ss
.base
.base1
, &str
, tests
[i
].delim
);
1571 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1572 cstr
= call_func1(p_basic_string_char_cstr
, &str
);
1574 ok(!strcmp(tests
[i
].line
, cstr
), "wrong line, expected = %s found = %s\n", tests
[i
].line
, cstr
);
1575 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1578 p_basic_istream_char_getline_bstr_delim(&ss
.base
.base1
, &str
, tests
[i
].nextdelim
);
1579 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &ss
.basic_ios
.base
);
1580 cstr
= call_func1(p_basic_string_char_cstr
, &str
);
1582 ok(!strcmp(tests
[i
].nextline
, cstr
), "wrong next line, expected = %s found = %s\n", tests
[i
].nextline
, cstr
);
1583 ok(tests
[i
].nextstate
== state
, "wrong next state, expected = %x found = %x\n", tests
[i
].nextstate
, state
);
1585 call_func1(p_basic_stringstream_char_vbase_dtor
, &ss
);
1586 call_func1(p_basic_string_char_dtor
, &str
);
1588 /* wchar_t version */
1589 AtoW(wide
, tests
[i
].str
, strlen(tests
[i
].str
));
1590 call_func3(p_basic_string_wchar_ctor_cstr_alloc
, &wstr
, wide
, &fake_allocator
);
1591 call_func4(p_basic_stringstream_wchar_ctor_str
, &wss
, &wstr
, OPENMODE_out
|OPENMODE_in
, TRUE
);
1593 p_basic_istream_wchar_getline_bstr_delim(&wss
.base
.base1
, &wstr
, tests
[i
].delim
);
1594 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1595 wcstr
= call_func1(p_basic_string_wchar_cstr
, &wstr
);
1597 AtoW(wide
, tests
[i
].line
, strlen(tests
[i
].line
));
1598 ok(!lstrcmpW(wide
, wcstr
), "wrong line, expected = %s found = %s\n", tests
[i
].line
, wine_dbgstr_w(wcstr
));
1599 ok(tests
[i
].state
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].state
, state
);
1602 p_basic_istream_wchar_getline_bstr_delim(&wss
.base
.base1
, &wstr
, tests
[i
].nextdelim
);
1603 state
= (IOSB_iostate
)call_func1(p_ios_base_rdstate
, &wss
.basic_ios
.base
);
1604 wcstr
= call_func1(p_basic_string_wchar_cstr
, &wstr
);
1606 AtoW(wide
, tests
[i
].nextline
, strlen(tests
[i
].nextline
));
1607 ok(!lstrcmpW(wide
, wcstr
), "wrong line, expected = %s found = %s\n", tests
[i
].nextline
, wine_dbgstr_w(wcstr
));
1608 ok(tests
[i
].nextstate
== state
, "wrong state, expected = %x found = %x\n", tests
[i
].nextstate
, state
);
1610 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1611 call_func1(p_basic_string_wchar_dtor
, &wstr
);
1615 static void test_ostream_print_ushort(void)
1617 basic_stringstream_wchar wss
;
1618 basic_string_wchar pwstr
;
1619 const wchar_t *wstr
;
1621 call_func3(p_basic_stringstream_wchar_ctor_mode
, &wss
, OPENMODE_in
|OPENMODE_out
, TRUE
);
1622 call_func2(p_basic_ostream_short_print_ushort
, &wss
.base
.base2
, 65);
1624 call_func2(p_basic_stringstream_wchar_str_get
, &wss
, &pwstr
);
1625 wstr
= call_func1(p_basic_string_wchar_cstr
, &pwstr
);
1626 ok(!lstrcmpW(L
"65", wstr
), "wstr = %s\n", wine_dbgstr_w(wstr
));
1628 call_func1(p_basic_string_wchar_dtor
, &pwstr
);
1629 call_func1(p_basic_stringstream_wchar_vbase_dtor
, &wss
);
1634 const char* export_name
;
1635 } vbtable_size_exports_list
[] = {
1636 {{0x60, 0xb0}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1637 {{0x58, 0xa0}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1638 {{0x60, 0xb0}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1639 {{0x58, 0xa0}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1640 {{0x5c, 0xa8}, "??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@"},
1641 {{0x5c, 0xa8}, "??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@"},
1642 {{ 0xc, 0x18}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1643 {{ 0x4, 0x8}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1644 {{ 0xc, 0x18}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1645 {{ 0x4, 0x8}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1646 {{ 0x8, 0x10}, "??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@"},
1647 {{ 0x8, 0x10}, "??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@"},
1648 {{0x54, 0x98}, "??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1649 {{0x54, 0x98}, "??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1650 {{0x58, 0xa0}, "??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@"},
1651 {{0x58, 0xa0}, "??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@"},
1652 {{ 0x4, 0x8}, "??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@"},
1653 {{ 0x4, 0x8}, "??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@"},
1654 {{0x50, 0x90}, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1655 {{0x50, 0x90}, "??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1656 {{0x58, 0xa0}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1657 {{0x50, 0x90}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1658 {{0x58, 0xa0}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1659 {{0x50, 0x90}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1663 static void test_vbtable_size_exports(void)
1666 const int *p_vbtable
;
1667 int arch_idx
= (sizeof(void*) == 8);
1669 for (i
= 0; vbtable_size_exports_list
[i
].export_name
; i
++)
1671 SET(p_vbtable
, vbtable_size_exports_list
[i
].export_name
);
1673 ok(p_vbtable
[0] == 0, "vbtable[0] wrong, got 0x%x\n", p_vbtable
[0]);
1674 ok(p_vbtable
[1] == vbtable_size_exports_list
[i
].value
[arch_idx
],
1675 "%d: %s[1] wrong, got 0x%x\n", i
, vbtable_size_exports_list
[i
].export_name
, p_vbtable
[1]);
1685 test_num_get_get_double();
1686 test_num_put_put_double();
1687 test_istream_ipfx();
1688 test_istream_ignore();
1689 test_istream_seekg();
1690 test_istream_seekg_fpos();
1691 test_istream_peek();
1692 test_istream_tellg();
1693 test_istream_getline();
1694 test_ostream_print_ushort();
1696 test_vbtable_size_exports();