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 static void init_thiscall_thunk(void)
549 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
550 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
551 thunk->pop_eax = 0x58; /* popl %eax */
552 thunk->pop_edx = 0x5a; /* popl %edx */
553 thunk->pop_ecx = 0x59; /* popl %ecx */
554 thunk->push_eax = 0x50; /* pushl %eax */
555 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
556 call_thiscall_func1 = (void *)thunk;
557 call_thiscall_func2 = (void *)thunk;
558 call_thiscall_func3 = (void *)thunk;
559 call_thiscall_func4 = (void *)thunk;
560 call_thiscall_func5 = (void *)thunk;
562 call_thiscall_func2_ptr_dbl = (void *)thunk;
563 call_thiscall_func2_ptr_fpos = (void *)thunk;
566 #define call_func1(func,_this) call_thiscall_func1(func,_this)
567 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
568 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
569 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
571 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
572 (const void*)(c), (const void *)(d))
574 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
575 #define call_func2_ptr_fpos(func,_this,a) call_thiscall_func2_ptr_fpos(func,_this,a)
579 #define init_thiscall_thunk()
580 #define call_func1(func,_this) func(_this)
581 #define call_func2(func,_this,a) func(_this,a)
582 #define call_func3(func,_this,a,b) func(_this,a,b)
583 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
584 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
586 #define call_func2_ptr_dbl call_func2
587 #define call_func2_ptr_fpos call_func2
589 #endif /* __i386__ */
591 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
592 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
593 static BOOL init(void)
595 HMODULE msvcr = LoadLibraryA("msvcr90.dll");
596 HMODULE msvcp = LoadLibraryA("msvcp90.dll");
597 if(!msvcr || !msvcp) {
598 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
602 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
603 p_free = (void*)GetProcAddress(msvcr, "free");
604 if(!p_set_invalid_parameter_handler || !p_free) {
605 win_skip("Error setting tests environment\n");
609 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
611 if(sizeof(void*) == 8) { /* 64-bit initialization */
612 SET(p_basic_stringstream_char_ctor,
613 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
614 SET(p_basic_stringstream_char_ctor_str,
615 "??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");
616 SET(p_basic_stringstream_char_str_get,
617 "?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");
618 SET(p_basic_stringstream_char_vbase_dtor,
619 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
621 SET(p_basic_stringstream_wchar_ctor,
622 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
623 SET(p_basic_stringstream_wchar_ctor_str,
624 "??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");
625 SET(p_basic_stringstream_wchar_str_get,
626 "?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");
627 SET(p_basic_stringstream_wchar_vbase_dtor,
628 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
630 SET(p_basic_fstream_char_ctor_name,
631 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z");
632 SET(p_basic_fstream_char_vbase_dtor,
633 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ");
635 SET(p_basic_fstream_wchar_ctor_name,
636 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z");
637 SET(p_basic_fstream_wchar_vbase_dtor,
638 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ");
640 SET(p_basic_istream_char_read_uint64,
641 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z");
642 SET(p_basic_istream_char_read_double,
643 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z");
644 SET(p_basic_istream_char_get,
645 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
646 SET(p_basic_istream_char_ipfx,
647 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z");
648 SET(p_basic_istream_char_ignore,
649 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
650 SET(p_basic_istream_char_seekg,
651 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
652 SET(p_basic_istream_char_seekg_fpos,
653 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
654 SET(p_basic_istream_char_peek,
655 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
656 SET(p_basic_istream_char_tellg,
657 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
658 SET(p_basic_istream_char_getline_bstr_delim,
659 "??$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");
661 SET(p_basic_istream_wchar_read_uint64,
662 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z");
663 SET(p_basic_istream_wchar_read_double,
664 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z");
665 SET(p_basic_istream_wchar_get,
666 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
667 SET(p_basic_istream_wchar_ipfx,
668 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z");
669 SET(p_basic_istream_wchar_ignore,
670 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z");
671 SET(p_basic_istream_wchar_seekg,
672 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z");
673 SET(p_basic_istream_wchar_seekg_fpos,
674 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
675 SET(p_basic_istream_wchar_peek,
676 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
677 SET(p_basic_istream_wchar_tellg,
678 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
679 SET(p_basic_istream_wchar_getline_bstr_delim,
680 "??$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");
682 SET(p_basic_ostream_char_print_double,
683 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z");
685 SET(p_basic_ostream_wchar_print_double,
686 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z");
688 SET(p_ios_base_rdstate,
689 "?rdstate@ios_base@std@@QEBAHXZ");
690 SET(p_ios_base_setf_mask,
691 "?setf@ios_base@std@@QEAAHHH@Z");
692 SET(p_ios_base_unsetf,
693 "?unsetf@ios_base@std@@QEAAXH@Z");
694 SET(p_ios_base_precision_set,
695 "?precision@ios_base@std@@QEAA_J_J@Z");
697 SET(p_basic_ios_char_imbue,
698 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
700 SET(p_basic_ios_wchar_imbue,
701 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
703 SET(p_locale_ctor_cstr,
704 "??0locale@std@@QEAA@PEBDH@Z");
706 "??1locale@std@@QEAA@XZ");
708 SET(p_basic_string_char_ctor_cstr,
709 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBD@Z");
710 SET(p_basic_string_char_cstr,
711 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
712 SET(p_basic_string_char_dtor,
713 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
715 SET(p_basic_string_wchar_ctor_cstr,
716 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@PEB_W@Z");
717 SET(p_basic_string_wchar_cstr,
718 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
719 SET(p_basic_string_wchar_dtor,
720 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@XZ");
722 SET(p_basic_stringstream_char_ctor,
723 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
724 SET(p_basic_stringstream_char_ctor_str,
725 "??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");
726 SET(p_basic_stringstream_char_str_get,
727 "?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");
728 SET(p_basic_stringstream_char_vbase_dtor,
729 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
731 SET(p_basic_stringstream_wchar_ctor,
732 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
733 SET(p_basic_stringstream_wchar_ctor_str,
734 "??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");
735 SET(p_basic_stringstream_wchar_str_get,
736 "?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");
737 SET(p_basic_stringstream_wchar_vbase_dtor,
738 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
740 SET(p_basic_fstream_char_ctor_name,
741 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
742 SET(p_basic_fstream_char_vbase_dtor,
743 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
745 SET(p_basic_fstream_wchar_ctor_name,
746 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
747 SET(p_basic_fstream_wchar_vbase_dtor,
748 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
750 SET(p_basic_istream_char_read_uint64,
751 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z");
752 SET(p_basic_istream_char_read_double,
753 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z");
754 SET(p_basic_istream_char_get,
755 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
756 SET(p_basic_istream_char_ipfx,
757 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z");
758 SET(p_basic_istream_char_ignore,
759 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
760 SET(p_basic_istream_char_seekg,
761 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
762 SET(p_basic_istream_char_seekg_fpos,
763 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
764 SET(p_basic_istream_char_peek,
765 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
766 SET(p_basic_istream_char_tellg,
767 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ");
768 SET(p_basic_istream_char_getline_bstr_delim,
769 "??$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");
771 SET(p_basic_istream_wchar_read_uint64,
772 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z");
773 SET(p_basic_istream_wchar_read_double,
774 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z");
775 SET(p_basic_istream_wchar_get,
776 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
777 SET(p_basic_istream_wchar_ipfx,
778 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z");
779 SET(p_basic_istream_wchar_ignore,
780 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
781 SET(p_basic_istream_wchar_seekg,
782 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
783 SET(p_basic_istream_wchar_seekg_fpos,
784 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
785 SET(p_basic_istream_wchar_peek,
786 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
787 SET(p_basic_istream_wchar_tellg,
788 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ");
789 SET(p_basic_istream_wchar_getline_bstr_delim,
790 "??$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");
792 SET(p_basic_ostream_char_print_double,
793 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z");
795 SET(p_basic_ostream_wchar_print_double,
796 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z");
798 SET(p_ios_base_rdstate,
799 "?rdstate@ios_base@std@@QBEHXZ");
800 SET(p_ios_base_setf_mask,
801 "?setf@ios_base@std@@QAEHHH@Z");
802 SET(p_ios_base_unsetf,
803 "?unsetf@ios_base@std@@QAEXH@Z");
804 SET(p_ios_base_precision_set,
805 "?precision@ios_base@std@@QAEHH@Z");
807 SET(p_basic_ios_char_imbue,
808 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
810 SET(p_basic_ios_wchar_imbue,
811 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
813 SET(p_locale_ctor_cstr,
814 "??0locale@std@@QAE@PBDH@Z");
816 "??1locale@std@@QAE@XZ");
818 SET(p_basic_string_char_ctor_cstr,
819 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
820 SET(p_basic_string_char_cstr,
821 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
822 SET(p_basic_string_char_dtor,
823 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
825 SET(p_basic_string_wchar_ctor_cstr,
826 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
827 SET(p_basic_string_wchar_cstr,
828 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
829 SET(p_basic_string_wchar_dtor,
830 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
833 init_thiscall_thunk();
837 /* convert a dll name A->W without depending on the current codepage */
838 static wchar_t *AtoW( wchar_t *nameW, const char *nameA, unsigned int len )
842 for (i = 0; i < len; i++) nameW[i] = nameA[i];
847 static void test_num_get_get_uint64(void)
849 unsigned short testus, nextus;
850 basic_stringstream_wchar wss;
851 basic_stringstream_char ss;
852 basic_string_wchar wstr;
853 basic_string_char str;
860 /* makes tables narrower */
861 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
863 struct _test_num_get {
872 { "0", NULL, FMTFLAG_dec, IOSTATE_eofbit, 0, EOF },
873 { "1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
874 { "+1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
875 { "-1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, -1234567, EOF },
876 { "", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF },
878 /* different bases */
879 /* (with and without zero are both tested, since 0 can signal a prefix check) */
880 { "0x1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* lowercase x */
881 { "0X1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* uppercase X */
882 { "010", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
883 { "010", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
884 { "010", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
885 { "10", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
886 { "10", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
887 { "10", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
888 { "10", NULL, 0, IOSTATE_eofbit, 10, EOF }, /* discover dec */
889 { "010", NULL, 0, IOSTATE_eofbit, 8, EOF }, /* discover oct */
890 { "0xD", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (upper) */
891 { "0xd", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (lower) */
893 /* test grouping - default/"C" has no grouping, named English/German locales do */
894 { "0.", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, '.' },
895 { "0,", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
896 { "0,", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with , */
897 { "0.", "German", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with . */
898 { "0,", "German", FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
899 { ",0", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group at start */
901 { "1,234,567", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* no grouping */
902 { "1,234,567", "English", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with , */
903 { "1.234.567", "German", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with . */
904 { "1,,234", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* empty group */
905 { "1,,234", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group */
906 { "0x1,000,000", "English", FMTFLAG_hex, IOSTATE_eofbit, 16777216, EOF }, /* yeah, hex can group */
907 { "1,23,34", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid size group */
908 { "0,123", "English", FMTFLAG_dec, IOSTATE_eofbit, 123, EOF }, /* 0 solo in group */
910 { "18446744073709551615", NULL, FMTFLAG_dec, IOSTATE_eofbit, ~0, EOF }, /* max value */
911 { "99999999999999999999", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid value */
913 /* test invalid formats */
914 { "0000x10", NULL, FMTFLAG_hex, IOSTATE_goodbit, 0, 'x' },
915 { "x10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
916 { "0xx10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
919 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
921 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
922 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
925 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
926 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
930 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
931 call_func2(p_basic_istream_char_read_uint64, &ss.base.base1, &val);
932 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
933 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
935 if(state==IOSTATE_faileof && tests[i].val==~0) {
936 /* Maximal uint64 test is broken on 9.0.21022.8 */
937 skip("basic_istream_char_read_uint64(MAX_UINT64) is broken\n");
941 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
942 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
943 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
944 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
947 call_func1(p_locale_dtor, &lcl);
949 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
950 call_func1(p_basic_string_char_dtor, &str);
952 /* wchar_t version */
953 AtoW(wide, tests[i].str, strlen(tests[i].str));
954 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
955 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
958 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
959 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
963 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
964 call_func2(p_basic_istream_wchar_read_uint64, &wss.base.base1, &val);
965 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
966 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
968 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
969 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
970 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
971 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
972 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
975 call_func1(p_locale_dtor, &lcl);
977 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
978 call_func1(p_basic_string_wchar_dtor, &wstr);
983 static void test_num_get_get_double(void)
985 unsigned short testus, nextus;
986 basic_stringstream_wchar wss;
987 basic_stringstream_char ss;
988 basic_string_wchar wstr;
989 basic_string_char str;
996 /* makes tables narrower */
997 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
999 struct _test_num_get {
1007 { "0", NULL, IOSTATE_eofbit, 0.0, EOF },
1008 { "10", NULL, IOSTATE_eofbit, 10.0, EOF },
1009 { "+10", NULL, IOSTATE_eofbit, 10.0, EOF },
1010 { "-10", NULL, IOSTATE_eofbit, -10.0, EOF },
1011 { "+010", NULL, IOSTATE_eofbit, 10.0, EOF }, /* leading zero */
1013 /* test grouping - default/"C" has no grouping, named English/German locales do */
1014 { "1,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* with comma */
1015 { "1,000", "English", IOSTATE_eofbit, 1000.0, EOF },
1016 { "1,000", "German", IOSTATE_eofbit, 1.0, EOF },
1018 { "1.000", NULL, IOSTATE_eofbit, 1.0, EOF }, /* with period */
1019 { "1.000", "English", IOSTATE_eofbit, 1.0, EOF },
1020 { "1.000", "German", IOSTATE_eofbit, 1000.0, EOF },
1022 { "1,234.", NULL, IOSTATE_goodbit, 1.0, ',' },
1023 { "1,234.", "English", IOSTATE_eofbit, 1234.0, EOF }, /* trailing decimal */
1024 { "1,234.", "German", IOSTATE_goodbit, 1.234, '.' },
1025 { "1,234.5", "English", IOSTATE_eofbit, 1234.5, EOF }, /* group + decimal */
1026 { "1,234.5", "German", IOSTATE_goodbit, 1.234, '.' },
1028 { "1,234,567,890", NULL, IOSTATE_goodbit, 1.0, ',' }, /* more groups */
1029 { "1,234,567,890", "English", IOSTATE_eofbit, 1234567890.0, EOF },
1030 { "1,234,567,890", "German", IOSTATE_goodbit, 1.234, ',' },
1031 { "1.234.567.890", "German", IOSTATE_eofbit, 1234567890.0, EOF },
1033 /* extra digits and stuff */
1034 { "00000.123456", NULL, IOSTATE_eofbit, 0.123456, EOF },
1035 { "0.1234560000", NULL, IOSTATE_eofbit, 0.123456, EOF },
1036 { "100aaaa", NULL, IOSTATE_goodbit, 100.0, 'a' },
1039 { "10e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* lowercase e */
1040 { "10E10", NULL, IOSTATE_eofbit, 10E10, EOF }, /* uppercase E */
1041 { "10e+10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* sign */
1042 { "10e-10", NULL, IOSTATE_eofbit, 10e-10, EOF },
1043 { "10.e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* trailing decimal before exponent */
1044 { "-10.e-10", NULL, IOSTATE_eofbit, -10e-10, EOF },
1045 { "-12.345e-10", NULL, IOSTATE_eofbit, -12.345e-10, EOF },
1046 { "1,234e10", NULL, IOSTATE_goodbit, 1.0, ',' },
1047 { "1,234e10", "English", IOSTATE_eofbit, 1234.0e10, EOF },
1048 { "1,234e10", "German", IOSTATE_eofbit, 1.234e10, EOF },
1049 { "1.0e999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too big */
1050 { "1.0e-999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too small */
1053 { "1,000,", NULL, IOSTATE_goodbit, 1.0, ',' }, /* trailing group */
1054 { "1,000,", "English", IOSTATE_faileof, 42.0, EOF },
1055 { "1.000.", "German", IOSTATE_faileof, 42.0, EOF },
1057 { "1,,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* empty group */
1058 { "1,,000", "English", IOSTATE_failbit, 42.0, EOF },
1059 { "1..000", "German", IOSTATE_failbit, 42.0, EOF },
1061 { "1.0,00", "English", IOSTATE_goodbit, 1.0, ',' },
1062 { "1.0,00", "German", IOSTATE_faileof, 42.0, EOF },
1064 { "1.0ee10", NULL, IOSTATE_failbit, 42.0, EOF }, /* dup exp */
1065 { "1.0e1.0", NULL, IOSTATE_goodbit, 10.0, '.' }, /* decimal in exponent */
1066 { "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
1069 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1071 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1072 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1075 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1076 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1080 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
1081 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1082 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1084 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1085 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1086 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1089 call_func1(p_locale_dtor, &lcl);
1091 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1092 call_func1(p_basic_string_char_dtor, &str);
1094 /* wchar_t version */
1095 AtoW(wide, tests[i].str, strlen(tests[i].str));
1096 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1097 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1100 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1101 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1105 call_func2(p_basic_istream_wchar_read_double, &wss.base.base1, &val);
1106 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1107 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1109 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1110 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1111 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1112 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1115 call_func1(p_locale_dtor, &lcl);
1117 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1118 call_func1(p_basic_string_wchar_dtor, &wstr);
1123 static void test_num_put_put_double(void)
1125 basic_stringstream_wchar wss;
1126 basic_stringstream_char ss;
1127 basic_string_wchar pwstr;
1128 basic_string_char pstr;
1130 const wchar_t *wstr;
1135 struct _test_num_get {
1138 streamsize prec; /* set to -1 for default */
1139 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
1142 { 0.0, NULL, -1, 0, "0" },
1145 { 0.123, NULL, -1, 0, "0.123" },
1146 { 0.123, NULL, 6, 0, "0.123" },
1147 { 0.123, NULL, 0, 0, "0.123" },
1150 { 0.123, NULL, -1, FMTFLAG_fixed, "0.123000" },
1151 { 0.123, NULL, 6, FMTFLAG_fixed, "0.123000" },
1152 { 0.123, NULL, 0, FMTFLAG_fixed, "0" },
1154 /* scientific format */
1155 { 123456.789, NULL, -1, FMTFLAG_scientific, "1.234568e+005" },
1156 { 123456.789, NULL, 0, FMTFLAG_scientific, "1.234568e+005" },
1157 { 123456.789, NULL, 9, FMTFLAG_scientific, "1.234567890e+005" },
1158 { 123456.789, "German", 9, FMTFLAG_scientific, "1,234567890e+005" },
1160 /* different locales */
1161 { 0.123, "C", -1, 0, "0.123" },
1162 { 0.123, "English", -1, 0, "0.123" },
1163 { 0.123, "German", -1, 0, "0,123" },
1165 { 123456.789, "C", -1, 0, "123457" },
1166 { 123456.789, "English", -1, 0, "123,457" },
1167 { 123456.789, "German", -1, 0, "123.457" },
1169 /* signs and exponents */
1170 { 1.0e-9, NULL, -1, 0, "1e-009" },
1171 { 1.0e-9, NULL, 9, 0, "1e-009" },
1172 { -1.0e9, NULL, -1, 0, "-1e+009" },
1173 { -1.0e9, NULL, 9, 0, "-1e+009" },
1175 { 1.0e-9, NULL, 0, FMTFLAG_fixed, "0" },
1176 { 1.0e-9, NULL, 6, FMTFLAG_fixed, "0.000000" },
1177 { 1.0e-9, NULL, 9, FMTFLAG_fixed, "0.000000001" },
1178 { -1.0e9, NULL, 0, FMTFLAG_fixed, "-1000000000" },
1179 { -1.0e9, NULL, 6, FMTFLAG_fixed, "-1000000000.000000" },
1181 { -1.23456789e9, NULL, 0, 0, "-1.23457e+009" },
1182 { -1.23456789e9, NULL, 0, FMTFLAG_fixed, "-1234567890" },
1183 { -1.23456789e9, NULL, 6, FMTFLAG_fixed, "-1234567890.000000" },
1184 { -1.23456789e-9, NULL, 6, FMTFLAG_fixed, "-0.000000" },
1185 { -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
1188 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1190 call_func2(p_basic_stringstream_char_ctor, &ss, TRUE);
1193 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1194 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1197 /* set format and precision only if specified, so we can try defaults */
1199 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1200 if(tests[i].prec != -1)
1201 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
1202 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, tests[i].val);
1204 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
1205 str = call_func1(p_basic_string_char_cstr, &pstr);
1207 ok(!strcmp(tests[i].str, str), "wrong output, expected = %s found = %s\n", tests[i].str, str);
1208 call_func1(p_basic_string_char_dtor, &pstr);
1211 call_func1(p_locale_dtor, &lcl);
1213 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1215 /* wchar_t version */
1216 call_func2(p_basic_stringstream_wchar_ctor, &wss, TRUE);
1219 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1220 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1223 /* set format and precision only if specified, so we can try defaults */
1225 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1226 if(tests[i].prec != -1)
1227 call_func2(p_ios_base_precision_set, &wss.basic_ios.base, tests[i].prec);
1228 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, tests[i].val);
1230 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
1231 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
1233 AtoW(wide, tests[i].str, strlen(tests[i].str));
1234 ok(!lstrcmpW(wide, wstr), "wrong output, expected = %s found = %s\n", tests[i].str, wine_dbgstr_w(wstr));
1235 call_func1(p_basic_string_wchar_dtor, &pwstr);
1238 call_func1(p_locale_dtor, &lcl);
1240 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1245 static void test_istream_ipfx(void)
1247 unsigned short testus, nextus;
1248 basic_stringstream_wchar wss;
1249 basic_stringstream_char ss;
1250 basic_string_wchar wstr;
1251 basic_string_char str;
1256 /* makes tables narrower */
1257 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1259 struct _test_istream_ipfx {
1267 /* string unset noskip return state next char */
1268 { "", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* empty string */
1269 { " ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* just ws */
1270 { "\t \n \f ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* different ws */
1271 { "simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1272 { " simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1273 { " simple", TRUE, FALSE, TRUE, IOSTATE_goodbit, ' ' }, /* unset skipws */
1274 { " simple", FALSE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* ipfx(true) */
1275 { " simple", TRUE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* both */
1276 { "\n\t ws", FALSE, FALSE, TRUE, IOSTATE_goodbit, 'w' },
1277 { "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
1280 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1282 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1283 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1285 /* set format and precision only if specified, so we can try defaults */
1286 if(tests[i].unset_skipws)
1287 call_func2(p_ios_base_unsetf, &ss.basic_ios.base, TRUE);
1289 ret = (int)call_func2(p_basic_istream_char_ipfx, &ss.base.base1, tests[i].noskip);
1290 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1291 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1293 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1294 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1295 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1297 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1298 call_func1(p_basic_string_char_dtor, &str);
1300 /* wchar_t version */
1301 AtoW(wide, tests[i].str, strlen(tests[i].str));
1302 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1303 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1305 /* set format and precision only if specified, so we can try defaults */
1306 if(tests[i].unset_skipws)
1307 call_func2(p_ios_base_unsetf, &wss.basic_ios.base, TRUE);
1309 ret = (int)call_func2(p_basic_istream_wchar_ipfx, &wss.base.base1, tests[i].noskip);
1310 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1311 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1313 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1314 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1315 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1316 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1318 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1319 call_func1(p_basic_string_wchar_dtor, &wstr);
1324 static void test_istream_ignore(void)
1326 unsigned short testus, nextus;
1327 basic_stringstream_wchar wss;
1328 basic_stringstream_char ss;
1329 basic_string_wchar wstr;
1330 basic_string_char str;
1335 struct _test_istream_ignore {
1342 /* string count delim state next */
1343 { "", 0, '\n', IOSTATE_goodbit, EOF }, /* empty string */
1345 /* different counts */
1346 { "ABCDEF", 2, '\n', IOSTATE_goodbit, 'C' }, /* easy case */
1347 { "ABCDEF", 42, '\n', IOSTATE_eofbit, EOF }, /* ignore too much */
1348 { "ABCDEF", -2, '\n', IOSTATE_goodbit, 'A' }, /* negative count */
1349 { "ABCDEF", 6, '\n', IOSTATE_goodbit, EOF }, /* is eof not set at end */
1350 { "ABCDEF", 7, '\n', IOSTATE_eofbit, EOF }, /* eof is set just after end */
1352 /* different delimiters */
1353 { "ABCDEF", 42, '\0', IOSTATE_eofbit, EOF }, /* null as delim */
1354 { "ABC DEF GHI", 0, ' ', IOSTATE_goodbit, 'A' },
1355 { "ABC DEF GHI", 42, ' ', IOSTATE_goodbit, 'D' },
1356 { "ABC DEF\tGHI", 42, '\t', IOSTATE_goodbit, 'G' },
1357 { "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
1360 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1362 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1363 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1365 call_func3(p_basic_istream_char_ignore, &ss.base.base1, tests[i].count, tests[i].delim);
1366 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1367 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1369 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1370 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1372 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1373 call_func1(p_basic_string_char_dtor, &str);
1375 /* wchar_t version */
1376 AtoW(wide, tests[i].str, strlen(tests[i].str));
1377 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1378 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1380 call_func3(p_basic_istream_wchar_ignore, &wss.base.base1, tests[i].count, tests[i].delim);
1381 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1382 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1384 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1385 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1386 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1388 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1389 call_func1(p_basic_string_wchar_dtor, &wstr);
1394 static void test_istream_seekg(void)
1396 unsigned short testus, nextus;
1397 basic_stringstream_wchar wss;
1398 basic_stringstream_char ss;
1399 basic_string_wchar wstr;
1400 basic_string_char str;
1405 struct _test_istream_seekg {
1412 { "ABCDEFGHIJ", 0, SEEKDIR_beg, IOSTATE_goodbit, 'A' },
1413 { "ABCDEFGHIJ", 1, SEEKDIR_beg, IOSTATE_goodbit, 'B' },
1414 { "ABCDEFGHIJ", 5, SEEKDIR_cur, IOSTATE_goodbit, 'F' },
1415 { "ABCDEFGHIJ", -3, SEEKDIR_end, IOSTATE_goodbit, 'H' },
1418 { "ABCDEFGHIJ", -1, SEEKDIR_beg, IOSTATE_failbit, EOF },
1419 { "ABCDEFGHIJ", 42, SEEKDIR_cur, IOSTATE_failbit, EOF },
1420 { "ABCDEFGHIJ", 42, SEEKDIR_end, IOSTATE_failbit, EOF },
1421 { "", 0, SEEKDIR_beg, IOSTATE_failbit, EOF },
1424 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1426 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1427 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1429 call_func3(p_basic_istream_char_seekg, &ss.base.base1, tests[i].off, tests[i].dir);
1430 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1431 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1433 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1434 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1436 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1437 call_func1(p_basic_string_char_dtor, &str);
1439 /* wchar_t version */
1440 AtoW(wide, tests[i].str, strlen(tests[i].str));
1441 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1442 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1444 call_func3(p_basic_istream_wchar_seekg, &wss.base.base1, tests[i].off, tests[i].dir);
1445 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1446 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1448 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1449 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1450 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1452 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1453 call_func1(p_basic_string_wchar_dtor, &wstr);
1458 static void test_istream_seekg_fpos(void)
1460 unsigned short testus, nextus;
1461 basic_stringstream_wchar wss;
1462 basic_stringstream_char ss;
1463 basic_string_wchar wstr;
1464 basic_string_char str;
1470 struct _test_istream_seekg_fpos {
1476 { "ABCDEFGHIJ", 0, IOSTATE_goodbit, 'A' },
1477 { "ABCDEFGHIJ", 9, IOSTATE_goodbit, 'J' },
1478 { "ABCDEFGHIJ", 10, IOSTATE_goodbit, EOF }, /* beyond end, but still good */
1479 { "ABCDEFGHIJ", -1, IOSTATE_failbit, EOF },
1480 { "", 0, IOSTATE_failbit, EOF },
1483 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1485 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1486 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1488 pos.off = tests[i].off;
1489 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1491 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, pos);
1492 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1493 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1495 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1496 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1498 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1499 call_func1(p_basic_string_char_dtor, &str);
1501 /* wchar_t version */
1502 AtoW(wide, tests[i].str, strlen(tests[i].str));
1503 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1504 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1506 pos.off = tests[i].off;
1507 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1509 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, pos);
1510 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1511 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1513 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1514 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1515 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1517 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1518 call_func1(p_basic_string_wchar_dtor, &wstr);
1523 static void test_istream_peek(void)
1525 unsigned short testus, nextus, peekus;
1526 basic_stringstream_wchar wss;
1527 basic_stringstream_char ss;
1528 basic_string_wchar wstr;
1529 basic_string_char str;
1534 struct _test_istream_peek {
1540 { "", EOF, EOF, IOSTATE_eofbit },
1541 { "ABCDEF", 'A', 'A', IOSTATE_goodbit },
1544 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1546 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1547 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1549 peek = (int)call_func1(p_basic_istream_char_peek, &ss.base.base1);
1550 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1551 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1553 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1554 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1555 ok(peek == next, "wrong peek, expected %c (%i) found = %c (%i)\n", peek, peek, next, next);
1557 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1558 call_func1(p_basic_string_char_dtor, &str);
1560 /* wchar_t version */
1561 AtoW(wide, tests[i].str, strlen(tests[i].str));
1562 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1563 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1565 peekus = (unsigned short)(int)call_func1(p_basic_istream_wchar_peek, &wss.base.base1);
1566 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1567 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1569 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1570 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1571 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1572 ok(peekus == nextus, "wrong peek, expected %c (%i) found = %c (%i)\n", peekus, peekus, nextus, nextus);
1574 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1575 call_func1(p_basic_string_wchar_dtor, &wstr);
1580 static void test_istream_tellg(void)
1582 basic_stringstream_wchar wss;
1583 basic_stringstream_char ss;
1584 basic_fstream_wchar wfs;
1585 basic_fstream_char fs;
1586 basic_string_wchar wstr;
1587 basic_string_char str;
1588 fpos_int spos, tpos, *rpos;
1593 const char *testfile = "file.txt";
1595 struct _test_istream_tellg_fpos {
1598 streamoff telloff_ss; /* offset for stringstream */
1599 streamoff telloff_fs; /* offset for fstream */
1603 { "", -1, -1, 0, 0 }, /* tellg on defaults */
1604 { "", 0, -1, 0, 0 }, /* tellg after seek 0 */
1605 { "", 42, -1, 0, 42 }, /* tellg after seek beyond end */
1606 { "", -6, -1, -1, 0 }, /* tellg after seek beyond beg */
1608 /* non-empty strings */
1609 { "ABCDEFGHIJ", -1, 0, 0, 0 },
1610 { "ABCDEFGHIJ", 3, 3, 0, 3 },
1611 { "ABCDEFGHIJ", 42, -1, 0, 42 },
1612 { "ABCDEFGHIJ", -6, -1, -1, 0 }
1615 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1616 /* stringstream<char> version */
1617 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1618 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1620 spos.off = tests[i].seekoff;
1624 tpos.off = 0xdeadbeef;
1625 tpos.pos = 0xdeadbeef;
1626 tpos.state = 0xdeadbeef;
1628 if (tests[i].seekoff != -1) /* to test without seek */
1629 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, spos);
1630 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &ss.base.base1, &tpos);
1632 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1633 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1634 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1635 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1636 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1637 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1639 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1640 call_func1(p_basic_string_char_dtor, &str);
1642 /* stringstream<wchar_t> version */
1643 AtoW(wide, tests[i].str, strlen(tests[i].str));
1644 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1645 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1647 spos.off = tests[i].seekoff;
1648 spos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1651 tpos.off = 0xdeadbeef;
1652 tpos.pos = 0xdeadbeef;
1653 tpos.state = 0xdeadbeef;
1655 if (tests[i].seekoff != -1) /* to test without seek */
1656 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, spos);
1657 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wss.base.base1, &tpos);
1659 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1660 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1661 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1662 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1663 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1664 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1666 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1667 call_func1(p_basic_string_wchar_dtor, &wstr);
1670 file = fopen(testfile, "wt");
1671 fprintf(file, tests[i].str);
1674 /* fstream<char> version */
1675 call_func5(p_basic_fstream_char_ctor_name, &fs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1677 spos.off = tests[i].seekoff;
1681 tpos.off = 0xdeadbeef;
1682 tpos.pos = 0xdeadbeef;
1683 tpos.state = 0xdeadbeef;
1685 if (tests[i].seekoff != -1) /* to test without seek */
1686 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &fs.base.base1, spos);
1687 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &fs.base.base1, &tpos);
1689 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1690 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1691 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1692 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1693 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1695 call_func1(p_basic_fstream_char_vbase_dtor, &fs);
1697 /* fstream<wchar_t> version */
1698 call_func5(p_basic_fstream_wchar_ctor_name, &wfs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1700 spos.off = tests[i].seekoff;
1704 tpos.off = 0xdeadbeef;
1705 tpos.pos = 0xdeadbeef;
1706 tpos.state = 0xdeadbeef;
1708 if (tests[i].seekoff != -1) /* to test without seek */
1709 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wfs.base.base1, spos);
1710 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wfs.base.base1, &tpos);
1712 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1713 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1714 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1715 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1716 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1718 call_func1(p_basic_fstream_wchar_vbase_dtor, &wfs);
1725 static void test_istream_getline(void)
1727 basic_stringstream_wchar wss;
1728 basic_stringstream_char ss;
1729 basic_string_wchar wstr;
1730 basic_string_char str;
1735 const wchar_t *wcstr;
1737 /* makes tables narrower */
1738 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1740 struct _test_istream_getline {
1745 const char *nextline;
1747 IOSB_iostate nextstate;
1749 { "", "", '\n', IOSTATE_faileof, "", '\n', IOSTATE_faileof },
1751 { "this\n", "this", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1752 { "this\nis\nsome\ntext\n", "this", '\n', IOSTATE_goodbit, "is", '\n', IOSTATE_goodbit },
1754 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is", ' ', IOSTATE_goodbit },
1755 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is some text", '\n', IOSTATE_goodbit },
1757 { "this is some text\n", "this is some text", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1758 { "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit, "this is some text\n", '\n', IOSTATE_faileof },
1761 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1763 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1764 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1766 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].delim);
1767 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1768 cstr = call_func1(p_basic_string_char_cstr, &str);
1770 ok(!strcmp(tests[i].line, cstr), "wrong line, expected = %s found = %s\n", tests[i].line, cstr);
1771 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1774 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].nextdelim);
1775 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1776 cstr = call_func1(p_basic_string_char_cstr, &str);
1778 ok(!strcmp(tests[i].nextline, cstr), "wrong next line, expected = %s found = %s\n", tests[i].nextline, cstr);
1779 ok(tests[i].nextstate == state, "wrong next state, expected = %x found = %x\n", tests[i].nextstate, state);
1781 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1782 call_func1(p_basic_string_char_dtor, &str);
1784 /* wchar_t version */
1785 AtoW(wide, tests[i].str, strlen(tests[i].str));
1786 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1787 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1789 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].delim);
1790 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1791 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
1793 AtoW(wide, tests[i].line, strlen(tests[i].line));
1794 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].line, wine_dbgstr_w(wcstr));
1795 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1798 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].nextdelim);
1799 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1800 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
1802 AtoW(wide, tests[i].nextline, strlen(tests[i].nextline));
1803 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].nextline, wine_dbgstr_w(wcstr));
1804 ok(tests[i].nextstate == state, "wrong state, expected = %x found = %x\n", tests[i].nextstate, state);
1806 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1807 call_func1(p_basic_string_wchar_dtor, &wstr);
1817 test_num_get_get_uint64();
1818 test_num_get_get_double();
1819 test_num_put_put_double();
1820 test_istream_ipfx();
1821 test_istream_ignore();
1822 test_istream_seekg();
1823 test_istream_seekg_fpos();
1824 test_istream_peek();
1825 test_istream_tellg();
1826 test_istream_getline();
1828 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");