mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / msvcp90 / tests / ios.c
blob994420dd2290636fe51f5032c14cc4fd0245f425
1 /*
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
19 #include <stdio.h>
20 #include <locale.h>
21 #include <sys/stat.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <share.h>
26 #include "wine/test.h"
28 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
29 static void (__cdecl *p_free)(void*);
31 #undef __thiscall
32 #ifdef __i386__
33 #define __thiscall __stdcall
34 #else
35 #define __thiscall __cdecl
36 #endif
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);
45 /* class mutex */
46 typedef struct {
47 void *mutex;
48 } mutex;
50 /* class locale */
51 typedef struct
53 struct _locale__Locimp *ptr;
54 } locale;
56 /* class locale::facet */
57 typedef struct {
58 const vtable_ptr *vtable;
59 MSVCP_size_t refs;
60 } locale_facet;
62 /* class codecvt_base */
63 typedef struct {
64 locale_facet facet;
65 } codecvt_base;
67 /* class codecvt<char> */
68 typedef struct {
69 codecvt_base base;
70 } codecvt_char;
72 typedef struct {
73 LCID handle;
74 unsigned page;
75 } _Cvtvec;
77 /* class codecvt<wchar> */
78 typedef struct {
79 codecvt_base base;
80 _Cvtvec cvt;
81 } codecvt_wchar;
83 typedef enum {
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,
93 FMTFLAG_dec = 0x0200,
94 FMTFLAG_oct = 0x0400,
95 FMTFLAG_hex = 0x0800,
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
105 } IOSB_fmtflags;
107 typedef enum {
108 OPENMODE_in = 0x01,
109 OPENMODE_out = 0x02,
110 OPENMODE_ate = 0x04,
111 OPENMODE_app = 0x08,
112 OPENMODE_trunc = 0x10,
113 OPENMODE__Nocreate = 0x40,
114 OPENMODE__Noreplace = 0x80,
115 OPENMODE_binary = 0x20,
116 OPENMODE_mask = 0xff
117 } IOSB_openmode;
119 typedef enum {
120 SEEKDIR_beg = 0x0,
121 SEEKDIR_cur = 0x1,
122 SEEKDIR_end = 0x2,
123 SEEKDIR_mask = 0x3
124 } IOSB_seekdir;
126 typedef enum {
127 IOSTATE_goodbit = 0x00,
128 IOSTATE_eofbit = 0x01,
129 IOSTATE_failbit = 0x02,
130 IOSTATE_badbit = 0x04,
131 IOSTATE__Hardfail = 0x10,
132 IOSTATE_mask = 0x17
133 } IOSB_iostate;
135 typedef struct _iosarray {
136 struct _iosarray *next;
137 int index;
138 int long_val;
139 void *ptr_val;
140 } IOS_BASE_iosarray;
142 typedef enum {
143 EVENT_erase_event,
144 EVENT_imbue_event,
145 EVENT_copyfmt_event
146 } IOS_BASE_event;
148 struct _ios_base;
149 typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
150 typedef struct _fnarray {
151 struct _fnarray *next;
152 int index;
153 IOS_BASE_event_callback event_handler;
154 } IOS_BASE_fnarray;
156 /* class ios_base */
157 typedef struct _ios_base {
158 const vtable_ptr *vtable;
159 MSVCP_size_t stdstr;
160 IOSB_iostate state;
161 IOSB_iostate except;
162 IOSB_fmtflags fmtfl;
163 streamsize prec;
164 streamsize wide;
165 IOS_BASE_iosarray *arr;
166 IOS_BASE_fnarray *calls;
167 locale *loc;
168 } ios_base;
170 /* class basic_streambuf<char> */
171 typedef struct {
172 const vtable_ptr *vtable;
173 mutex lock;
174 char *rbuf;
175 char *wbuf;
176 char **prbuf;
177 char **pwbuf;
178 char *rpos;
179 char *wpos;
180 char **prpos;
181 char **pwpos;
182 int rsize;
183 int wsize;
184 int *prsize;
185 int *pwsize;
186 locale *loc;
187 } basic_streambuf_char;
189 /* class istreambuf_iterator<char> */
190 typedef struct {
191 basic_streambuf_char *strbuf;
192 MSVCP_bool got;
193 char val;
194 } istreambuf_iterator_char;
196 /* class basic_streambuf<wchar> */
197 typedef struct {
198 const vtable_ptr *vtable;
199 mutex lock;
200 wchar_t *rbuf;
201 wchar_t *wbuf;
202 wchar_t **prbuf;
203 wchar_t **pwbuf;
204 wchar_t *rpos;
205 wchar_t *wpos;
206 wchar_t **prpos;
207 wchar_t **pwpos;
208 int rsize;
209 int wsize;
210 int *prsize;
211 int *pwsize;
212 locale *loc;
213 } basic_streambuf_wchar;
215 typedef struct {
216 basic_streambuf_char base;
217 codecvt_char *cvt;
218 char putback;
219 MSVCP_bool wrotesome;
220 int state;
221 MSVCP_bool close;
222 FILE *file;
223 } basic_filebuf_char;
225 typedef struct {
226 basic_streambuf_wchar base;
227 codecvt_wchar *cvt;
228 wchar_t putback;
229 MSVCP_bool wrotesome;
230 int state;
231 MSVCP_bool close;
232 FILE *file;
233 } basic_filebuf_wchar;
235 typedef struct {
236 basic_streambuf_char base;
237 char *seekhigh;
238 int state;
239 char allocator; /* empty struct */
240 } basic_stringbuf_char;
242 typedef struct {
243 basic_streambuf_wchar base;
244 wchar_t *seekhigh;
245 int state;
246 char allocator; /* empty struct */
247 } basic_stringbuf_wchar;
249 typedef struct {
250 ios_base base;
251 basic_streambuf_char *strbuf;
252 struct _basic_ostream_char *stream;
253 char fillch;
254 } basic_ios_char;
256 typedef struct {
257 ios_base base;
258 basic_streambuf_wchar *strbuf;
259 struct _basic_ostream_wchar *stream;
260 wchar_t fillch;
261 } basic_ios_wchar;
263 typedef struct _basic_ostream_char {
264 const int *vbtable;
265 /* virtual inheritance
266 * basic_ios_char basic_ios;
268 } basic_ostream_char;
270 typedef struct _basic_ostream_wchar {
271 const int *vbtable;
272 /* virtual inheritance
273 * basic_ios_wchar basic_ios;
275 } basic_ostream_wchar;
277 typedef struct {
278 const int *vbtable;
279 streamsize count;
280 /* virtual inheritance
281 * basic_ios_char basic_ios;
283 } basic_istream_char;
285 typedef struct {
286 const int *vbtable;
287 streamsize count;
288 /* virtual inheritance
289 * basic_ios_wchar basic_ios;
291 } basic_istream_wchar;
293 typedef struct {
294 basic_istream_char base1;
295 basic_ostream_char base2;
296 /* virtual inheritance
297 * basic_ios_char basic_ios;
299 } basic_iostream_char;
301 typedef struct {
302 basic_istream_wchar base1;
303 basic_ostream_wchar base2;
304 /* virtual inheritance
305 * basic_ios_wchar basic_ios;
307 } basic_iostream_wchar;
309 typedef struct {
310 basic_ostream_char base;
311 basic_filebuf_char filebuf;
312 /* virtual inheritance
313 * basic_ios_char basic_ios;
315 } basic_ofstream_char;
317 typedef struct {
318 basic_ostream_wchar base;
319 basic_filebuf_wchar filebuf;
320 /* virtual inheritance
321 * basic_ios_wchar basic_ios;
323 } basic_ofstream_wchar;
325 typedef struct {
326 basic_istream_char base;
327 basic_filebuf_char filebuf;
328 /* virtual inheritance
329 * basic_ios_char basic_ios;
331 } basic_ifstream_char;
333 typedef struct {
334 basic_istream_wchar base;
335 basic_filebuf_wchar filebuf;
336 /* virtual inheritance
337 * basic_ios_wchar basic_ios;
339 } basic_ifstream_wchar;
341 typedef struct {
342 basic_iostream_char base;
343 basic_filebuf_char filebuf;
344 /* virtual inheritance */
345 basic_ios_char basic_ios; /* here to reserve correct stack size */
346 } basic_fstream_char;
348 typedef struct {
349 basic_iostream_wchar base;
350 basic_filebuf_wchar filebuf;
351 /* virtual inheritance */
352 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
353 } basic_fstream_wchar;
355 typedef struct {
356 basic_ostream_char base;
357 basic_stringbuf_char strbuf;
358 /* virtual inheritance
359 * basic_ios_char basic_ios;
361 } basic_ostringstream_char;
363 typedef struct {
364 basic_ostream_wchar base;
365 basic_stringbuf_wchar strbuf;
366 /* virtual inheritance
367 * basic_ios_wchar basic_ios;
369 } basic_ostringstream_wchar;
371 typedef struct {
372 basic_istream_char base;
373 basic_stringbuf_char strbuf;
374 /* virtual inheritance
375 * basic_ios_char basic_ios;
377 } basic_istringstream_char;
379 typedef struct {
380 basic_istream_wchar base;
381 basic_stringbuf_wchar strbuf;
382 /* virtual inheritance
383 * basic_ios_wchar basic_ios;
385 } basic_istringstream_wchar;
387 typedef struct {
388 basic_iostream_char base;
389 basic_stringbuf_char strbuf;
390 /* virtual inheritance */
391 basic_ios_char basic_ios; /* here to reserve correct stack size */
392 } basic_stringstream_char;
394 typedef struct {
395 basic_iostream_wchar base;
396 basic_stringbuf_wchar strbuf;
397 /* virtual inheritance */
398 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
399 } basic_stringstream_wchar;
401 /* basic_string<char, char_traits<char>, allocator<char>> */
402 #define BUF_SIZE_CHAR 16
403 typedef struct _basic_string_char
405 void *allocator;
406 union {
407 char buf[BUF_SIZE_CHAR];
408 char *ptr;
409 } data;
410 size_t size;
411 size_t res;
412 } basic_string_char;
414 #define BUF_SIZE_WCHAR 8
415 typedef struct
417 void *allocator;
418 union {
419 wchar_t buf[BUF_SIZE_WCHAR];
420 wchar_t *ptr;
421 } data;
422 MSVCP_size_t size;
423 MSVCP_size_t res;
424 } basic_string_wchar;
426 typedef struct {
427 streamoff off;
428 __int64 DECLSPEC_ALIGN(8) pos;
429 int state;
430 } fpos_int;
432 /* class complex<float> */
433 typedef struct {
434 float real;
435 float imag;
436 } complex_float;
438 /* class complex<double> */
439 /* class complex<long double> */
440 typedef struct {
441 double real;
442 double imag;
443 } complex_double;
445 typedef enum {
446 DATEORDER_no_order,
447 DATEORDER_dmy,
448 DATEORDER_mdy,
449 DATEORDER_ymd,
450 DATEORDER_ydm
451 } dateorder;
453 /* class time_get<char> */
454 typedef struct {
455 locale_facet facet;
456 const char *days;
457 const char *months;
458 dateorder dateorder;
459 _Cvtvec cvt;
460 } time_get_char;
462 /* stringstream */
463 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor)(basic_stringstream_char*);
464 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor_str)(basic_stringstream_char*, const basic_string_char*, int, MSVCP_bool);
465 static basic_string_char* (*__thiscall p_basic_stringstream_char_str_get)(const basic_stringstream_char*, basic_string_char*);
466 static void (*__thiscall p_basic_stringstream_char_vbase_dtor)(basic_stringstream_char*);
468 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor)(basic_stringstream_wchar*);
469 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor_str)(basic_stringstream_wchar*, const basic_string_wchar*, int, MSVCP_bool);
470 static basic_string_wchar* (*__thiscall p_basic_stringstream_wchar_str_get)(const basic_stringstream_wchar*, basic_string_wchar*);
471 static void (*__thiscall p_basic_stringstream_wchar_vbase_dtor)(basic_stringstream_wchar*);
473 /* fstream */
474 static basic_fstream_char* (*__thiscall p_basic_fstream_char_ctor_name)(basic_fstream_char*, const char*, int, int, MSVCP_bool);
475 static void (*__thiscall p_basic_fstream_char_vbase_dtor)(basic_fstream_char*);
477 static basic_fstream_wchar* (*__thiscall p_basic_fstream_wchar_ctor_name)(basic_fstream_wchar*, const char*, int, int, MSVCP_bool);
478 static void (*__thiscall p_basic_fstream_wchar_vbase_dtor)(basic_fstream_wchar*);
480 /* istream */
481 static basic_istream_char* (*__thiscall p_basic_istream_char_read_uint64)(basic_istream_char*, unsigned __int64*);
482 static basic_istream_char* (*__thiscall p_basic_istream_char_read_float)(basic_istream_char*, float*);
483 static basic_istream_char* (*__thiscall p_basic_istream_char_read_double)(basic_istream_char*, double*);
484 static basic_istream_char* (*__cdecl p_basic_istream_char_read_str)(basic_istream_char*, char*);
485 static basic_istream_char* (*__cdecl p_basic_istream_char_read_complex_double)(basic_istream_char*, complex_double*);
486 static int (*__thiscall p_basic_istream_char_get)(basic_istream_char*);
487 static MSVCP_bool (*__thiscall p_basic_istream_char_ipfx)(basic_istream_char*, MSVCP_bool);
488 static basic_istream_char* (*__thiscall p_basic_istream_char_ignore)(basic_istream_char*, streamsize, int);
489 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg)(basic_istream_char*, streamoff, int);
490 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg_fpos)(basic_istream_char*, fpos_int);
491 static int (*__thiscall p_basic_istream_char_peek)(basic_istream_char*);
492 static fpos_int* (*__thiscall p_basic_istream_char_tellg)(basic_istream_char*, fpos_int*);
493 static basic_istream_char* (*__cdecl p_basic_istream_char_getline_bstr_delim)(basic_istream_char*, basic_string_char*, char);
495 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_uint64)(basic_istream_wchar*, unsigned __int64*);
496 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_double)(basic_istream_wchar*, double *);
497 static int (*__thiscall p_basic_istream_wchar_get)(basic_istream_wchar*);
498 static MSVCP_bool (*__thiscall p_basic_istream_wchar_ipfx)(basic_istream_wchar*, MSVCP_bool);
499 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_ignore)(basic_istream_wchar*, streamsize, unsigned short);
500 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg)(basic_istream_wchar*, streamoff, int);
501 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg_fpos)(basic_istream_wchar*, fpos_int);
502 static unsigned short (*__thiscall p_basic_istream_wchar_peek)(basic_istream_wchar*);
503 static fpos_int* (*__thiscall p_basic_istream_wchar_tellg)(basic_istream_wchar*, fpos_int*);
504 static basic_istream_wchar* (*__cdecl p_basic_istream_wchar_getline_bstr_delim)(basic_istream_wchar*, basic_string_wchar*, wchar_t);
506 /* ostream */
507 static basic_ostream_char* (*__thiscall p_basic_ostream_char_print_float)(basic_ostream_char*, float);
509 static basic_ostream_char* (*__thiscall p_basic_ostream_char_print_double)(basic_ostream_char*, double);
511 static basic_ostream_wchar* (*__thiscall p_basic_ostream_wchar_print_double)(basic_ostream_wchar*, double);
513 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_float)(basic_ostream_char*, complex_float*);
515 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_double)(basic_ostream_char*, complex_double*);
517 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_ldouble)(basic_ostream_char*, complex_double*);
519 static basic_ostream_wchar* (*__thiscall p_basic_ostream_short_print_ushort)(basic_ostream_wchar*, unsigned short);
521 /* basic_ios */
522 static locale* (*__thiscall p_basic_ios_char_imbue)(basic_ios_char*, locale*, const locale*);
523 static basic_ios_char* (*__thiscall p_basic_ios_char_ctor)(basic_ios_char*);
524 static char (*__thiscall p_basic_ios_char_widen)(basic_ios_char*, char);
525 static void (*__thiscall p_basic_ios_char_dtor)(basic_ios_char*);
527 static locale* (*__thiscall p_basic_ios_wchar_imbue)(basic_ios_wchar*, locale*, const locale*);
529 /* ios_base */
530 static void (*__thiscall p_ios_base__Init)(ios_base*);
531 static IOSB_iostate (*__thiscall p_ios_base_rdstate)(const ios_base*);
532 static IOSB_fmtflags (*__thiscall p_ios_base_setf_mask)(ios_base*, IOSB_fmtflags, IOSB_fmtflags);
533 static void (*__thiscall p_ios_base_unsetf)(ios_base*, IOSB_fmtflags);
534 static streamsize (*__thiscall p_ios_base_precision_set)(ios_base*, streamsize);
536 /* locale */
537 static locale* (*__thiscall p_locale_ctor_cstr)(locale*, const char*, int /* FIXME: category */);
538 static void (*__thiscall p_locale_dtor)(locale *this);
540 /* basic_string */
541 static basic_string_char* (__thiscall *p_basic_string_char_ctor_cstr)(basic_string_char*, const char*);
542 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
543 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
545 static basic_string_wchar* (__thiscall *p_basic_string_wchar_ctor_cstr)(basic_string_wchar*, const wchar_t*);
546 static const wchar_t* (__thiscall *p_basic_string_wchar_cstr)(basic_string_wchar*);
547 static void (__thiscall *p_basic_string_wchar_dtor)(basic_string_wchar*);
549 /* basic_istringstream */
550 static basic_istringstream_char* (__thiscall *p_basic_istringstream_char_ctor_str)(
551 basic_istringstream_char*, const basic_string_char*, int, MSVCP_bool);
552 static void (__thiscall *p_basic_istringstream_char_dtor)(basic_ios_char*);
554 /* time_get */
555 static time_get_char* (__thiscall *p_time_get_char_ctor)(time_get_char*);
556 static void (__thiscall *p_time_get_char_dtor)(time_get_char*);
557 static int (__cdecl *p_time_get_char__Getint)(const time_get_char*,
558 istreambuf_iterator_char*, istreambuf_iterator_char*, int, int, int*);
560 static int invalid_parameter = 0;
561 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
562 const wchar_t *function, const wchar_t *file,
563 unsigned line, uintptr_t arg)
565 ok(expression == NULL, "expression is not NULL\n");
566 ok(function == NULL, "function is not NULL\n");
567 ok(file == NULL, "file is not NULL\n");
568 ok(line == 0, "line = %u\n", line);
569 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
570 invalid_parameter++;
573 /* Emulate a __thiscall */
574 #ifdef __i386__
576 #include "pshpack1.h"
577 struct thiscall_thunk
579 BYTE pop_eax; /* popl %eax (ret addr) */
580 BYTE pop_edx; /* popl %edx (func) */
581 BYTE pop_ecx; /* popl %ecx (this) */
582 BYTE push_eax; /* pushl %eax */
583 WORD jmp_edx; /* jmp *%edx */
585 #include "poppack.h"
587 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
588 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
589 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
590 static void * (WINAPI *call_thiscall_func4)( void *func, void *this, const void *a, const void *b,
591 const void *c );
592 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
593 const void *c, const void *d );
595 /* to silence compiler errors */
596 static void * (WINAPI *call_thiscall_func2_ptr_dbl)( void *func, void *this, double a );
597 static void * (WINAPI *call_thiscall_func2_ptr_flt)( void *func, void *this, float a );
598 static void * (WINAPI *call_thiscall_func2_ptr_fpos)( void *func, void *this, fpos_int a );
600 static void init_thiscall_thunk(void)
602 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
603 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
604 thunk->pop_eax = 0x58; /* popl %eax */
605 thunk->pop_edx = 0x5a; /* popl %edx */
606 thunk->pop_ecx = 0x59; /* popl %ecx */
607 thunk->push_eax = 0x50; /* pushl %eax */
608 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
609 call_thiscall_func1 = (void *)thunk;
610 call_thiscall_func2 = (void *)thunk;
611 call_thiscall_func3 = (void *)thunk;
612 call_thiscall_func4 = (void *)thunk;
613 call_thiscall_func5 = (void *)thunk;
615 call_thiscall_func2_ptr_dbl = (void *)thunk;
616 call_thiscall_func2_ptr_flt = (void *)thunk;
617 call_thiscall_func2_ptr_fpos = (void *)thunk;
620 #define call_func1(func,_this) call_thiscall_func1(func,_this)
621 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
622 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
623 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
624 (const void*)(c))
625 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
626 (const void*)(c), (const void *)(d))
628 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
629 #define call_func2_ptr_flt(func,_this,a) call_thiscall_func2_ptr_flt(func,_this,a)
630 #define call_func2_ptr_fpos(func,_this,a) call_thiscall_func2_ptr_fpos(func,_this,a)
632 #else
634 #define init_thiscall_thunk()
635 #define call_func1(func,_this) func(_this)
636 #define call_func2(func,_this,a) func(_this,a)
637 #define call_func3(func,_this,a,b) func(_this,a,b)
638 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
639 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
641 #define call_func2_ptr_dbl call_func2
642 #define call_func2_ptr_flt call_func2
643 #define call_func2_ptr_fpos call_func2
645 #endif /* __i386__ */
647 static HMODULE msvcr, msvcp;
648 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
649 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
650 static BOOL init(void)
652 msvcr = LoadLibraryA("msvcr90.dll");
653 msvcp = LoadLibraryA("msvcp90.dll");
654 if(!msvcr || !msvcp) {
655 win_skip("msvcp90.dll or msvcr90.dll not installed\n");
656 return FALSE;
659 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
660 p_free = (void*)GetProcAddress(msvcr, "free");
661 if(!p_set_invalid_parameter_handler || !p_free) {
662 win_skip("Error setting tests environment\n");
663 return FALSE;
666 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
668 if(sizeof(void*) == 8) { /* 64-bit initialization */
669 SET(p_basic_stringstream_char_ctor,
670 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
671 SET(p_basic_stringstream_char_ctor_str,
672 "??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");
673 SET(p_basic_stringstream_char_str_get,
674 "?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");
675 SET(p_basic_stringstream_char_vbase_dtor,
676 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
678 SET(p_basic_stringstream_wchar_ctor,
679 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
680 SET(p_basic_stringstream_wchar_ctor_str,
681 "??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");
682 SET(p_basic_stringstream_wchar_str_get,
683 "?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");
684 SET(p_basic_stringstream_wchar_vbase_dtor,
685 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
687 SET(p_basic_fstream_char_ctor_name,
688 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z");
689 SET(p_basic_fstream_char_vbase_dtor,
690 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ");
692 SET(p_basic_fstream_wchar_ctor_name,
693 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z");
694 SET(p_basic_fstream_wchar_vbase_dtor,
695 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ");
697 SET(p_basic_istream_char_read_uint64,
698 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z");
699 SET(p_basic_istream_char_read_float,
700 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z");
701 SET(p_basic_istream_char_read_double,
702 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z");
703 SET(p_basic_istream_char_read_str,
704 "??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z");
705 SET(p_basic_istream_char_read_complex_double,
706 "??$?5NDU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$complex@N@0@@Z");
707 SET(p_basic_istream_char_get,
708 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
709 SET(p_basic_istream_char_ipfx,
710 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z");
711 SET(p_basic_istream_char_ignore,
712 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
713 SET(p_basic_istream_char_seekg,
714 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
715 SET(p_basic_istream_char_seekg_fpos,
716 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
717 SET(p_basic_istream_char_peek,
718 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
719 SET(p_basic_istream_char_tellg,
720 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
721 SET(p_basic_istream_char_getline_bstr_delim,
722 "??$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");
724 SET(p_basic_istream_wchar_read_uint64,
725 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z");
726 SET(p_basic_istream_wchar_read_double,
727 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z");
728 SET(p_basic_istream_wchar_get,
729 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
730 SET(p_basic_istream_wchar_ipfx,
731 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z");
732 SET(p_basic_istream_wchar_ignore,
733 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z");
734 SET(p_basic_istream_wchar_seekg,
735 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z");
736 SET(p_basic_istream_wchar_seekg_fpos,
737 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
738 SET(p_basic_istream_wchar_peek,
739 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
740 SET(p_basic_istream_wchar_tellg,
741 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
742 SET(p_basic_istream_wchar_getline_bstr_delim,
743 "??$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");
745 SET(p_basic_ostream_char_print_float,
746 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z");
748 SET(p_basic_ostream_char_print_double,
749 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z");
751 SET(p_basic_ostream_wchar_print_double,
752 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z");
754 SET(p_basic_ostream_short_print_ushort,
755 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@G@Z");
757 SET(p_basic_ostream_char_print_complex_float,
758 "??$?6MDU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@M@0@@Z");
760 SET(p_basic_ostream_char_print_complex_double,
761 "??$?6NDU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@N@0@@Z");
763 SET(p_basic_ostream_char_print_complex_ldouble,
764 "??$?6ODU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@O@0@@Z");
766 SET(p_ios_base__Init,
767 "?_Init@ios_base@std@@IEAAXXZ");
768 SET(p_ios_base_rdstate,
769 "?rdstate@ios_base@std@@QEBAHXZ");
770 SET(p_ios_base_setf_mask,
771 "?setf@ios_base@std@@QEAAHHH@Z");
772 SET(p_ios_base_unsetf,
773 "?unsetf@ios_base@std@@QEAAXH@Z");
774 SET(p_ios_base_precision_set,
775 "?precision@ios_base@std@@QEAA_J_J@Z");
777 SET(p_basic_ios_char_imbue,
778 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
779 SET(p_basic_ios_char_ctor,
780 "??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ");
781 SET(p_basic_ios_char_widen,
782 "?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z");
783 SET(p_basic_ios_char_dtor,
784 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ");
786 SET(p_basic_ios_wchar_imbue,
787 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
789 SET(p_locale_ctor_cstr,
790 "??0locale@std@@QEAA@PEBDH@Z");
791 SET(p_locale_dtor,
792 "??1locale@std@@QEAA@XZ");
794 SET(p_basic_string_char_ctor_cstr,
795 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBD@Z");
796 SET(p_basic_string_char_cstr,
797 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
798 SET(p_basic_string_char_dtor,
799 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
801 SET(p_basic_string_wchar_ctor_cstr,
802 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@PEB_W@Z");
803 SET(p_basic_string_wchar_cstr,
804 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
805 SET(p_basic_string_wchar_dtor,
806 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@XZ");
808 SET(p_basic_istringstream_char_ctor_str,
809 "??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?"
810 "$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z");
811 SET(p_basic_istringstream_char_dtor,
812 "??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ");
813 SET(p_time_get_char_ctor,
814 "??_F?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QEAAXXZ");
815 SET(p_time_get_char_dtor,
816 "??1?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MEAA@XZ");
817 SET(p_time_get_char__Getint,
818 "?_Getint@?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std"
819 "@@AEBAHAEAV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@0HHAEAH@Z");
820 } else {
821 #ifdef __arm__
822 SET(p_basic_stringstream_char_ctor,
823 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
824 SET(p_basic_stringstream_char_ctor_str,
825 "??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");
826 SET(p_basic_stringstream_char_str_get,
827 "?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");
828 SET(p_basic_stringstream_char_vbase_dtor,
829 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
831 SET(p_basic_stringstream_wchar_ctor,
832 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
833 SET(p_basic_stringstream_wchar_ctor_str,
834 "??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");
835 SET(p_basic_stringstream_wchar_str_get,
836 "?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");
837 SET(p_basic_stringstream_wchar_vbase_dtor,
838 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
840 SET(p_basic_fstream_char_ctor_name,
841 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
842 SET(p_basic_fstream_char_vbase_dtor,
843 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
845 SET(p_basic_fstream_wchar_ctor_name,
846 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
847 SET(p_basic_fstream_wchar_vbase_dtor,
848 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
850 SET(p_basic_istream_char_read_uint64,
851 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AA_K@Z");
852 SET(p_basic_istream_char_read_float,
853 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AAM@Z");
854 SET(p_basic_istream_char_read_double,
855 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AAN@Z");
856 SET(p_basic_istream_char_read_str,
857 "??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z");
858 SET(p_basic_istream_char_read_complex_double,
859 "??$?5NDU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$complex@N@0@@Z");
860 SET(p_basic_istream_char_get,
861 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAHXZ");
862 SET(p_basic_istream_char_ipfx,
863 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAA_N_N@Z");
864 SET(p_basic_istream_char_ignore,
865 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
866 SET(p_basic_istream_char_seekg,
867 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
868 SET(p_basic_istream_char_seekg_fpos,
869 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV12@V?$fpos@H@2@@Z");
870 SET(p_basic_istream_char_peek,
871 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAHXZ");
872 SET(p_basic_istream_char_tellg,
873 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAA?AV?$fpos@H@2@XZ");
874 SET(p_basic_istream_char_getline_bstr_delim,
875 "??$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");
877 SET(p_basic_istream_wchar_read_uint64,
878 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@AA_K@Z");
879 SET(p_basic_istream_wchar_read_double,
880 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@AAN@Z");
881 SET(p_basic_istream_wchar_get,
882 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAGXZ");
883 SET(p_basic_istream_wchar_ipfx,
884 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAA_N_N@Z");
885 SET(p_basic_istream_wchar_ignore,
886 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
887 SET(p_basic_istream_wchar_seekg,
888 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
889 SET(p_basic_istream_wchar_seekg_fpos,
890 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV12@V?$fpos@H@2@@Z");
891 SET(p_basic_istream_wchar_peek,
892 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAGXZ");
893 SET(p_basic_istream_wchar_tellg,
894 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAA?AV?$fpos@H@2@XZ");
895 SET(p_basic_istream_wchar_getline_bstr_delim,
896 "??$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");
898 SET(p_basic_ostream_char_print_float,
899 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAAAAV01@M@Z");
901 SET(p_basic_ostream_char_print_double,
902 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAAAAV01@N@Z");
904 SET(p_basic_ostream_wchar_print_double,
905 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@N@Z");
907 SET(p_basic_ostream_short_print_ushort,
908 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAAAAV01@G@Z");
910 SET(p_basic_ostream_char_print_complex_float,
911 "??$?6MDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@M@0@@Z");
913 SET(p_basic_ostream_char_print_complex_double,
914 "??$?6NDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@N@0@@Z");
916 SET(p_basic_ostream_char_print_complex_ldouble,
917 "??$?6ODU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@O@0@@Z");
919 SET(p_ios_base__Init,
920 "?_Init@ios_base@std@@IAAXXZ");
921 SET(p_ios_base_rdstate,
922 "?rdstate@ios_base@std@@QBAHXZ");
923 SET(p_ios_base_setf_mask,
924 "?setf@ios_base@std@@QAAHHH@Z");
925 SET(p_ios_base_unsetf,
926 "?unsetf@ios_base@std@@QAAXH@Z");
927 SET(p_ios_base_precision_set,
928 "?precision@ios_base@std@@QAEHH@Z");
930 SET(p_basic_ios_char_imbue,
931 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAA?AVlocale@2@ABV32@@Z");
932 SET(p_basic_ios_char_ctor,
933 "??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAA@XZ");
934 SET(p_basic_ios_char_widen,
935 "?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBADD@Z");
936 SET(p_basic_ios_char_dtor,
937 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAA@XZ");
939 SET(p_basic_ios_wchar_imbue,
940 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAA?AVlocale@2@ABV32@@Z");
942 SET(p_locale_ctor_cstr,
943 "??0locale@std@@QAE@PBDH@Z");
944 SET(p_locale_dtor,
945 "??1locale@std@@QAE@XZ");
947 SET(p_basic_string_char_ctor_cstr,
948 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
949 SET(p_basic_string_char_cstr,
950 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
951 SET(p_basic_string_char_dtor,
952 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
954 SET(p_basic_string_wchar_ctor_cstr,
955 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
956 SET(p_basic_string_wchar_cstr,
957 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
958 SET(p_basic_string_wchar_dtor,
959 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
961 SET(p_basic_istringstream_char_ctor_str,
962 "??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@"
963 "QAA@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z");
964 SET(p_basic_istringstream_char_dtor,
965 "??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAA@XZ");
966 SET(p_time_get_char_ctor,
967 "??_F?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAAXXZ");
968 SET(p_time_get_char_dtor,
969 "??1?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MAA@XZ");
970 #else
971 SET(p_basic_stringstream_char_ctor,
972 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
973 SET(p_basic_stringstream_char_ctor_str,
974 "??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");
975 SET(p_basic_stringstream_char_str_get,
976 "?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");
977 SET(p_basic_stringstream_char_vbase_dtor,
978 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
980 SET(p_basic_stringstream_wchar_ctor,
981 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
982 SET(p_basic_stringstream_wchar_ctor_str,
983 "??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");
984 SET(p_basic_stringstream_wchar_str_get,
985 "?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");
986 SET(p_basic_stringstream_wchar_vbase_dtor,
987 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
989 SET(p_basic_fstream_char_ctor_name,
990 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
991 SET(p_basic_fstream_char_vbase_dtor,
992 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
994 SET(p_basic_fstream_wchar_ctor_name,
995 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
996 SET(p_basic_fstream_wchar_vbase_dtor,
997 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
999 SET(p_basic_istream_char_read_uint64,
1000 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z");
1001 SET(p_basic_istream_char_read_float,
1002 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z");
1003 SET(p_basic_istream_char_read_double,
1004 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z");
1005 SET(p_basic_istream_char_read_str,
1006 "??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z");
1007 SET(p_basic_istream_char_read_complex_double,
1008 "??$?5NDU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$complex@N@0@@Z");
1009 SET(p_basic_istream_char_get,
1010 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
1011 SET(p_basic_istream_char_ipfx,
1012 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z");
1013 SET(p_basic_istream_char_ignore,
1014 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
1015 SET(p_basic_istream_char_seekg,
1016 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
1017 SET(p_basic_istream_char_seekg_fpos,
1018 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
1019 SET(p_basic_istream_char_peek,
1020 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
1021 SET(p_basic_istream_char_tellg,
1022 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ");
1023 SET(p_basic_istream_char_getline_bstr_delim,
1024 "??$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");
1026 SET(p_basic_istream_wchar_read_uint64,
1027 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z");
1028 SET(p_basic_istream_wchar_read_double,
1029 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z");
1030 SET(p_basic_istream_wchar_get,
1031 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
1032 SET(p_basic_istream_wchar_ipfx,
1033 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z");
1034 SET(p_basic_istream_wchar_ignore,
1035 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
1036 SET(p_basic_istream_wchar_seekg,
1037 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
1038 SET(p_basic_istream_wchar_seekg_fpos,
1039 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
1040 SET(p_basic_istream_wchar_peek,
1041 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
1042 SET(p_basic_istream_wchar_tellg,
1043 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ");
1044 SET(p_basic_istream_wchar_getline_bstr_delim,
1045 "??$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");
1047 SET(p_basic_ostream_char_print_float,
1048 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z");
1050 SET(p_basic_ostream_char_print_double,
1051 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z");
1053 SET(p_basic_ostream_wchar_print_double,
1054 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z");
1056 SET(p_basic_ostream_short_print_ushort,
1057 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@G@Z");
1059 SET(p_basic_ostream_char_print_complex_float,
1060 "??$?6MDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@M@0@@Z");
1062 SET(p_basic_ostream_char_print_complex_double,
1063 "??$?6NDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@N@0@@Z");
1065 SET(p_basic_ostream_char_print_complex_ldouble,
1066 "??$?6ODU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@O@0@@Z");
1068 SET(p_ios_base__Init,
1069 "?_Init@ios_base@std@@IAEXXZ");
1070 SET(p_ios_base_rdstate,
1071 "?rdstate@ios_base@std@@QBEHXZ");
1072 SET(p_ios_base_setf_mask,
1073 "?setf@ios_base@std@@QAEHHH@Z");
1074 SET(p_ios_base_unsetf,
1075 "?unsetf@ios_base@std@@QAEXH@Z");
1076 SET(p_ios_base_precision_set,
1077 "?precision@ios_base@std@@QAEHH@Z");
1079 SET(p_basic_ios_char_imbue,
1080 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
1081 SET(p_basic_ios_char_ctor,
1082 "??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ");
1083 SET(p_basic_ios_char_widen,
1084 "?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z");
1085 SET(p_basic_ios_char_dtor,
1086 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ");
1088 SET(p_basic_ios_wchar_imbue,
1089 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
1091 SET(p_locale_ctor_cstr,
1092 "??0locale@std@@QAE@PBDH@Z");
1093 SET(p_locale_dtor,
1094 "??1locale@std@@QAE@XZ");
1096 SET(p_basic_string_char_ctor_cstr,
1097 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
1098 SET(p_basic_string_char_cstr,
1099 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
1100 SET(p_basic_string_char_dtor,
1101 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
1103 SET(p_basic_string_wchar_ctor_cstr,
1104 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
1105 SET(p_basic_string_wchar_cstr,
1106 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
1107 SET(p_basic_string_wchar_dtor,
1108 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
1110 SET(p_basic_istringstream_char_ctor_str,
1111 "??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@"
1112 "QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z");
1113 SET(p_basic_istringstream_char_dtor,
1114 "??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
1115 SET(p_time_get_char_ctor,
1116 "??_F?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAEXXZ");
1117 SET(p_time_get_char_dtor,
1118 "??1?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MAE@XZ");
1119 #endif
1120 SET(p_time_get_char__Getint,
1121 "?_Getint@?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std"
1122 "@@ABAHAAV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@0HHAAH@Z");
1125 init_thiscall_thunk();
1126 return TRUE;
1129 /* convert a dll name A->W without depending on the current codepage */
1130 static wchar_t *AtoW( wchar_t *nameW, const char *nameA, unsigned int len )
1132 unsigned int i;
1134 for (i = 0; i < len; i++) nameW[i] = nameA[i];
1135 nameW[i] = 0;
1136 return nameW;
1139 static void test_num_get_get_uint64(void)
1141 unsigned short testus, nextus;
1142 basic_stringstream_wchar wss;
1143 basic_stringstream_char ss;
1144 basic_string_wchar wstr;
1145 basic_string_char str;
1146 IOSB_iostate state;
1147 locale lcl, retlcl;
1148 wchar_t wide[64];
1149 ULONGLONG val;
1150 int i, next;
1152 /* makes tables narrower */
1153 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1155 struct _test_num_get {
1156 const char *str;
1157 const char *lcl;
1158 IOSB_fmtflags fmtfl;
1159 IOSB_iostate state;
1160 ULONGLONG val;
1161 int next;
1162 } tests[] = {
1163 /* simple cases */
1164 { "0", NULL, FMTFLAG_dec, IOSTATE_eofbit, 0, EOF },
1165 { "1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
1166 { "+1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
1167 { "-1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, -1234567, EOF },
1168 { "", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF },
1170 /* different bases */
1171 /* (with and without zero are both tested, since 0 can signal a prefix check) */
1172 { "0x1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* lowercase x */
1173 { "0X1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* uppercase X */
1174 { "010", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
1175 { "010", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
1176 { "010", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
1177 { "10", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
1178 { "10", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
1179 { "10", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
1180 { "10", NULL, 0, IOSTATE_eofbit, 10, EOF }, /* discover dec */
1181 { "010", NULL, 0, IOSTATE_eofbit, 8, EOF }, /* discover oct */
1182 { "0xD", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (upper) */
1183 { "0xd", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (lower) */
1185 /* test grouping - default/"C" has no grouping, named English/German locales do */
1186 { "0.", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, '.' },
1187 { "0,", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
1188 { "0,", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with , */
1189 { "0.", "German", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with . */
1190 { "0,", "German", FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
1191 { ",0", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group at start */
1193 { "1,234,567", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* no grouping */
1194 { "1,234,567", "English", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with , */
1195 { "1.234.567", "German", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with . */
1196 { "1,,234", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* empty group */
1197 { "1,,234", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group */
1198 { "0x1,000,000", "English", FMTFLAG_hex, IOSTATE_eofbit, 16777216, EOF }, /* yeah, hex can group */
1199 { "1,23,34", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid size group */
1200 { "0,123", "English", FMTFLAG_dec, IOSTATE_eofbit, 123, EOF }, /* 0 solo in group */
1202 { "18446744073709551615", NULL, FMTFLAG_dec, IOSTATE_eofbit, ~0, EOF }, /* max value */
1203 { "99999999999999999999", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid value */
1205 /* test invalid formats */
1206 { "0000x10", NULL, FMTFLAG_hex, IOSTATE_goodbit, 0, 'x' },
1207 { "x10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
1208 { "0xx10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
1211 for(i=0; i<ARRAY_SIZE(tests); i++) {
1212 /* char version */
1213 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1214 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1216 if(tests[i].lcl) {
1217 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1218 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1221 val = 42;
1222 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
1223 call_func2(p_basic_istream_char_read_uint64, &ss.base.base1, &val);
1224 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1225 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1227 if(state==IOSTATE_faileof && tests[i].val==~0) {
1228 /* Maximal uint64 test is broken on 9.0.21022.8 */
1229 skip("basic_istream_char_read_uint64(MAX_UINT64) is broken\n");
1230 continue;
1233 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1234 ok(tests[i].val == val, "wrong val, expected = %s found %s\n", wine_dbgstr_longlong(tests[i].val),
1235 wine_dbgstr_longlong(val));
1236 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1238 if(tests[i].lcl)
1239 call_func1(p_locale_dtor, &lcl);
1241 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1242 call_func1(p_basic_string_char_dtor, &str);
1244 /* wchar_t version */
1245 AtoW(wide, tests[i].str, strlen(tests[i].str));
1246 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1247 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1249 if(tests[i].lcl) {
1250 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1251 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1254 val = 42;
1255 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
1256 call_func2(p_basic_istream_wchar_read_uint64, &wss.base.base1, &val);
1257 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1258 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1260 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1261 ok(tests[i].val == val, "wrong val, expected = %s found %s\n", wine_dbgstr_longlong(tests[i].val),
1262 wine_dbgstr_longlong(val));
1263 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1264 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1266 if(tests[i].lcl)
1267 call_func1(p_locale_dtor, &lcl);
1269 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1270 call_func1(p_basic_string_wchar_dtor, &wstr);
1275 static void test_num_get_get_double(void)
1277 unsigned short testus, nextus;
1278 basic_stringstream_wchar wss;
1279 basic_stringstream_char ss;
1280 basic_string_wchar wstr;
1281 basic_string_char str;
1282 IOSB_iostate state;
1283 locale lcl, retlcl;
1284 wchar_t wide[64];
1285 int i, next;
1286 double val;
1288 /* makes tables narrower */
1289 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1291 struct _test_num_get {
1292 const char *str;
1293 const char *lcl;
1294 IOSB_iostate state;
1295 double val;
1296 int next;
1297 } tests[] = {
1298 /* simple cases */
1299 { "0", NULL, IOSTATE_eofbit, 0.0, EOF },
1300 { "10", NULL, IOSTATE_eofbit, 10.0, EOF },
1301 { "+10", NULL, IOSTATE_eofbit, 10.0, EOF },
1302 { "-10", NULL, IOSTATE_eofbit, -10.0, EOF },
1303 { "+010", NULL, IOSTATE_eofbit, 10.0, EOF }, /* leading zero */
1305 /* test grouping - default/"C" has no grouping, named English/German locales do */
1306 { "1,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* with comma */
1307 { "1,000", "English", IOSTATE_eofbit, 1000.0, EOF },
1308 { "1,000", "German", IOSTATE_eofbit, 1.0, EOF },
1310 { "1.000", NULL, IOSTATE_eofbit, 1.0, EOF }, /* with period */
1311 { "1.000", "English", IOSTATE_eofbit, 1.0, EOF },
1312 { "1.000", "German", IOSTATE_eofbit, 1000.0, EOF },
1314 { "1,234.", NULL, IOSTATE_goodbit, 1.0, ',' },
1315 { "1,234.", "English", IOSTATE_eofbit, 1234.0, EOF }, /* trailing decimal */
1316 { "1,234.", "German", IOSTATE_goodbit, 1.234, '.' },
1317 { "1,234.5", "English", IOSTATE_eofbit, 1234.5, EOF }, /* group + decimal */
1318 { "1,234.5", "German", IOSTATE_goodbit, 1.234, '.' },
1320 { "1,234,567,890", NULL, IOSTATE_goodbit, 1.0, ',' }, /* more groups */
1321 { "1,234,567,890", "English", IOSTATE_eofbit, 1234567890.0, EOF },
1322 { "1,234,567,890", "German", IOSTATE_goodbit, 1.234, ',' },
1323 { "1.234.567.890", "German", IOSTATE_eofbit, 1234567890.0, EOF },
1325 /* extra digits and stuff */
1326 { "00000.123456", NULL, IOSTATE_eofbit, 0.123456, EOF },
1327 { "0.1234560000", NULL, IOSTATE_eofbit, 0.123456, EOF },
1328 { "100aaaa", NULL, IOSTATE_goodbit, 100.0, 'a' },
1330 /* exponent */
1331 { "10e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* lowercase e */
1332 { "10E10", NULL, IOSTATE_eofbit, 10E10, EOF }, /* uppercase E */
1333 { "10e+10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* sign */
1334 { "10e-10", NULL, IOSTATE_eofbit, 10e-10, EOF },
1335 { "10.e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* trailing decimal before exponent */
1336 { "-10.e-10", NULL, IOSTATE_eofbit, -10e-10, EOF },
1337 { "-12.345e-10", NULL, IOSTATE_eofbit, -12.345e-10, EOF },
1338 { "1,234e10", NULL, IOSTATE_goodbit, 1.0, ',' },
1339 { "1,234e10", "English", IOSTATE_eofbit, 1234.0e10, EOF },
1340 { "1,234e10", "German", IOSTATE_eofbit, 1.234e10, EOF },
1341 { "1.0e999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too big */
1342 { "1.0e-999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too small */
1344 /* bad form */
1345 { "1,000,", NULL, IOSTATE_goodbit, 1.0, ',' }, /* trailing group */
1346 { "1,000,", "English", IOSTATE_faileof, 42.0, EOF },
1347 { "1.000.", "German", IOSTATE_faileof, 42.0, EOF },
1349 { "1,,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* empty group */
1350 { "1,,000", "English", IOSTATE_failbit, 42.0, EOF },
1351 { "1..000", "German", IOSTATE_failbit, 42.0, EOF },
1353 { "1.0,00", "English", IOSTATE_goodbit, 1.0, ',' },
1354 { "1.0,00", "German", IOSTATE_faileof, 42.0, EOF },
1356 { "1.0ee10", NULL, IOSTATE_failbit, 42.0, EOF }, /* dup exp */
1357 { "1.0e1.0", NULL, IOSTATE_goodbit, 10.0, '.' }, /* decimal in exponent */
1358 { "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
1361 for(i=0; i<ARRAY_SIZE(tests); i++) {
1362 /* char version */
1363 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1364 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1366 if(tests[i].lcl) {
1367 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1368 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1371 val = 42.0;
1372 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
1373 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1374 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1376 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1377 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1378 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1380 if(tests[i].lcl)
1381 call_func1(p_locale_dtor, &lcl);
1383 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1384 call_func1(p_basic_string_char_dtor, &str);
1386 /* wchar_t version */
1387 AtoW(wide, tests[i].str, strlen(tests[i].str));
1388 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1389 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1391 if(tests[i].lcl) {
1392 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1393 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1396 val = 42.0;
1397 call_func2(p_basic_istream_wchar_read_double, &wss.base.base1, &val);
1398 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1399 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1401 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1402 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1403 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1404 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1406 if(tests[i].lcl)
1407 call_func1(p_locale_dtor, &lcl);
1409 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1410 call_func1(p_basic_string_wchar_dtor, &wstr);
1415 static void test_num_put_put_double(void)
1417 basic_stringstream_wchar wss;
1418 basic_stringstream_char ss;
1419 basic_string_wchar pwstr;
1420 basic_string_char pstr;
1421 locale lcl, retlcl;
1422 const wchar_t *wstr;
1423 const char *str;
1424 wchar_t wide[64];
1425 int i;
1427 struct _test_num_get {
1428 double val;
1429 const char *lcl;
1430 streamsize prec; /* set to -1 for default */
1431 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
1432 const char *str;
1433 } tests[] = {
1434 { 0.0, NULL, -1, 0, "0" },
1436 /* simple cases */
1437 { 0.123, NULL, -1, 0, "0.123" },
1438 { 0.123, NULL, 6, 0, "0.123" },
1439 { 0.123, NULL, 0, 0, "0.123" },
1441 /* fixed format */
1442 { 0.123, NULL, -1, FMTFLAG_fixed, "0.123000" },
1443 { 0.123, NULL, 6, FMTFLAG_fixed, "0.123000" },
1444 { 0.123, NULL, 0, FMTFLAG_fixed, "0" },
1446 /* scientific format */
1447 { 123456.789, NULL, -1, FMTFLAG_scientific, "1.234568e+005" },
1448 { 123456.789, NULL, 0, FMTFLAG_scientific, "1.234568e+005" },
1449 { 123456.789, NULL, 9, FMTFLAG_scientific, "1.234567890e+005" },
1450 { 123456.789, "German", 9, FMTFLAG_scientific, "1,234567890e+005" },
1452 /* different locales */
1453 { 0.123, "C", -1, 0, "0.123" },
1454 { 0.123, "English", -1, 0, "0.123" },
1455 { 0.123, "German", -1, 0, "0,123" },
1457 { 123456.789, "C", -1, 0, "123457" },
1458 { 123456.789, "English", -1, 0, "123,457" },
1459 { 123456.789, "German", -1, 0, "123.457" },
1461 /* signs and exponents */
1462 { 1.0e-9, NULL, -1, 0, "1e-009" },
1463 { 1.0e-9, NULL, 9, 0, "1e-009" },
1464 { -1.0e9, NULL, -1, 0, "-1e+009" },
1465 { -1.0e9, NULL, 9, 0, "-1e+009" },
1467 { 1.0e-9, NULL, 0, FMTFLAG_fixed, "0" },
1468 { 1.0e-9, NULL, 6, FMTFLAG_fixed, "0.000000" },
1469 { 1.0e-9, NULL, 9, FMTFLAG_fixed, "0.000000001" },
1470 { -1.0e9, NULL, 0, FMTFLAG_fixed, "-1000000000" },
1471 { -1.0e9, NULL, 6, FMTFLAG_fixed, "-1000000000.000000" },
1473 { -1.23456789e9, NULL, 0, 0, "-1.23457e+009" },
1474 { -1.23456789e9, NULL, 0, FMTFLAG_fixed, "-1234567890" },
1475 { -1.23456789e9, NULL, 6, FMTFLAG_fixed, "-1234567890.000000" },
1476 { -1.23456789e-9, NULL, 6, FMTFLAG_fixed, "-0.000000" },
1477 { -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
1480 for(i=0; i<ARRAY_SIZE(tests); i++) {
1481 /* char version */
1482 call_func1(p_basic_stringstream_char_ctor, &ss);
1484 if(tests[i].lcl) {
1485 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1486 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1489 /* set format and precision only if specified, so we can try defaults */
1490 if(tests[i].fmtfl)
1491 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1492 if(tests[i].prec != -1)
1493 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
1494 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, tests[i].val);
1496 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
1497 str = call_func1(p_basic_string_char_cstr, &pstr);
1499 ok(!strcmp(tests[i].str, str), "wrong output, expected = %s found = %s\n", tests[i].str, str);
1500 call_func1(p_basic_string_char_dtor, &pstr);
1502 if(tests[i].lcl)
1503 call_func1(p_locale_dtor, &lcl);
1505 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1507 /* wchar_t version */
1508 call_func1(p_basic_stringstream_wchar_ctor, &wss);
1510 if(tests[i].lcl) {
1511 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1512 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1515 /* set format and precision only if specified, so we can try defaults */
1516 if(tests[i].fmtfl)
1517 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1518 if(tests[i].prec != -1)
1519 call_func2(p_ios_base_precision_set, &wss.basic_ios.base, tests[i].prec);
1520 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, tests[i].val);
1522 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
1523 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
1525 AtoW(wide, tests[i].str, strlen(tests[i].str));
1526 ok(!lstrcmpW(wide, wstr), "wrong output, expected = %s found = %s\n", tests[i].str, wine_dbgstr_w(wstr));
1527 call_func1(p_basic_string_wchar_dtor, &pwstr);
1529 if(tests[i].lcl)
1530 call_func1(p_locale_dtor, &lcl);
1532 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1537 static void test_istream_ipfx(void)
1539 unsigned short testus, nextus;
1540 basic_stringstream_wchar wss;
1541 basic_stringstream_char ss;
1542 basic_string_wchar wstr;
1543 basic_string_char str;
1544 IOSB_iostate state;
1545 wchar_t wide[64];
1546 int i, next;
1547 MSVCP_bool ret;
1549 /* makes tables narrower */
1550 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1552 struct _test_istream_ipfx {
1553 const char *str;
1554 int unset_skipws;
1555 int noskip;
1556 MSVCP_bool ret;
1557 IOSB_iostate state;
1558 int next;
1559 } tests[] = {
1560 /* string unset noskip return state next char */
1561 { "", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* empty string */
1562 { " ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* just ws */
1563 { "\t \n \f ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* different ws */
1564 { "simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1565 { " simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1566 { " simple", TRUE, FALSE, TRUE, IOSTATE_goodbit, ' ' }, /* unset skipws */
1567 { " simple", FALSE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* ipfx(true) */
1568 { " simple", TRUE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* both */
1569 { "\n\t ws", FALSE, FALSE, TRUE, IOSTATE_goodbit, 'w' },
1570 { "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
1573 for(i=0; i<ARRAY_SIZE(tests); i++) {
1574 /* char version */
1575 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1576 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1578 /* set format and precision only if specified, so we can try defaults */
1579 if(tests[i].unset_skipws)
1580 call_func2(p_ios_base_unsetf, &ss.basic_ios.base, TRUE);
1582 ret = (MSVCP_bool)(INT_PTR)call_func2(p_basic_istream_char_ipfx, &ss.base.base1, tests[i].noskip);
1583 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1584 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1586 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1587 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1588 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1590 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1591 call_func1(p_basic_string_char_dtor, &str);
1593 /* wchar_t version */
1594 AtoW(wide, tests[i].str, strlen(tests[i].str));
1595 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1596 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1598 /* set format and precision only if specified, so we can try defaults */
1599 if(tests[i].unset_skipws)
1600 call_func2(p_ios_base_unsetf, &wss.basic_ios.base, TRUE);
1602 ret = (MSVCP_bool)(INT_PTR)call_func2(p_basic_istream_wchar_ipfx, &wss.base.base1, tests[i].noskip);
1603 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1604 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1606 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1607 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1608 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1609 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1611 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1612 call_func1(p_basic_string_wchar_dtor, &wstr);
1617 static void test_istream_ignore(void)
1619 unsigned short testus, nextus;
1620 basic_stringstream_wchar wss;
1621 basic_stringstream_char ss;
1622 basic_string_wchar wstr;
1623 basic_string_char str;
1624 IOSB_iostate state;
1625 wchar_t wide[64];
1626 int i, next;
1628 struct _test_istream_ignore {
1629 const char *str;
1630 streamsize count;
1631 int delim;
1632 IOSB_iostate state;
1633 int next;
1634 } tests[] = {
1635 /* string count delim state next */
1636 { "", 0, '\n', IOSTATE_goodbit, EOF }, /* empty string */
1638 /* different counts */
1639 { "ABCDEF", 2, '\n', IOSTATE_goodbit, 'C' }, /* easy case */
1640 { "ABCDEF", 42, '\n', IOSTATE_eofbit, EOF }, /* ignore too much */
1641 { "ABCDEF", -2, '\n', IOSTATE_goodbit, 'A' }, /* negative count */
1642 { "ABCDEF", 6, '\n', IOSTATE_goodbit, EOF }, /* is eof not set at end */
1643 { "ABCDEF", 7, '\n', IOSTATE_eofbit, EOF }, /* eof is set just after end */
1645 /* different delimiters */
1646 { "ABCDEF", 42, '\0', IOSTATE_eofbit, EOF }, /* null as delim */
1647 { "ABC DEF GHI", 0, ' ', IOSTATE_goodbit, 'A' },
1648 { "ABC DEF GHI", 42, ' ', IOSTATE_goodbit, 'D' },
1649 { "ABC DEF\tGHI", 42, '\t', IOSTATE_goodbit, 'G' },
1650 { "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
1653 for(i=0; i<ARRAY_SIZE(tests); i++) {
1654 /* char version */
1655 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1656 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1658 call_func3(p_basic_istream_char_ignore, &ss.base.base1, tests[i].count, tests[i].delim);
1659 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1660 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1662 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1663 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1665 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1666 call_func1(p_basic_string_char_dtor, &str);
1668 /* wchar_t version */
1669 AtoW(wide, tests[i].str, strlen(tests[i].str));
1670 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1671 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1673 call_func3(p_basic_istream_wchar_ignore, &wss.base.base1, tests[i].count, tests[i].delim);
1674 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1675 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1677 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1678 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1679 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1681 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1682 call_func1(p_basic_string_wchar_dtor, &wstr);
1687 static void test_istream_seekg(void)
1689 unsigned short testus, nextus;
1690 basic_stringstream_wchar wss;
1691 basic_stringstream_char ss;
1692 basic_string_wchar wstr;
1693 basic_string_char str;
1694 IOSB_iostate state;
1695 wchar_t wide[64];
1696 int i, next;
1698 struct _test_istream_seekg {
1699 const char *str;
1700 streamoff off;
1701 IOSB_seekdir dir;
1702 IOSB_iostate state;
1703 int next;
1704 } tests[] = {
1705 { "ABCDEFGHIJ", 0, SEEKDIR_beg, IOSTATE_goodbit, 'A' },
1706 { "ABCDEFGHIJ", 1, SEEKDIR_beg, IOSTATE_goodbit, 'B' },
1707 { "ABCDEFGHIJ", 5, SEEKDIR_cur, IOSTATE_goodbit, 'F' },
1708 { "ABCDEFGHIJ", -3, SEEKDIR_end, IOSTATE_goodbit, 'H' },
1710 /* bad offsets */
1711 { "ABCDEFGHIJ", -1, SEEKDIR_beg, IOSTATE_failbit, EOF },
1712 { "ABCDEFGHIJ", 42, SEEKDIR_cur, IOSTATE_failbit, EOF },
1713 { "ABCDEFGHIJ", 42, SEEKDIR_end, IOSTATE_failbit, EOF },
1714 { "", 0, SEEKDIR_beg, IOSTATE_failbit, EOF },
1717 for(i=0; i<ARRAY_SIZE(tests); i++) {
1718 /* char version */
1719 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1720 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1722 call_func3(p_basic_istream_char_seekg, &ss.base.base1, tests[i].off, tests[i].dir);
1723 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1724 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1726 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1727 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1729 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1730 call_func1(p_basic_string_char_dtor, &str);
1732 /* wchar_t version */
1733 AtoW(wide, tests[i].str, strlen(tests[i].str));
1734 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1735 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1737 call_func3(p_basic_istream_wchar_seekg, &wss.base.base1, tests[i].off, tests[i].dir);
1738 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1739 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1741 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1742 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1743 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1745 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1746 call_func1(p_basic_string_wchar_dtor, &wstr);
1751 static void test_istream_seekg_fpos(void)
1753 unsigned short testus, nextus;
1754 basic_stringstream_wchar wss;
1755 basic_stringstream_char ss;
1756 basic_string_wchar wstr;
1757 basic_string_char str;
1758 IOSB_iostate state;
1759 wchar_t wide[64];
1760 fpos_int pos;
1761 int i, next;
1763 struct _test_istream_seekg_fpos {
1764 const char *str;
1765 streamoff off;
1766 IOSB_iostate state;
1767 int next;
1768 } tests[] = {
1769 { "ABCDEFGHIJ", 0, IOSTATE_goodbit, 'A' },
1770 { "ABCDEFGHIJ", 9, IOSTATE_goodbit, 'J' },
1771 { "ABCDEFGHIJ", 10, IOSTATE_goodbit, EOF }, /* beyond end, but still good */
1772 { "ABCDEFGHIJ", -1, IOSTATE_failbit, EOF },
1773 { "", 0, IOSTATE_failbit, EOF },
1776 for(i=0; i<ARRAY_SIZE(tests); i++) {
1777 /* char version */
1778 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1779 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1781 pos.off = tests[i].off;
1782 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1783 pos.state = 0;
1784 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, pos);
1785 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1786 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1788 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1789 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1791 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1792 call_func1(p_basic_string_char_dtor, &str);
1794 /* wchar_t version */
1795 AtoW(wide, tests[i].str, strlen(tests[i].str));
1796 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1797 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1799 pos.off = tests[i].off;
1800 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1801 pos.state = 0;
1802 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, pos);
1803 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1804 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1806 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1807 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1808 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1810 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1811 call_func1(p_basic_string_wchar_dtor, &wstr);
1816 static void test_istream_peek(void)
1818 unsigned short testus, nextus, peekus;
1819 basic_stringstream_wchar wss;
1820 basic_stringstream_char ss;
1821 basic_string_wchar wstr;
1822 basic_string_char str;
1823 IOSB_iostate state;
1824 int i, next, peek;
1825 wchar_t wide[64];
1827 struct _test_istream_peek {
1828 const char *str;
1829 int peek;
1830 int next;
1831 IOSB_iostate state;
1832 } tests[] = {
1833 { "", EOF, EOF, IOSTATE_eofbit },
1834 { "ABCDEF", 'A', 'A', IOSTATE_goodbit },
1837 for(i=0; i<ARRAY_SIZE(tests); i++) {
1838 /* char version */
1839 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1840 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1842 peek = (int)call_func1(p_basic_istream_char_peek, &ss.base.base1);
1843 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1844 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1846 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1847 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1848 ok(peek == next, "wrong peek, expected %c (%i) found = %c (%i)\n", peek, peek, next, next);
1850 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1851 call_func1(p_basic_string_char_dtor, &str);
1853 /* wchar_t version */
1854 AtoW(wide, tests[i].str, strlen(tests[i].str));
1855 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1856 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1858 peekus = (unsigned short)(int)call_func1(p_basic_istream_wchar_peek, &wss.base.base1);
1859 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1860 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1862 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1863 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1864 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1865 ok(peekus == nextus, "wrong peek, expected %c (%i) found = %c (%i)\n", peekus, peekus, nextus, nextus);
1867 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1868 call_func1(p_basic_string_wchar_dtor, &wstr);
1873 static void test_istream_tellg(void)
1875 basic_stringstream_wchar wss;
1876 basic_stringstream_char ss;
1877 basic_fstream_wchar wfs;
1878 basic_fstream_char fs;
1879 basic_string_wchar wstr;
1880 basic_string_char str;
1881 fpos_int spos, tpos, *rpos;
1882 wchar_t wide[64];
1883 FILE *file;
1884 int i;
1886 const char *testfile = "file.txt";
1888 struct _test_istream_tellg_fpos {
1889 const char *str;
1890 streamoff seekoff;
1891 streamoff telloff_ss; /* offset for stringstream */
1892 streamoff telloff_fs; /* offset for fstream */
1893 __int64 tellpos;
1894 } tests[] = {
1895 /* empty strings */
1896 { "", -1, -1, 0, 0 }, /* tellg on defaults */
1897 { "", 0, -1, 0, 0 }, /* tellg after seek 0 */
1898 { "", 42, -1, 0, 42 }, /* tellg after seek beyond end */
1899 { "", -6, -1, -1, 0 }, /* tellg after seek beyond beg */
1901 /* non-empty strings */
1902 { "ABCDEFGHIJ", -1, 0, 0, 0 },
1903 { "ABCDEFGHIJ", 3, 3, 0, 3 },
1904 { "ABCDEFGHIJ", 42, -1, 0, 42 },
1905 { "ABCDEFGHIJ", -6, -1, -1, 0 }
1908 for(i=0; i<ARRAY_SIZE(tests); i++) {
1909 /* stringstream<char> version */
1910 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1911 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1913 spos.off = tests[i].seekoff;
1914 spos.pos = 0;
1915 spos.state = 0;
1917 tpos.off = 0xdeadbeef;
1918 tpos.pos = 0xdeadbeef;
1919 tpos.state = 0xdeadbeef;
1921 if (tests[i].seekoff != -1) /* to test without seek */
1922 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, spos);
1923 rpos = call_func2(p_basic_istream_char_tellg, &ss.base.base1, &tpos);
1925 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1926 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1927 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1928 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1929 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", wine_dbgstr_longlong(tpos.pos));
1930 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1931 if(tests[i].seekoff == -1) {
1932 ok(ss.basic_ios.base.state == IOSTATE_goodbit,
1933 "ss.basic_ios.base.state = %x\n", ss.basic_ios.base.state);
1936 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1937 call_func1(p_basic_string_char_dtor, &str);
1939 /* stringstream<wchar_t> version */
1940 AtoW(wide, tests[i].str, strlen(tests[i].str));
1941 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1942 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1944 spos.off = tests[i].seekoff;
1945 spos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1946 spos.state = 0;
1948 tpos.off = 0xdeadbeef;
1949 tpos.pos = 0xdeadbeef;
1950 tpos.state = 0xdeadbeef;
1952 if (tests[i].seekoff != -1) /* to test without seek */
1953 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, spos);
1954 rpos = call_func2(p_basic_istream_wchar_tellg, &wss.base.base1, &tpos);
1956 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1957 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1958 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1959 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1960 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", wine_dbgstr_longlong(tpos.pos));
1961 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1962 if(tests[i].seekoff == -1) {
1963 ok(ss.basic_ios.base.state == IOSTATE_goodbit,
1964 "ss.basic_ios.base.state = %x\n", ss.basic_ios.base.state);
1967 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1968 call_func1(p_basic_string_wchar_dtor, &wstr);
1970 /* filebuf */
1971 file = fopen(testfile, "wt");
1972 fprintf(file, "%s", tests[i].str);
1973 fclose(file);
1975 /* fstream<char> version */
1976 call_func5(p_basic_fstream_char_ctor_name, &fs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1978 spos.off = tests[i].seekoff;
1979 spos.pos = 0;
1980 spos.state = 0;
1982 tpos.off = 0xdeadbeef;
1983 tpos.pos = 0xdeadbeef;
1984 tpos.state = 0xdeadbeef;
1986 if (tests[i].seekoff != -1) /* to test without seek */
1987 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &fs.base.base1, spos);
1988 rpos = call_func2(p_basic_istream_char_tellg, &fs.base.base1, &tpos);
1990 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1991 wine_dbgstr_longlong(tests[i].tellpos), wine_dbgstr_longlong(tpos.pos));
1992 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1993 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1994 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1996 call_func1(p_basic_fstream_char_vbase_dtor, &fs);
1998 /* fstream<wchar_t> version */
1999 call_func5(p_basic_fstream_wchar_ctor_name, &wfs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
2001 spos.off = tests[i].seekoff;
2002 spos.pos = 0;
2003 spos.state = 0;
2005 tpos.off = 0xdeadbeef;
2006 tpos.pos = 0xdeadbeef;
2007 tpos.state = 0xdeadbeef;
2009 if (tests[i].seekoff != -1) /* to test without seek */
2010 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wfs.base.base1, spos);
2011 rpos = call_func2(p_basic_istream_wchar_tellg, &wfs.base.base1, &tpos);
2013 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
2014 wine_dbgstr_longlong(tests[i].tellpos), wine_dbgstr_longlong(tpos.pos));
2015 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
2016 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
2017 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
2019 call_func1(p_basic_fstream_wchar_vbase_dtor, &wfs);
2021 unlink(testfile);
2026 static void test_istream_getline(void)
2028 basic_stringstream_wchar wss;
2029 basic_stringstream_char ss;
2030 basic_string_wchar wstr;
2031 basic_string_char str;
2032 IOSB_iostate state;
2033 wchar_t wide[64];
2034 int i;
2035 const char *cstr;
2036 const wchar_t *wcstr;
2038 /* makes tables narrower */
2039 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
2041 struct _test_istream_getline {
2042 const char *str;
2043 const char *line;
2044 int delim;
2045 IOSB_iostate state;
2046 const char *nextline;
2047 int nextdelim;
2048 IOSB_iostate nextstate;
2049 } tests[] = {
2050 { "", "", '\n', IOSTATE_faileof, "", '\n', IOSTATE_faileof },
2052 { "this\n", "this", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
2053 { "this\nis\nsome\ntext\n", "this", '\n', IOSTATE_goodbit, "is", '\n', IOSTATE_goodbit },
2055 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is", ' ', IOSTATE_goodbit },
2056 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is some text", '\n', IOSTATE_goodbit },
2058 { "this is some text\n", "this is some text", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
2059 { "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit, "this is some text\n", '\n', IOSTATE_faileof },
2062 for(i=0; i<ARRAY_SIZE(tests); i++) {
2063 /* char version */
2064 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
2065 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
2067 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].delim);
2068 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
2069 cstr = call_func1(p_basic_string_char_cstr, &str);
2071 ok(!strcmp(tests[i].line, cstr), "wrong line, expected = %s found = %s\n", tests[i].line, cstr);
2072 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
2074 /* next line */
2075 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].nextdelim);
2076 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
2077 cstr = call_func1(p_basic_string_char_cstr, &str);
2079 ok(!strcmp(tests[i].nextline, cstr), "wrong next line, expected = %s found = %s\n", tests[i].nextline, cstr);
2080 ok(tests[i].nextstate == state, "wrong next state, expected = %x found = %x\n", tests[i].nextstate, state);
2082 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2083 call_func1(p_basic_string_char_dtor, &str);
2085 /* wchar_t version */
2086 AtoW(wide, tests[i].str, strlen(tests[i].str));
2087 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
2088 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
2090 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].delim);
2091 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
2092 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
2094 AtoW(wide, tests[i].line, strlen(tests[i].line));
2095 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].line, wine_dbgstr_w(wcstr));
2096 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
2098 /* next line */
2099 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].nextdelim);
2100 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
2101 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
2103 AtoW(wide, tests[i].nextline, strlen(tests[i].nextline));
2104 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].nextline, wine_dbgstr_w(wcstr));
2105 ok(tests[i].nextstate == state, "wrong state, expected = %x found = %x\n", tests[i].nextstate, state);
2107 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2108 call_func1(p_basic_string_wchar_dtor, &wstr);
2112 static void test_ostream_print_ushort(void)
2114 basic_stringstream_wchar wss;
2115 basic_string_wchar pwstr;
2116 const wchar_t *wstr;
2118 call_func1(p_basic_stringstream_wchar_ctor, &wss);
2119 call_func2(p_basic_ostream_short_print_ushort, &wss.base.base2, 65);
2121 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
2122 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
2123 ok(!lstrcmpW(L"65", wstr), "wstr = %s\n", wine_dbgstr_w(wstr));
2125 call_func1(p_basic_string_wchar_dtor, &pwstr);
2126 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2129 static void test_ostream_print_float(void)
2131 basic_stringstream_char ss;
2132 basic_string_char pstr;
2133 const char *str;
2134 float val;
2135 val = 3.14159;
2137 call_func1(p_basic_stringstream_char_ctor, &ss);
2138 call_func2_ptr_flt(p_basic_ostream_char_print_float, &ss.base.base2, val);
2139 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2140 str = call_func1(p_basic_string_char_cstr, &pstr);
2141 ok(!strcmp("3.14159", str), "str = %s\n", str);
2143 call_func1(p_basic_string_char_dtor, &pstr);
2144 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2147 static void test_ostream_print_double(void)
2149 basic_stringstream_char ss;
2150 basic_string_char pstr;
2151 const char *str;
2152 double val;
2153 val = 3.14159;
2155 call_func1(p_basic_stringstream_char_ctor, &ss);
2156 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, val);
2157 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2158 str = call_func1(p_basic_string_char_cstr, &pstr);
2159 ok(!strcmp("3.14159", str), "str = %s\n", str);
2161 call_func1(p_basic_string_char_dtor, &pstr);
2162 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2165 static void test_ostream_wchar_print_double(void)
2167 basic_stringstream_wchar wss;
2168 basic_string_wchar pwstr;
2169 const wchar_t *wstr;
2170 double val;
2171 val = 3.14159;
2173 call_func1(p_basic_stringstream_wchar_ctor, &wss);
2174 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, val);
2176 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
2177 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
2179 ok(!lstrcmpW(L"3.14159", wstr), "wstr = %s\n", wine_dbgstr_w(wstr));
2180 call_func1(p_basic_string_wchar_dtor, &pwstr);
2181 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2184 static void test_istream_read_float(void)
2186 basic_stringstream_char ss;
2187 basic_string_char str;
2188 const char *test_str;
2189 float val, correct_val;
2191 test_str = "3.14159";
2192 call_func2(p_basic_string_char_ctor_cstr, &str, test_str);
2193 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_in, TRUE);
2195 val = 0;
2196 call_func2(p_basic_istream_char_read_float, &ss.base.base1, &val);
2197 correct_val = 3.14159;
2198 ok(correct_val == val, "wrong val, expected = %g found %g\n", correct_val, val);
2200 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2201 call_func1(p_basic_string_char_dtor, &str);
2204 static void test_istream_read_double(void)
2206 basic_stringstream_char ss;
2207 basic_string_char str;
2208 const char *test_str;
2209 double val, correct_val;
2211 test_str = "3.14159";
2212 call_func2(p_basic_string_char_ctor_cstr, &str, test_str);
2213 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_in, TRUE);
2215 val = 0;
2216 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
2217 correct_val = 3.14159;
2218 ok(correct_val == val, "wrong val, expected = %g found %g\n", correct_val, val);
2220 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2221 call_func1(p_basic_string_char_dtor, &str);
2224 static void test_ostream_print_complex_float(void)
2226 basic_stringstream_char ss;
2227 basic_string_char pstr;
2228 const char *str;
2229 locale lcl, retlcl;
2230 int i;
2231 struct _test_print_complex_float {
2232 complex_float val;
2233 const char *lcl;
2234 streamsize prec; /* set to -1 for default */
2235 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
2236 const char *str;
2237 } tests[] = {
2238 /* simple cases */
2239 { {0.123,-4.5}, NULL, -1, 0, "(0.123,-4.5)" },
2240 { {0.123,-4.5}, NULL, 6, 0, "(0.123,-4.5)" },
2241 { {0.123,-4.5}, NULL, 0, 0, "(0.123,-4.5)" },
2243 /*{ fixed format */
2244 { {0.123,-4.6}, NULL, 0, FMTFLAG_fixed, "(0,-5)" },
2245 { {0.123,-4.6}, NULL, -1, FMTFLAG_fixed, "(0.123000,-4.600000)" },
2246 { {0.123,-4.6}, NULL, 6, FMTFLAG_fixed, "(0.123000,-4.600000)" },
2248 /*{ scientific format */
2249 { {123456.789,-4.5678}, NULL, -1, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" },
2250 { {123456.789,-4.5678}, NULL, 0, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" },
2251 { {123456.789,-4.5678}, NULL, 9, FMTFLAG_scientific, "(1.234567891e+005,-4.567800045e+000)" },
2252 { {123456.789,-4.5678}, "German", 9, FMTFLAG_scientific, "(1,234567891e+005,-4,567800045e+000)" },
2254 /*{ different locales */
2255 { {0.123,-4.5}, "C", -1, 0, "(0.123,-4.5)" },
2256 { {0.123,-4.5}, "English", -1, 0, "(0.123,-4.5)" },
2257 { {0.123,-4.5}, "German", -1, 0, "(0,123,-4,5)" },
2259 { {123456.789,-4.5678}, "C", -1, 0, "(123457,-4.5678)" },
2260 { {123456.789,-4.5678}, "English", -1, 0, "(123,457,-4.5678)" },
2261 { {123456.789,-4.5678}, "German", -1, 0, "(123.457,-4,5678)" },
2263 /*{ signs and exponents */
2264 { { 1.0e-9,-4.1e-3}, NULL, -1, 0, "(1e-009,-0.0041)" },
2265 { { 1.0e-9,-4.1e-3}, NULL, 9, 0, "(9.99999972e-010,-0.00410000002)" },
2266 { {-1.0e9,-4.1e-3}, NULL, -1, 0, "(-1e+009,-0.0041)" },
2267 { {-1.0e9,-4.1e-3}, NULL, 9, 0, "(-1e+009,-0.00410000002)" },
2269 { { 1.0e-9,0}, NULL, 0, FMTFLAG_fixed, "(0,0)" },
2270 { { 1.0e-9,0}, NULL, 6, FMTFLAG_fixed, "(0.000000,0.000000)" },
2271 { { 1.0e-9,0}, NULL, 9, FMTFLAG_fixed, "(0.000000001,0.000000000)" },
2272 { {-1.0e9, 0}, NULL, 0, FMTFLAG_fixed, "(-1000000000,0)" },
2273 { {-1.0e9, 0}, NULL, 6, FMTFLAG_fixed, "(-1000000000.000000,0.000000)" },
2275 { {-1.23456789e9,2.3456789e9}, NULL, 0, 0, "(-1.23457e+009,2.34568e+009)" },
2276 { {-1.23456789e9,2.3456789e9}, NULL, 0, FMTFLAG_fixed, "(-1234567936,2345678848)" },
2277 { {-1.23456789e9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-1234567936.000000,2345678848.000000)" },
2278 { {-1.23456789e-9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-0.000000,2345678848.000000)" },
2279 { {-1.23456789e-9,2.3456789e9}, NULL, 9, FMTFLAG_fixed, "(-0.000000001,2345678848.000000000)" }
2282 for(i=0; i<ARRAY_SIZE(tests); i++) {
2283 call_func1(p_basic_stringstream_char_ctor, &ss);
2285 if(tests[i].lcl) {
2286 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
2287 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
2290 /* set format and precision only if specified, so we can try defaults */
2291 if(tests[i].fmtfl)
2292 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
2293 if(tests[i].prec != -1)
2294 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
2295 p_basic_ostream_char_print_complex_float(&ss.base.base2, &tests[i].val);
2297 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2298 str = call_func1(p_basic_string_char_cstr, &pstr);
2299 ok(!strcmp(str, tests[i].str), "test %d fail, str = %s\n", i+1, str);
2300 call_func1(p_basic_string_char_dtor, &pstr);
2301 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2305 static void test_ostream_print_complex_double(void)
2307 static const char complex_double_str[] = "(3.14159,1.23459)";
2309 basic_stringstream_char ss;
2310 basic_string_char pstr;
2311 const char *str;
2312 complex_double val= {3.14159, 1.23459};
2314 call_func1(p_basic_stringstream_char_ctor, &ss);
2315 p_basic_ostream_char_print_complex_double(&ss.base.base2, &val);
2317 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2318 str = call_func1(p_basic_string_char_cstr, &pstr);
2319 ok(!strcmp(complex_double_str, str), "str = %s\n", str);
2321 call_func1(p_basic_string_char_dtor, &pstr);
2322 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2325 static void test_ostream_print_complex_ldouble(void)
2327 static const char complex_double_str[] = "(3.14159,1.23459)";
2329 basic_stringstream_char ss;
2330 basic_string_char pstr;
2331 const char *str;
2332 complex_double val = {3.14159, 1.23459};
2334 call_func1(p_basic_stringstream_char_ctor, &ss);
2335 p_basic_ostream_char_print_complex_ldouble(&ss.base.base2, &val);
2337 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2338 str = call_func1(p_basic_string_char_cstr, &pstr);
2339 ok(!strcmp(complex_double_str, str), "str = %s\n", str);
2341 call_func1(p_basic_string_char_dtor, &pstr);
2342 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2345 static void test_istream_read_complex_double(void)
2347 basic_string_char str;
2348 IOSB_iostate state;
2349 complex_double val;
2350 locale lcl, retlcl;
2351 basic_stringstream_char ss;
2352 int i;
2353 char next[100];
2354 const char deadbeef_str[] = "(3.14159,3456.7890)";
2355 const complex_double deadbeef = {3.14159, 3456.7890};
2356 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
2358 struct _test_istream_read_complex_double {
2359 const char *complex_double_str;
2360 const char *lcl;
2361 complex_double correct_val;
2362 IOSB_iostate state;
2363 const char *str;
2364 } tests[] = {
2365 /* supported format: real */
2366 { "-12 3", NULL, {-12 , 0}, IOSTATE_goodbit, "3"},
2367 { "1e2,3", NULL, {100 , 0}, IOSTATE_goodbit, ",3"},
2368 { "3E2,,", NULL, {300 , 0}, IOSTATE_goodbit, ",,"},
2370 /* supported format: (real) */
2371 { "(3.)", NULL, {3., 0}, IOSTATE_goodbit, "" },
2372 { "(3E10)1", NULL, {3e+10, 0}, IOSTATE_goodbit, "1"},
2374 /* supported format: (real,imaginary) */
2375 { "(3, -.4)", NULL, {3, -0.4} , IOSTATE_goodbit, ""},
2376 { " (6.6,\n1.1\t)", NULL, {6.6, 1.1}, IOSTATE_goodbit, ""},
2377 { "(6.666 , 7.77)mark", NULL, {6.666, 7.77}, IOSTATE_goodbit, "mark"},
2379 /* different locales */
2380 { "1,234e10", "English", {1234.0e10, 0}, IOSTATE_eofbit, ""},
2381 { "1,234e10", "German" , {1.234e10, 0}, IOSTATE_eofbit, ""},
2382 { "1,234,567,890", "English", {1234567890.0, 0}, IOSTATE_eofbit , ""},
2383 { "1,234,567,890", "German" , {1.234, 0} , IOSTATE_goodbit, ",567,890"},
2384 { "(0.123,-4.5)", "English", {0.123,-4.5}, IOSTATE_goodbit, ""},
2385 { "(0,123,4,5)" , "German" , {0.123,4.5 }, IOSTATE_goodbit, ""},
2386 { "(123,456.,4.5678)", "English", {123456,4.5678}, IOSTATE_goodbit, ""},
2387 { "(123.456,,4,5678)", "German" , {123456,4.5678}, IOSTATE_goodbit, ""},
2389 /* eofbit */
2390 { ".09", NULL, {0.09, 0}, IOSTATE_eofbit, ""},
2391 { "\t-1e2", NULL, {-100, 0}, IOSTATE_eofbit, ""},
2392 { "+", NULL, deadbeef, IOSTATE_faileof, ""},
2393 { "(-1.1,3 \t " , NULL, deadbeef, IOSTATE_faileof, ""},
2394 { "(-1.1 , \t -3.4E3 \t ", NULL, deadbeef, IOSTATE_faileof, ""},
2396 /* nonsupported formats */
2397 { "(*)" , NULL, deadbeef, IOSTATE_failbit, ""},
2398 { "(\n*" , NULL, deadbeef, IOSTATE_failbit, ""},
2399 { "(6..)" , NULL, deadbeef, IOSTATE_failbit, ""},
2400 { "(3.12,*", NULL, deadbeef, IOSTATE_failbit, ""},
2401 { "(3.12,)", NULL, deadbeef, IOSTATE_failbit, ""},
2402 { "(1.0eE10, 3)" , NULL, deadbeef, IOSTATE_failbit, ""},
2405 for(i=0; i<ARRAY_SIZE(tests); i++) {
2406 call_func2(p_basic_string_char_ctor_cstr, &str, deadbeef_str);
2407 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
2408 p_basic_istream_char_read_complex_double(&ss.base.base1, &val);
2410 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].complex_double_str);
2411 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
2412 if(tests[i].lcl) {
2413 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
2414 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
2416 p_basic_istream_char_read_complex_double(&ss.base.base1, &val);
2417 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
2419 memset(next, 0, sizeof(next));
2420 p_basic_istream_char_read_str(&ss.base.base1, next);
2422 ok(tests[i].state == state, "test %d fail, wrong state, expected = %x found = %x\n", i+1, tests[i].state, state);
2423 ok(tests[i].correct_val.real == val.real, "test %d fail, wrong val, expected = %g found %g\n", i+1, tests[i].correct_val.real, val.real);
2424 ok(tests[i].correct_val.imag == val.imag, "test %d fail, wrong val, expected = %g found %g\n", i+1, tests[i].correct_val.imag, val.imag);
2425 ok(!strcmp(tests[i].str, next), "test %d fail, wrong next, expected = %s found %s\n", i+1, tests[i].str, next);
2427 if(tests[i].lcl)
2428 call_func1(p_locale_dtor, &lcl);
2429 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2430 call_func1(p_basic_string_char_dtor, &str);
2434 static void test_basic_ios(void)
2436 basic_ios_char bi;
2437 char c;
2439 call_func1(p_basic_ios_char_ctor, &bi);
2440 call_func1(p_ios_base__Init, &bi.base);
2442 c = (UINT_PTR)call_func2(p_basic_ios_char_widen, &bi, 'a');
2443 ok(c == 'a', "basic_ios::widen('a') returned %x\n", c);
2445 call_func1(p_basic_ios_char_dtor, &bi);
2448 static void test_time_get__Getint(void)
2450 const struct {
2451 const char *str;
2452 int min;
2453 int max;
2454 int ret;
2455 int val;
2456 } tests[] = {
2457 { "0", 0, 0, IOSTATE_eofbit, 0 },
2458 { "0000", 0, 0, IOSTATE_eofbit, 0 },
2459 { "1234", 0, 2000, IOSTATE_eofbit, 1234 },
2460 { "+016", 0, 20, IOSTATE_eofbit, 16 },
2461 { "0x12", 0, 20, IOSTATE_goodbit, 0 },
2462 { " 0", 0, 0, IOSTATE_failbit, -1 },
2463 { "0 ", 0, 0, IOSTATE_goodbit, 0 },
2464 { "-13", -50, -12, IOSTATE_eofbit, -13 }
2467 struct {
2468 basic_istringstream_char basic_istringstream;
2469 basic_ios_char basic_ios;
2470 } ss;
2471 istreambuf_iterator_char beg, end;
2472 basic_string_char str;
2473 time_get_char time_get;
2474 int i, ret, v;
2476 call_func1(p_time_get_char_ctor, &time_get);
2477 for(i=0; i<ARRAY_SIZE(tests); i++)
2479 memset(&beg, 0, sizeof(beg));
2480 memset(&end, 0, sizeof(end));
2481 v = -1;
2483 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
2484 call_func4(p_basic_istringstream_char_ctor_str, &ss.basic_istringstream, &str, 0, TRUE);
2485 call_func1(p_basic_string_char_dtor, &str);
2486 beg.strbuf = &ss.basic_istringstream.strbuf.base;
2488 ret = p_time_get_char__Getint(&time_get, &beg, &end,
2489 tests[i].min, tests[i].max, &v);
2490 ok(ret == tests[i].ret, "%d) ret = %d, expected %d\n", i, ret, tests[i].ret);
2491 ok(v == tests[i].val, "%d) v = %d, expected %d\n", i, v, tests[i].val);
2493 call_func1(p_basic_istringstream_char_dtor, &ss.basic_ios);
2494 call_func1(p_basic_ios_char_dtor, &ss.basic_ios);
2496 call_func1(p_time_get_char_dtor, &time_get);
2499 START_TEST(ios)
2501 if(!init())
2502 return;
2504 test_num_get_get_uint64();
2505 test_num_get_get_double();
2506 test_num_put_put_double();
2507 test_istream_ipfx();
2508 test_istream_ignore();
2509 test_istream_seekg();
2510 test_istream_seekg_fpos();
2511 test_istream_peek();
2512 test_istream_tellg();
2513 test_istream_getline();
2514 test_ostream_print_ushort();
2515 test_ostream_print_float();
2516 test_ostream_print_double();
2517 test_ostream_wchar_print_double();
2518 test_istream_read_float();
2519 test_istream_read_double();
2520 test_ostream_print_complex_float();
2521 test_ostream_print_complex_double();
2522 test_ostream_print_complex_ldouble();
2523 test_istream_read_complex_double();
2524 test_basic_ios();
2525 test_time_get__Getint();
2527 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
2529 FreeLibrary(msvcr);
2530 FreeLibrary(msvcp);