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"
28 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
29 static void (__cdecl *p_free)(void*);
33 #define __thiscall __stdcall
35 #define __thiscall __cdecl
38 typedef unsigned char MSVCP_bool;
39 typedef SIZE_T MSVCP_size_t;
40 typedef SSIZE_T streamoff;
41 typedef SSIZE_T streamsize;
43 typedef void (*vtable_ptr)(void);
53 struct _locale__Locimp *ptr;
56 /* class locale::facet */
58 const vtable_ptr *vtable;
62 /* class codecvt_base */
67 /* class codecvt<char> */
77 /* class codecvt<wchar> */
84 FMTFLAG_skipws = 0x0001,
85 FMTFLAG_unitbuf = 0x0002,
86 FMTFLAG_uppercase = 0x0004,
87 FMTFLAG_showbase = 0x0008,
88 FMTFLAG_showpoint = 0x0010,
89 FMTFLAG_showpos = 0x0020,
90 FMTFLAG_left = 0x0040,
91 FMTFLAG_right = 0x0080,
92 FMTFLAG_internal = 0x0100,
96 FMTFLAG_scientific = 0x1000,
97 FMTFLAG_fixed = 0x2000,
98 FMTFLAG_hexfloat = 0x3000,
99 FMTFLAG_boolalpha = 0x4000,
100 FMTFLAG_stdio = 0x8000,
101 FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
102 FMTFLAG_basefield = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
103 FMTFLAG_floatfield = FMTFLAG_scientific|FMTFLAG_fixed,
104 FMTFLAG_mask = 0xffff
112 OPENMODE_trunc = 0x10,
113 OPENMODE__Nocreate = 0x40,
114 OPENMODE__Noreplace = 0x80,
115 OPENMODE_binary = 0x20,
127 IOSTATE_goodbit = 0x00,
128 IOSTATE_eofbit = 0x01,
129 IOSTATE_failbit = 0x02,
130 IOSTATE_badbit = 0x04,
131 IOSTATE__Hardfail = 0x10,
135 typedef struct _iosarray {
136 struct _iosarray *next;
149 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
150 typedef struct _fnarray {
151 struct _fnarray *next;
153 IOS_BASE_event_callback event_handler;
157 typedef struct _ios_base {
158 const vtable_ptr *vtable;
165 IOS_BASE_iosarray *arr;
166 IOS_BASE_fnarray *calls;
170 /* class basic_streambuf<char> */
172 const vtable_ptr *vtable;
187 } basic_streambuf_char;
189 /* class basic_streambuf<wchar> */
191 const vtable_ptr *vtable;
206 } basic_streambuf_wchar;
209 basic_streambuf_char base;
212 MSVCP_bool wrotesome;
216 } basic_filebuf_char;
219 basic_streambuf_wchar base;
222 MSVCP_bool wrotesome;
226 } basic_filebuf_wchar;
229 basic_streambuf_char base;
232 char allocator; /* empty struct */
233 } basic_stringbuf_char;
236 basic_streambuf_wchar base;
239 char allocator; /* empty struct */
240 } basic_stringbuf_wchar;
244 basic_streambuf_char *strbuf;
245 struct _basic_ostream_char *stream;
251 basic_streambuf_wchar *strbuf;
252 struct _basic_ostream_wchar *stream;
256 typedef struct _basic_ostream_char {
258 /* virtual inheritance
259 * basic_ios_char basic_ios;
261 } basic_ostream_char;
263 typedef struct _basic_ostream_wchar {
265 /* virtual inheritance
266 * basic_ios_wchar basic_ios;
268 } basic_ostream_wchar;
273 /* virtual inheritance
274 * basic_ios_char basic_ios;
276 } basic_istream_char;
281 /* virtual inheritance
282 * basic_ios_wchar basic_ios;
284 } basic_istream_wchar;
287 basic_istream_char base1;
288 basic_ostream_char base2;
289 /* virtual inheritance
290 * basic_ios_char basic_ios;
292 } basic_iostream_char;
295 basic_istream_wchar base1;
296 basic_ostream_wchar base2;
297 /* virtual inheritance
298 * basic_ios_wchar basic_ios;
300 } basic_iostream_wchar;
303 basic_ostream_char base;
304 basic_filebuf_char filebuf;
305 /* virtual inheritance
306 * basic_ios_char basic_ios;
308 } basic_ofstream_char;
311 basic_ostream_wchar base;
312 basic_filebuf_wchar filebuf;
313 /* virtual inheritance
314 * basic_ios_wchar basic_ios;
316 } basic_ofstream_wchar;
319 basic_istream_char base;
320 basic_filebuf_char filebuf;
321 /* virtual inheritance
322 * basic_ios_char basic_ios;
324 } basic_ifstream_char;
327 basic_istream_wchar base;
328 basic_filebuf_wchar filebuf;
329 /* virtual inheritance
330 * basic_ios_wchar basic_ios;
332 } basic_ifstream_wchar;
335 basic_iostream_char base;
336 basic_filebuf_char filebuf;
337 /* virtual inheritance */
338 basic_ios_char basic_ios; /* here to reserve correct stack size */
339 } basic_fstream_char;
342 basic_iostream_wchar base;
343 basic_filebuf_wchar filebuf;
344 /* virtual inheritance */
345 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
346 } basic_fstream_wchar;
349 basic_ostream_char base;
350 basic_stringbuf_char strbuf;
351 /* virtual inheritance
352 * basic_ios_char basic_ios;
354 } basic_ostringstream_char;
357 basic_ostream_wchar base;
358 basic_stringbuf_wchar strbuf;
359 /* virtual inheritance
360 * basic_ios_wchar basic_ios;
362 } basic_ostringstream_wchar;
365 basic_istream_char base;
366 basic_stringbuf_char strbuf;
367 /* virtual inheritance
368 * basic_ios_char basic_ios;
370 } basic_istringstream_char;
373 basic_istream_wchar base;
374 basic_stringbuf_wchar strbuf;
375 /* virtual inheritance
376 * basic_ios_wchar basic_ios;
378 } basic_istringstream_wchar;
381 basic_iostream_char base;
382 basic_stringbuf_char strbuf;
383 /* virtual inheritance */
384 basic_ios_char basic_ios; /* here to reserve correct stack size */
385 } basic_stringstream_char;
388 basic_iostream_wchar base;
389 basic_stringbuf_wchar strbuf;
390 /* virtual inheritance */
391 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
392 } basic_stringstream_wchar;
394 /* basic_string<char, char_traits<char>, allocator<char>> */
395 #define BUF_SIZE_CHAR 16
396 typedef struct _basic_string_char
400 char buf[BUF_SIZE_CHAR];
407 #define BUF_SIZE_WCHAR 8
412 wchar_t buf[BUF_SIZE_WCHAR];
417 } basic_string_wchar;
421 __int64 DECLSPEC_ALIGN(8) pos;
426 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor)(basic_stringstream_char*, MSVCP_bool);
427 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor_str)(basic_stringstream_char*, const basic_string_char*, int, MSVCP_bool);
428 static basic_string_char* (*__thiscall p_basic_stringstream_char_str_get)(const basic_stringstream_char*, basic_string_char*);
429 static void (*__thiscall p_basic_stringstream_char_vbase_dtor)(basic_stringstream_char*);
431 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor)(basic_stringstream_wchar*, MSVCP_bool);
432 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor_str)(basic_stringstream_wchar*, const basic_string_wchar*, int, MSVCP_bool);
433 static basic_string_wchar* (*__thiscall p_basic_stringstream_wchar_str_get)(const basic_stringstream_wchar*, basic_string_wchar*);
434 static void (*__thiscall p_basic_stringstream_wchar_vbase_dtor)(basic_stringstream_wchar*);
437 static basic_fstream_char* (*__thiscall p_basic_fstream_char_ctor_name)(basic_fstream_char*, const char*, int, int, MSVCP_bool);
438 static void (*__thiscall p_basic_fstream_char_vbase_dtor)(basic_fstream_char*);
440 static basic_fstream_wchar* (*__thiscall p_basic_fstream_wchar_ctor_name)(basic_fstream_wchar*, const char*, int, int, MSVCP_bool);
441 static void (*__thiscall p_basic_fstream_wchar_vbase_dtor)(basic_fstream_wchar*);
444 static basic_istream_char* (*__thiscall p_basic_istream_char_read_uint64)(basic_istream_char*, unsigned __int64*);
445 static basic_istream_char* (*__thiscall p_basic_istream_char_read_double)(basic_istream_char*, double*);
446 static int (*__thiscall p_basic_istream_char_get)(basic_istream_char*);
447 static MSVCP_bool (*__thiscall p_basic_istream_char_ipfx)(basic_istream_char*, MSVCP_bool);
448 static basic_istream_char* (*__thiscall p_basic_istream_char_ignore)(basic_istream_char*, streamsize, int);
449 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg)(basic_istream_char*, streamoff, int);
450 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg_fpos)(basic_istream_char*, fpos_int);
451 static int (*__thiscall p_basic_istream_char_peek)(basic_istream_char*);
452 static fpos_int* (*__thiscall p_basic_istream_char_tellg)(basic_istream_char*, fpos_int*);
453 static basic_istream_char* (*__cdecl p_basic_istream_char_getline_bstr_delim)(basic_istream_char*, basic_string_char*, char);
455 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_uint64)(basic_istream_wchar*, unsigned __int64*);
456 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_double)(basic_istream_wchar*, double *);
457 static int (*__thiscall p_basic_istream_wchar_get)(basic_istream_wchar*);
458 static MSVCP_bool (*__thiscall p_basic_istream_wchar_ipfx)(basic_istream_wchar*, MSVCP_bool);
459 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_ignore)(basic_istream_wchar*, streamsize, unsigned short);
460 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg)(basic_istream_wchar*, streamoff, int);
461 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg_fpos)(basic_istream_wchar*, fpos_int);
462 static unsigned short (*__thiscall p_basic_istream_wchar_peek)(basic_istream_wchar*);
463 static fpos_int* (*__thiscall p_basic_istream_wchar_tellg)(basic_istream_wchar*, fpos_int*);
464 static basic_istream_wchar* (*__cdecl p_basic_istream_wchar_getline_bstr_delim)(basic_istream_wchar*, basic_string_wchar*, wchar_t);
467 static basic_ostream_char* (*__thiscall p_basic_ostream_char_print_double)(basic_ostream_char*, double);
469 static basic_ostream_wchar* (*__thiscall p_basic_ostream_wchar_print_double)(basic_ostream_wchar*, double);
472 static locale* (*__thiscall p_basic_ios_char_imbue)(basic_ios_char*, locale*, const locale*);
474 static locale* (*__thiscall p_basic_ios_wchar_imbue)(basic_ios_wchar*, locale*, const locale*);
477 static IOSB_iostate (*__thiscall p_ios_base_rdstate)(const ios_base*);
478 static IOSB_fmtflags (*__thiscall p_ios_base_setf_mask)(ios_base*, IOSB_fmtflags, IOSB_fmtflags);
479 static void (*__thiscall p_ios_base_unsetf)(ios_base*, IOSB_fmtflags);
480 static streamsize (*__thiscall p_ios_base_precision_set)(ios_base*, streamsize);
483 static locale* (*__thiscall p_locale_ctor_cstr)(locale*, const char*, int /* FIXME: category */);
484 static void (*__thiscall p_locale_dtor)(locale *this);
487 static basic_string_char* (__thiscall *p_basic_string_char_ctor_cstr)(basic_string_char*, const char*);
488 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
489 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
491 static basic_string_wchar* (__thiscall *p_basic_string_wchar_ctor_cstr)(basic_string_wchar*, const wchar_t*);
492 static const wchar_t* (__thiscall *p_basic_string_wchar_cstr)(basic_string_wchar*);
493 static void (__thiscall *p_basic_string_wchar_dtor)(basic_string_wchar*);
495 static int invalid_parameter = 0;
496 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
497 const wchar_t *function, const wchar_t *file,
498 unsigned line, uintptr_t arg)
500 ok(expression == NULL, "expression is not NULL\n");
501 ok(function == NULL, "function is not NULL\n");
502 ok(file == NULL, "file is not NULL\n");
503 ok(line == 0, "line = %u\n", line);
504 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
508 static inline const char* debugstr_longlong(ULONGLONG ll)
510 /* return a different string if called up to 4 times in the same ok() */
511 static char string[4][17];
514 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
515 sprintf(string[which & 3], "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll);
517 sprintf(string[which & 3], "%lx", (unsigned long)ll);
518 return string[which++ & 3];
521 /* Emulate a __thiscall */
524 #include "pshpack1.h"
525 struct thiscall_thunk
527 BYTE pop_eax; /* popl %eax (ret addr) */
528 BYTE pop_edx; /* popl %edx (func) */
529 BYTE pop_ecx; /* popl %ecx (this) */
530 BYTE push_eax; /* pushl %eax */
531 WORD jmp_edx; /* jmp *%edx */
535 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
536 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
537 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
538 static void * (WINAPI *call_thiscall_func4)( void *func, void *this, const void *a, const void *b,
540 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
541 const void *c, const void *d );
543 /* to silence compiler errors */
544 static void * (WINAPI *call_thiscall_func2_ptr_dbl)( void *func, void *this, double a );
545 static void * (WINAPI *call_thiscall_func2_ptr_fpos)( void *func, void *this, fpos_int a );
547 struct thiscall_thunk_retptr *thunk_retptr;
549 static void init_thiscall_thunk(void)
551 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
552 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
553 thunk->pop_eax = 0x58; /* popl %eax */
554 thunk->pop_edx = 0x5a; /* popl %edx */
555 thunk->pop_ecx = 0x59; /* popl %ecx */
556 thunk->push_eax = 0x50; /* pushl %eax */
557 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
558 call_thiscall_func1 = (void *)thunk;
559 call_thiscall_func2 = (void *)thunk;
560 call_thiscall_func3 = (void *)thunk;
561 call_thiscall_func4 = (void *)thunk;
562 call_thiscall_func5 = (void *)thunk;
564 call_thiscall_func2_ptr_dbl = (void *)thunk;
565 call_thiscall_func2_ptr_fpos = (void *)thunk;
568 #define call_func1(func,_this) call_thiscall_func1(func,_this)
569 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
570 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
571 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
573 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
574 (const void*)(c), (const void *)(d))
576 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
577 #define call_func2_ptr_fpos(func,_this,a) call_thiscall_func2_ptr_fpos(func,_this,a)
581 #define init_thiscall_thunk()
582 #define call_func1(func,_this) func(_this)
583 #define call_func2(func,_this,a) func(_this,a)
584 #define call_func3(func,_this,a,b) func(_this,a,b)
585 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
586 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
588 #define call_func2_ptr_dbl call_func2
589 #define call_func2_ptr_fpos call_func2
591 #endif /* __i386__ */
593 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
594 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
595 static BOOL init(void)
597 HMODULE msvcr = LoadLibraryA("msvcr90.dll");
598 HMODULE msvcp = LoadLibraryA("msvcp90.dll");
599 if(!msvcr || !msvcp) {
600 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
604 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
605 p_free = (void*)GetProcAddress(msvcr, "free");
606 if(!p_set_invalid_parameter_handler || !p_free) {
607 win_skip("Error setting tests environment\n");
611 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
613 if(sizeof(void*) == 8) { /* 64-bit initialization */
614 SET(p_basic_stringstream_char_ctor,
615 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
616 SET(p_basic_stringstream_char_ctor_str,
617 "??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");
618 SET(p_basic_stringstream_char_str_get,
619 "?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");
620 SET(p_basic_stringstream_char_vbase_dtor,
621 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
623 SET(p_basic_stringstream_wchar_ctor,
624 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
625 SET(p_basic_stringstream_wchar_ctor_str,
626 "??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z");
627 SET(p_basic_stringstream_wchar_str_get,
628 "?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ");
629 SET(p_basic_stringstream_wchar_vbase_dtor,
630 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
632 SET(p_basic_fstream_char_ctor_name,
633 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z");
634 SET(p_basic_fstream_char_vbase_dtor,
635 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ");
637 SET(p_basic_fstream_wchar_ctor_name,
638 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z");
639 SET(p_basic_fstream_wchar_vbase_dtor,
640 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ");
642 SET(p_basic_istream_char_read_uint64,
643 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z");
644 SET(p_basic_istream_char_read_double,
645 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z");
646 SET(p_basic_istream_char_get,
647 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
648 SET(p_basic_istream_char_ipfx,
649 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z");
650 SET(p_basic_istream_char_ignore,
651 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
652 SET(p_basic_istream_char_seekg,
653 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
654 SET(p_basic_istream_char_seekg_fpos,
655 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
656 SET(p_basic_istream_char_peek,
657 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
658 SET(p_basic_istream_char_tellg,
659 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
660 SET(p_basic_istream_char_getline_bstr_delim,
661 "??$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");
663 SET(p_basic_istream_wchar_read_uint64,
664 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z");
665 SET(p_basic_istream_wchar_read_double,
666 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z");
667 SET(p_basic_istream_wchar_get,
668 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
669 SET(p_basic_istream_wchar_ipfx,
670 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z");
671 SET(p_basic_istream_wchar_ignore,
672 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z");
673 SET(p_basic_istream_wchar_seekg,
674 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z");
675 SET(p_basic_istream_wchar_seekg_fpos,
676 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
677 SET(p_basic_istream_wchar_peek,
678 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
679 SET(p_basic_istream_wchar_tellg,
680 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
681 SET(p_basic_istream_wchar_getline_bstr_delim,
682 "??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@_W@Z");
684 SET(p_basic_ostream_char_print_double,
685 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z");
687 SET(p_basic_ostream_wchar_print_double,
688 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z");
690 SET(p_ios_base_rdstate,
691 "?rdstate@ios_base@std@@QEBAHXZ");
692 SET(p_ios_base_setf_mask,
693 "?setf@ios_base@std@@QEAAHHH@Z");
694 SET(p_ios_base_unsetf,
695 "?unsetf@ios_base@std@@QEAAXH@Z");
696 SET(p_ios_base_precision_set,
697 "?precision@ios_base@std@@QEAA_J_J@Z");
699 SET(p_basic_ios_char_imbue,
700 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
702 SET(p_basic_ios_wchar_imbue,
703 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
705 SET(p_locale_ctor_cstr,
706 "??0locale@std@@QEAA@PEBDH@Z");
708 "??1locale@std@@QEAA@XZ");
710 SET(p_basic_string_char_ctor_cstr,
711 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBD@Z");
712 SET(p_basic_string_char_cstr,
713 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
714 SET(p_basic_string_char_dtor,
715 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
717 SET(p_basic_string_wchar_ctor_cstr,
718 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@PEB_W@Z");
719 SET(p_basic_string_wchar_cstr,
720 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
721 SET(p_basic_string_wchar_dtor,
722 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@XZ");
724 SET(p_basic_stringstream_char_ctor,
725 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
726 SET(p_basic_stringstream_char_ctor_str,
727 "??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");
728 SET(p_basic_stringstream_char_str_get,
729 "?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");
730 SET(p_basic_stringstream_char_vbase_dtor,
731 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
733 SET(p_basic_stringstream_wchar_ctor,
734 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
735 SET(p_basic_stringstream_wchar_ctor_str,
736 "??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z");
737 SET(p_basic_stringstream_wchar_str_get,
738 "?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ");
739 SET(p_basic_stringstream_wchar_vbase_dtor,
740 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
742 SET(p_basic_fstream_char_ctor_name,
743 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
744 SET(p_basic_fstream_char_vbase_dtor,
745 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
747 SET(p_basic_fstream_wchar_ctor_name,
748 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
749 SET(p_basic_fstream_wchar_vbase_dtor,
750 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
752 SET(p_basic_istream_char_read_uint64,
753 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z");
754 SET(p_basic_istream_char_read_double,
755 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z");
756 SET(p_basic_istream_char_get,
757 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
758 SET(p_basic_istream_char_ipfx,
759 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z");
760 SET(p_basic_istream_char_ignore,
761 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
762 SET(p_basic_istream_char_seekg,
763 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
764 SET(p_basic_istream_char_seekg_fpos,
765 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
766 SET(p_basic_istream_char_peek,
767 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
768 SET(p_basic_istream_char_tellg,
769 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ");
770 SET(p_basic_istream_char_getline_bstr_delim,
771 "??$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");
773 SET(p_basic_istream_wchar_read_uint64,
774 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z");
775 SET(p_basic_istream_wchar_read_double,
776 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z");
777 SET(p_basic_istream_wchar_get,
778 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
779 SET(p_basic_istream_wchar_ipfx,
780 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z");
781 SET(p_basic_istream_wchar_ignore,
782 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
783 SET(p_basic_istream_wchar_seekg,
784 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
785 SET(p_basic_istream_wchar_seekg_fpos,
786 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
787 SET(p_basic_istream_wchar_peek,
788 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
789 SET(p_basic_istream_wchar_tellg,
790 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ");
791 SET(p_basic_istream_wchar_getline_bstr_delim,
792 "??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@_W@Z");
794 SET(p_basic_ostream_char_print_double,
795 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z");
797 SET(p_basic_ostream_wchar_print_double,
798 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z");
800 SET(p_ios_base_rdstate,
801 "?rdstate@ios_base@std@@QBEHXZ");
802 SET(p_ios_base_setf_mask,
803 "?setf@ios_base@std@@QAEHHH@Z");
804 SET(p_ios_base_unsetf,
805 "?unsetf@ios_base@std@@QAEXH@Z");
806 SET(p_ios_base_precision_set,
807 "?precision@ios_base@std@@QAEHH@Z");
809 SET(p_basic_ios_char_imbue,
810 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
812 SET(p_basic_ios_wchar_imbue,
813 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
815 SET(p_locale_ctor_cstr,
816 "??0locale@std@@QAE@PBDH@Z");
818 "??1locale@std@@QAE@XZ");
820 SET(p_basic_string_char_ctor_cstr,
821 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
822 SET(p_basic_string_char_cstr,
823 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
824 SET(p_basic_string_char_dtor,
825 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
827 SET(p_basic_string_wchar_ctor_cstr,
828 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
829 SET(p_basic_string_wchar_cstr,
830 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
831 SET(p_basic_string_wchar_dtor,
832 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
835 init_thiscall_thunk();
839 /* convert a dll name A->W without depending on the current codepage */
840 static wchar_t *AtoW( wchar_t *nameW, const char *nameA, unsigned int len )
844 for (i = 0; i < len; i++) nameW[i] = nameA[i];
849 static void test_num_get_get_uint64(void)
851 unsigned short testus, nextus;
852 basic_stringstream_wchar wss;
853 basic_stringstream_char ss;
854 basic_string_wchar wstr;
855 basic_string_char str;
862 /* makes tables narrower */
863 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
865 struct _test_num_get {
874 { "0", NULL, FMTFLAG_dec, IOSTATE_eofbit, 0, EOF },
875 { "1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
876 { "+1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
877 { "-1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, -1234567, EOF },
878 { "", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF },
880 /* different bases */
881 /* (with and without zero are both tested, since 0 can signal a prefix check) */
882 { "0x1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* lowercase x */
883 { "0X1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* uppercase X */
884 { "010", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
885 { "010", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
886 { "010", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
887 { "10", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
888 { "10", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
889 { "10", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
890 { "10", NULL, 0, IOSTATE_eofbit, 10, EOF }, /* discover dec */
891 { "010", NULL, 0, IOSTATE_eofbit, 8, EOF }, /* discover oct */
892 { "0xD", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (upper) */
893 { "0xd", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (lower) */
895 /* test grouping - default/"C" has no grouping, named English/German locales do */
896 { "0.", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, '.' },
897 { "0,", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
898 { "0,", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with , */
899 { "0.", "German", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with . */
900 { "0,", "German", FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
901 { ",0", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group at start */
903 { "1,234,567", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* no grouping */
904 { "1,234,567", "English", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with , */
905 { "1.234.567", "German", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with . */
906 { "1,,234", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* empty group */
907 { "1,,234", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group */
908 { "0x1,000,000", "English", FMTFLAG_hex, IOSTATE_eofbit, 16777216, EOF }, /* yeah, hex can group */
909 { "1,23,34", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid size group */
910 { "0,123", "English", FMTFLAG_dec, IOSTATE_eofbit, 123, EOF }, /* 0 solo in group */
912 { "18446744073709551615", NULL, FMTFLAG_dec, IOSTATE_eofbit, ~0, EOF }, /* max value */
913 { "99999999999999999999", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid value */
915 /* test invalid formats */
916 { "0000x10", NULL, FMTFLAG_hex, IOSTATE_goodbit, 0, 'x' },
917 { "x10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
918 { "0xx10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
921 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
923 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
924 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
927 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
928 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
932 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
933 call_func2(p_basic_istream_char_read_uint64, &ss.base.base1, &val);
934 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
935 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
937 if(state==IOSTATE_faileof && tests[i].val==~0) {
938 /* Maximal uint64 test is broken on 9.0.21022.8 */
939 skip("basic_istream_char_read_uint64(MAX_UINT64) is broken\n");
943 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
944 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
945 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
946 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
949 call_func1(p_locale_dtor, &lcl);
951 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
952 call_func1(p_basic_string_char_dtor, &str);
954 /* wchar_t version */
955 AtoW(wide, tests[i].str, strlen(tests[i].str));
956 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
957 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
960 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
961 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
965 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
966 call_func2(p_basic_istream_wchar_read_uint64, &wss.base.base1, &val);
967 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
968 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
970 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
971 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
972 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
973 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
974 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
977 call_func1(p_locale_dtor, &lcl);
979 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
980 call_func1(p_basic_string_wchar_dtor, &wstr);
985 static void test_num_get_get_double(void)
987 unsigned short testus, nextus;
988 basic_stringstream_wchar wss;
989 basic_stringstream_char ss;
990 basic_string_wchar wstr;
991 basic_string_char str;
998 /* makes tables narrower */
999 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1001 struct _test_num_get {
1009 { "0", NULL, IOSTATE_eofbit, 0.0, EOF },
1010 { "10", NULL, IOSTATE_eofbit, 10.0, EOF },
1011 { "+10", NULL, IOSTATE_eofbit, 10.0, EOF },
1012 { "-10", NULL, IOSTATE_eofbit, -10.0, EOF },
1013 { "+010", NULL, IOSTATE_eofbit, 10.0, EOF }, /* leading zero */
1015 /* test grouping - default/"C" has no grouping, named English/German locales do */
1016 { "1,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* with comma */
1017 { "1,000", "English", IOSTATE_eofbit, 1000.0, EOF },
1018 { "1,000", "German", IOSTATE_eofbit, 1.0, EOF },
1020 { "1.000", NULL, IOSTATE_eofbit, 1.0, EOF }, /* with period */
1021 { "1.000", "English", IOSTATE_eofbit, 1.0, EOF },
1022 { "1.000", "German", IOSTATE_eofbit, 1000.0, EOF },
1024 { "1,234.", NULL, IOSTATE_goodbit, 1.0, ',' },
1025 { "1,234.", "English", IOSTATE_eofbit, 1234.0, EOF }, /* trailing decimal */
1026 { "1,234.", "German", IOSTATE_goodbit, 1.234, '.' },
1027 { "1,234.5", "English", IOSTATE_eofbit, 1234.5, EOF }, /* group + decimal */
1028 { "1,234.5", "German", IOSTATE_goodbit, 1.234, '.' },
1030 { "1,234,567,890", NULL, IOSTATE_goodbit, 1.0, ',' }, /* more groups */
1031 { "1,234,567,890", "English", IOSTATE_eofbit, 1234567890.0, EOF },
1032 { "1,234,567,890", "German", IOSTATE_goodbit, 1.234, ',' },
1033 { "1.234.567.890", "German", IOSTATE_eofbit, 1234567890.0, EOF },
1035 /* extra digits and stuff */
1036 { "00000.123456", NULL, IOSTATE_eofbit, 0.123456, EOF },
1037 { "0.1234560000", NULL, IOSTATE_eofbit, 0.123456, EOF },
1038 { "100aaaa", NULL, IOSTATE_goodbit, 100.0, 'a' },
1041 { "10e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* lowercase e */
1042 { "10E10", NULL, IOSTATE_eofbit, 10E10, EOF }, /* uppercase E */
1043 { "10e+10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* sign */
1044 { "10e-10", NULL, IOSTATE_eofbit, 10e-10, EOF },
1045 { "10.e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* trailing decimal before exponent */
1046 { "-10.e-10", NULL, IOSTATE_eofbit, -10e-10, EOF },
1047 { "-12.345e-10", NULL, IOSTATE_eofbit, -12.345e-10, EOF },
1048 { "1,234e10", NULL, IOSTATE_goodbit, 1.0, ',' },
1049 { "1,234e10", "English", IOSTATE_eofbit, 1234.0e10, EOF },
1050 { "1,234e10", "German", IOSTATE_eofbit, 1.234e10, EOF },
1051 { "1.0e999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too big */
1052 { "1.0e-999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too small */
1055 { "1,000,", NULL, IOSTATE_goodbit, 1.0, ',' }, /* trailing group */
1056 { "1,000,", "English", IOSTATE_faileof, 42.0, EOF },
1057 { "1.000.", "German", IOSTATE_faileof, 42.0, EOF },
1059 { "1,,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* empty group */
1060 { "1,,000", "English", IOSTATE_failbit, 42.0, EOF },
1061 { "1..000", "German", IOSTATE_failbit, 42.0, EOF },
1063 { "1.0,00", "English", IOSTATE_goodbit, 1.0, ',' },
1064 { "1.0,00", "German", IOSTATE_faileof, 42.0, EOF },
1066 { "1.0ee10", NULL, IOSTATE_failbit, 42.0, EOF }, /* dup exp */
1067 { "1.0e1.0", NULL, IOSTATE_goodbit, 10.0, '.' }, /* decimal in exponent */
1068 { "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
1071 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1073 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1074 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1077 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1078 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1082 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
1083 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1084 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1086 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1087 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1088 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1091 call_func1(p_locale_dtor, &lcl);
1093 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1094 call_func1(p_basic_string_char_dtor, &str);
1096 /* wchar_t version */
1097 AtoW(wide, tests[i].str, strlen(tests[i].str));
1098 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1099 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1102 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1103 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1107 call_func2(p_basic_istream_wchar_read_double, &wss.base.base1, &val);
1108 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1109 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1111 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1112 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1113 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1114 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1117 call_func1(p_locale_dtor, &lcl);
1119 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1120 call_func1(p_basic_string_wchar_dtor, &wstr);
1125 static void test_num_put_put_double(void)
1127 basic_stringstream_wchar wss;
1128 basic_stringstream_char ss;
1129 basic_string_wchar pwstr;
1130 basic_string_char pstr;
1132 const wchar_t *wstr;
1137 struct _test_num_get {
1140 streamsize prec; /* set to -1 for default */
1141 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
1144 { 0.0, NULL, -1, 0, "0" },
1147 { 0.123, NULL, -1, 0, "0.123" },
1148 { 0.123, NULL, 6, 0, "0.123" },
1149 { 0.123, NULL, 0, 0, "0.123" },
1152 { 0.123, NULL, -1, FMTFLAG_fixed, "0.123000" },
1153 { 0.123, NULL, 6, FMTFLAG_fixed, "0.123000" },
1154 { 0.123, NULL, 0, FMTFLAG_fixed, "0" },
1156 /* scientific format */
1157 { 123456.789, NULL, -1, FMTFLAG_scientific, "1.234568e+005" },
1158 { 123456.789, NULL, 0, FMTFLAG_scientific, "1.234568e+005" },
1159 { 123456.789, NULL, 9, FMTFLAG_scientific, "1.234567890e+005" },
1160 { 123456.789, "German", 9, FMTFLAG_scientific, "1,234567890e+005" },
1162 /* different locales */
1163 { 0.123, "C", -1, 0, "0.123" },
1164 { 0.123, "English", -1, 0, "0.123" },
1165 { 0.123, "German", -1, 0, "0,123" },
1167 { 123456.789, "C", -1, 0, "123457" },
1168 { 123456.789, "English", -1, 0, "123,457" },
1169 { 123456.789, "German", -1, 0, "123.457" },
1171 /* signs and exponents */
1172 { 1.0e-9, NULL, -1, 0, "1e-009" },
1173 { 1.0e-9, NULL, 9, 0, "1e-009" },
1174 { -1.0e9, NULL, -1, 0, "-1e+009" },
1175 { -1.0e9, NULL, 9, 0, "-1e+009" },
1177 { 1.0e-9, NULL, 0, FMTFLAG_fixed, "0" },
1178 { 1.0e-9, NULL, 6, FMTFLAG_fixed, "0.000000" },
1179 { 1.0e-9, NULL, 9, FMTFLAG_fixed, "0.000000001" },
1180 { -1.0e9, NULL, 0, FMTFLAG_fixed, "-1000000000" },
1181 { -1.0e9, NULL, 6, FMTFLAG_fixed, "-1000000000.000000" },
1183 { -1.23456789e9, NULL, 0, 0, "-1.23457e+009" },
1184 { -1.23456789e9, NULL, 0, FMTFLAG_fixed, "-1234567890" },
1185 { -1.23456789e9, NULL, 6, FMTFLAG_fixed, "-1234567890.000000" },
1186 { -1.23456789e-9, NULL, 6, FMTFLAG_fixed, "-0.000000" },
1187 { -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
1190 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1192 call_func2(p_basic_stringstream_char_ctor, &ss, TRUE);
1195 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1196 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1199 /* set format and precision only if specified, so we can try defaults */
1201 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1202 if(tests[i].prec != -1)
1203 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
1204 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, tests[i].val);
1206 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
1207 str = call_func1(p_basic_string_char_cstr, &pstr);
1209 ok(!strcmp(tests[i].str, str), "wrong output, expected = %s found = %s\n", tests[i].str, str);
1210 call_func1(p_basic_string_char_dtor, &pstr);
1213 call_func1(p_locale_dtor, &lcl);
1215 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1217 /* wchar_t version */
1218 call_func2(p_basic_stringstream_wchar_ctor, &wss, TRUE);
1221 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1222 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1225 /* set format and precision only if specified, so we can try defaults */
1227 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1228 if(tests[i].prec != -1)
1229 call_func2(p_ios_base_precision_set, &wss.basic_ios.base, tests[i].prec);
1230 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, tests[i].val);
1232 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
1233 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
1235 AtoW(wide, tests[i].str, strlen(tests[i].str));
1236 ok(!lstrcmpW(wide, wstr), "wrong output, expected = %s found = %s\n", tests[i].str, wine_dbgstr_w(wstr));
1237 call_func1(p_basic_string_wchar_dtor, &pwstr);
1240 call_func1(p_locale_dtor, &lcl);
1242 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1247 static void test_istream_ipfx(void)
1249 unsigned short testus, nextus;
1250 basic_stringstream_wchar wss;
1251 basic_stringstream_char ss;
1252 basic_string_wchar wstr;
1253 basic_string_char str;
1258 /* makes tables narrower */
1259 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1261 struct _test_istream_ipfx {
1269 /* string unset noskip return state next char */
1270 { "", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* empty string */
1271 { " ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* just ws */
1272 { "\t \n \f ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* different ws */
1273 { "simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1274 { " simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1275 { " simple", TRUE, FALSE, TRUE, IOSTATE_goodbit, ' ' }, /* unset skipws */
1276 { " simple", FALSE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* ipfx(true) */
1277 { " simple", TRUE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* both */
1278 { "\n\t ws", FALSE, FALSE, TRUE, IOSTATE_goodbit, 'w' },
1279 { "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
1282 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1284 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1285 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1287 /* set format and precision only if specified, so we can try defaults */
1288 if(tests[i].unset_skipws)
1289 call_func2(p_ios_base_unsetf, &ss.basic_ios.base, TRUE);
1291 ret = (int)call_func2(p_basic_istream_char_ipfx, &ss.base.base1, tests[i].noskip);
1292 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1293 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1295 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1296 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1297 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1299 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1300 call_func1(p_basic_string_char_dtor, &str);
1302 /* wchar_t version */
1303 AtoW(wide, tests[i].str, strlen(tests[i].str));
1304 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1305 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1307 /* set format and precision only if specified, so we can try defaults */
1308 if(tests[i].unset_skipws)
1309 call_func2(p_ios_base_unsetf, &wss.basic_ios.base, TRUE);
1311 ret = (int)call_func2(p_basic_istream_wchar_ipfx, &wss.base.base1, tests[i].noskip);
1312 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1313 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1315 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1316 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1317 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1318 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1320 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1321 call_func1(p_basic_string_wchar_dtor, &wstr);
1326 static void test_istream_ignore(void)
1328 unsigned short testus, nextus;
1329 basic_stringstream_wchar wss;
1330 basic_stringstream_char ss;
1331 basic_string_wchar wstr;
1332 basic_string_char str;
1337 struct _test_istream_ignore {
1344 /* string count delim state next */
1345 { "", 0, '\n', IOSTATE_goodbit, EOF }, /* empty string */
1347 /* different counts */
1348 { "ABCDEF", 2, '\n', IOSTATE_goodbit, 'C' }, /* easy case */
1349 { "ABCDEF", 42, '\n', IOSTATE_eofbit, EOF }, /* ignore too much */
1350 { "ABCDEF", -2, '\n', IOSTATE_goodbit, 'A' }, /* negative count */
1351 { "ABCDEF", 6, '\n', IOSTATE_goodbit, EOF }, /* is eof not set at end */
1352 { "ABCDEF", 7, '\n', IOSTATE_eofbit, EOF }, /* eof is set just after end */
1354 /* different delimiters */
1355 { "ABCDEF", 42, '\0', IOSTATE_eofbit, EOF }, /* null as delim */
1356 { "ABC DEF GHI", 0, ' ', IOSTATE_goodbit, 'A' },
1357 { "ABC DEF GHI", 42, ' ', IOSTATE_goodbit, 'D' },
1358 { "ABC DEF\tGHI", 42, '\t', IOSTATE_goodbit, 'G' },
1359 { "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
1362 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1364 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1365 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1367 call_func3(p_basic_istream_char_ignore, &ss.base.base1, tests[i].count, tests[i].delim);
1368 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1369 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1371 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1372 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1374 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1375 call_func1(p_basic_string_char_dtor, &str);
1377 /* wchar_t version */
1378 AtoW(wide, tests[i].str, strlen(tests[i].str));
1379 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1380 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1382 call_func3(p_basic_istream_wchar_ignore, &wss.base.base1, tests[i].count, tests[i].delim);
1383 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1384 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1386 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1387 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1388 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1390 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1391 call_func1(p_basic_string_wchar_dtor, &wstr);
1396 static void test_istream_seekg(void)
1398 unsigned short testus, nextus;
1399 basic_stringstream_wchar wss;
1400 basic_stringstream_char ss;
1401 basic_string_wchar wstr;
1402 basic_string_char str;
1407 struct _test_istream_seekg {
1414 { "ABCDEFGHIJ", 0, SEEKDIR_beg, IOSTATE_goodbit, 'A' },
1415 { "ABCDEFGHIJ", 1, SEEKDIR_beg, IOSTATE_goodbit, 'B' },
1416 { "ABCDEFGHIJ", 5, SEEKDIR_cur, IOSTATE_goodbit, 'F' },
1417 { "ABCDEFGHIJ", -3, SEEKDIR_end, IOSTATE_goodbit, 'H' },
1420 { "ABCDEFGHIJ", -1, SEEKDIR_beg, IOSTATE_failbit, EOF },
1421 { "ABCDEFGHIJ", 42, SEEKDIR_cur, IOSTATE_failbit, EOF },
1422 { "ABCDEFGHIJ", 42, SEEKDIR_end, IOSTATE_failbit, EOF },
1423 { "", 0, SEEKDIR_beg, IOSTATE_failbit, EOF },
1426 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1428 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1429 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1431 call_func3(p_basic_istream_char_seekg, &ss.base.base1, tests[i].off, tests[i].dir);
1432 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1433 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1435 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1436 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1438 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1439 call_func1(p_basic_string_char_dtor, &str);
1441 /* wchar_t version */
1442 AtoW(wide, tests[i].str, strlen(tests[i].str));
1443 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1444 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1446 call_func3(p_basic_istream_wchar_seekg, &wss.base.base1, tests[i].off, tests[i].dir);
1447 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1448 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1450 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1451 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1452 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1454 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1455 call_func1(p_basic_string_wchar_dtor, &wstr);
1460 static void test_istream_seekg_fpos(void)
1462 unsigned short testus, nextus;
1463 basic_stringstream_wchar wss;
1464 basic_stringstream_char ss;
1465 basic_string_wchar wstr;
1466 basic_string_char str;
1472 struct _test_istream_seekg_fpos {
1478 { "ABCDEFGHIJ", 0, IOSTATE_goodbit, 'A' },
1479 { "ABCDEFGHIJ", 9, IOSTATE_goodbit, 'J' },
1480 { "ABCDEFGHIJ", 10, IOSTATE_goodbit, EOF }, /* beyond end, but still good */
1481 { "ABCDEFGHIJ", -1, IOSTATE_failbit, EOF },
1482 { "", 0, IOSTATE_failbit, EOF },
1485 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1487 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1488 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1490 pos.off = tests[i].off;
1491 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1493 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, pos);
1494 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1495 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1497 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1498 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1500 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1501 call_func1(p_basic_string_char_dtor, &str);
1503 /* wchar_t version */
1504 AtoW(wide, tests[i].str, strlen(tests[i].str));
1505 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1506 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1508 pos.off = tests[i].off;
1509 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1511 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, pos);
1512 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1513 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1515 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1516 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1517 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1519 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1520 call_func1(p_basic_string_wchar_dtor, &wstr);
1525 static void test_istream_peek(void)
1527 unsigned short testus, nextus, peekus;
1528 basic_stringstream_wchar wss;
1529 basic_stringstream_char ss;
1530 basic_string_wchar wstr;
1531 basic_string_char str;
1536 struct _test_istream_peek {
1542 { "", EOF, EOF, IOSTATE_eofbit },
1543 { "ABCDEF", 'A', 'A', IOSTATE_goodbit },
1546 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1548 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1549 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1551 peek = (int)call_func1(p_basic_istream_char_peek, &ss.base.base1);
1552 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1553 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1555 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1556 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1557 ok(peek == next, "wrong peek, expected %c (%i) found = %c (%i)\n", peek, peek, next, next);
1559 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1560 call_func1(p_basic_string_char_dtor, &str);
1562 /* wchar_t version */
1563 AtoW(wide, tests[i].str, strlen(tests[i].str));
1564 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1565 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1567 peekus = (unsigned short)(int)call_func1(p_basic_istream_wchar_peek, &wss.base.base1);
1568 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1569 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1571 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1572 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1573 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1574 ok(peekus == nextus, "wrong peek, expected %c (%i) found = %c (%i)\n", peekus, peekus, nextus, nextus);
1576 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1577 call_func1(p_basic_string_wchar_dtor, &wstr);
1582 static void test_istream_tellg(void)
1584 basic_stringstream_wchar wss;
1585 basic_stringstream_char ss;
1586 basic_fstream_wchar wfs;
1587 basic_fstream_char fs;
1588 basic_string_wchar wstr;
1589 basic_string_char str;
1590 fpos_int spos, tpos, *rpos;
1595 const char *testfile = "file.txt";
1597 struct _test_istream_tellg_fpos {
1600 streamoff telloff_ss; /* offset for stringstream */
1601 streamoff telloff_fs; /* offset for fstream */
1605 { "", -1, -1, 0, 0 }, /* tellg on defaults */
1606 { "", 0, -1, 0, 0 }, /* tellg after seek 0 */
1607 { "", 42, -1, 0, 42 }, /* tellg after seek beyond end */
1608 { "", -6, -1, -1, 0 }, /* tellg after seek beyond beg */
1610 /* non-empty strings */
1611 { "ABCDEFGHIJ", -1, 0, 0, 0 },
1612 { "ABCDEFGHIJ", 3, 3, 0, 3 },
1613 { "ABCDEFGHIJ", 42, -1, 0, 42 },
1614 { "ABCDEFGHIJ", -6, -1, -1, 0 }
1617 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1618 /* stringstream<char> version */
1619 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1620 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1622 spos.off = tests[i].seekoff;
1626 tpos.off = 0xdeadbeef;
1627 tpos.pos = 0xdeadbeef;
1628 tpos.state = 0xdeadbeef;
1630 if (tests[i].seekoff != -1) /* to test without seek */
1631 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, spos);
1632 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &ss.base.base1, &tpos);
1634 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1635 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1636 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1637 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1638 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1639 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1641 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1642 call_func1(p_basic_string_char_dtor, &str);
1644 /* stringstream<wchar_t> version */
1645 AtoW(wide, tests[i].str, strlen(tests[i].str));
1646 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1647 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1649 spos.off = tests[i].seekoff;
1650 spos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1653 tpos.off = 0xdeadbeef;
1654 tpos.pos = 0xdeadbeef;
1655 tpos.state = 0xdeadbeef;
1657 if (tests[i].seekoff != -1) /* to test without seek */
1658 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, spos);
1659 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wss.base.base1, &tpos);
1661 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1662 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1663 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1664 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1665 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1666 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1668 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1669 call_func1(p_basic_string_wchar_dtor, &wstr);
1672 file = fopen(testfile, "wt");
1673 fprintf(file, tests[i].str);
1676 /* fstream<char> version */
1677 call_func5(p_basic_fstream_char_ctor_name, &fs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1679 spos.off = tests[i].seekoff;
1683 tpos.off = 0xdeadbeef;
1684 tpos.pos = 0xdeadbeef;
1685 tpos.state = 0xdeadbeef;
1687 if (tests[i].seekoff != -1) /* to test without seek */
1688 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &fs.base.base1, spos);
1689 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &fs.base.base1, &tpos);
1691 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1692 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1693 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1694 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1695 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1697 call_func1(p_basic_fstream_char_vbase_dtor, &fs);
1699 /* fstream<wchar_t> version */
1700 call_func5(p_basic_fstream_wchar_ctor_name, &wfs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1702 spos.off = tests[i].seekoff;
1706 tpos.off = 0xdeadbeef;
1707 tpos.pos = 0xdeadbeef;
1708 tpos.state = 0xdeadbeef;
1710 if (tests[i].seekoff != -1) /* to test without seek */
1711 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wfs.base.base1, spos);
1712 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wfs.base.base1, &tpos);
1714 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1715 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1716 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1717 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1718 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1720 call_func1(p_basic_fstream_wchar_vbase_dtor, &wfs);
1727 static void test_istream_getline(void)
1729 basic_stringstream_wchar wss;
1730 basic_stringstream_char ss;
1731 basic_string_wchar wstr;
1732 basic_string_char str;
1737 const wchar_t *wcstr;
1739 /* makes tables narrower */
1740 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1742 struct _test_istream_getline {
1747 const char *nextline;
1749 IOSB_iostate nextstate;
1751 { "", "", '\n', IOSTATE_faileof, "", '\n', IOSTATE_faileof },
1753 { "this\n", "this", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1754 { "this\nis\nsome\ntext\n", "this", '\n', IOSTATE_goodbit, "is", '\n', IOSTATE_goodbit },
1756 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is", ' ', IOSTATE_goodbit },
1757 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is some text", '\n', IOSTATE_goodbit },
1759 { "this is some text\n", "this is some text", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1760 { "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit, "this is some text\n", '\n', IOSTATE_faileof },
1763 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1765 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1766 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1768 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].delim);
1769 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1770 cstr = call_func1(p_basic_string_char_cstr, &str);
1772 ok(!strcmp(tests[i].line, cstr), "wrong line, expected = %s found = %s\n", tests[i].line, cstr);
1773 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1776 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].nextdelim);
1777 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1778 cstr = call_func1(p_basic_string_char_cstr, &str);
1780 ok(!strcmp(tests[i].nextline, cstr), "wrong next line, expected = %s found = %s\n", tests[i].nextline, cstr);
1781 ok(tests[i].nextstate == state, "wrong next state, expected = %x found = %x\n", tests[i].nextstate, state);
1783 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1784 call_func1(p_basic_string_char_dtor, &str);
1786 /* wchar_t version */
1787 AtoW(wide, tests[i].str, strlen(tests[i].str));
1788 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1789 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1791 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].delim);
1792 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1793 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
1795 AtoW(wide, tests[i].line, strlen(tests[i].line));
1796 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].line, wine_dbgstr_w(wcstr));
1797 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1800 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].nextdelim);
1801 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1802 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
1804 AtoW(wide, tests[i].nextline, strlen(tests[i].nextline));
1805 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].nextline, wine_dbgstr_w(wcstr));
1806 ok(tests[i].nextstate == state, "wrong state, expected = %x found = %x\n", tests[i].nextstate, state);
1808 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1809 call_func1(p_basic_string_wchar_dtor, &wstr);
1819 test_num_get_get_uint64();
1820 test_num_get_get_double();
1821 test_num_put_put_double();
1822 test_istream_ipfx();
1823 test_istream_ignore();
1824 test_istream_seekg();
1825 test_istream_seekg_fpos();
1826 test_istream_peek();
1827 test_istream_tellg();
1828 test_istream_getline();
1830 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");