msvcp90/tests: Fix a spelling error.
[wine/multimedia.git] / dlls / msvcp90 / tests / ios.c
blob0c57ca1459703bd9370656e4355e5d80641c82ec
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 basic_streambuf<wchar> */
190 typedef struct {
191 const vtable_ptr *vtable;
192 mutex lock;
193 wchar_t *rbuf;
194 wchar_t *wbuf;
195 wchar_t **prbuf;
196 wchar_t **pwbuf;
197 wchar_t *rpos;
198 wchar_t *wpos;
199 wchar_t **prpos;
200 wchar_t **pwpos;
201 int rsize;
202 int wsize;
203 int *prsize;
204 int *pwsize;
205 locale *loc;
206 } basic_streambuf_wchar;
208 typedef struct {
209 basic_streambuf_char base;
210 codecvt_char *cvt;
211 char putback;
212 MSVCP_bool wrotesome;
213 int state;
214 MSVCP_bool close;
215 FILE *file;
216 } basic_filebuf_char;
218 typedef struct {
219 basic_streambuf_wchar base;
220 codecvt_wchar *cvt;
221 wchar_t putback;
222 MSVCP_bool wrotesome;
223 int state;
224 MSVCP_bool close;
225 FILE *file;
226 } basic_filebuf_wchar;
228 typedef struct {
229 basic_streambuf_char base;
230 char *seekhigh;
231 int state;
232 char allocator; /* empty struct */
233 } basic_stringbuf_char;
235 typedef struct {
236 basic_streambuf_wchar base;
237 wchar_t *seekhigh;
238 int state;
239 char allocator; /* empty struct */
240 } basic_stringbuf_wchar;
242 typedef struct {
243 ios_base base;
244 basic_streambuf_char *strbuf;
245 struct _basic_ostream_char *stream;
246 char fillch;
247 } basic_ios_char;
249 typedef struct {
250 ios_base base;
251 basic_streambuf_wchar *strbuf;
252 struct _basic_ostream_wchar *stream;
253 wchar_t fillch;
254 } basic_ios_wchar;
256 typedef struct _basic_ostream_char {
257 const int *vbtable;
258 /* virtual inheritance
259 * basic_ios_char basic_ios;
261 } basic_ostream_char;
263 typedef struct _basic_ostream_wchar {
264 const int *vbtable;
265 /* virtual inheritance
266 * basic_ios_wchar basic_ios;
268 } basic_ostream_wchar;
270 typedef struct {
271 const int *vbtable;
272 streamsize count;
273 /* virtual inheritance
274 * basic_ios_char basic_ios;
276 } basic_istream_char;
278 typedef struct {
279 const int *vbtable;
280 streamsize count;
281 /* virtual inheritance
282 * basic_ios_wchar basic_ios;
284 } basic_istream_wchar;
286 typedef struct {
287 basic_istream_char base1;
288 basic_ostream_char base2;
289 /* virtual inheritance
290 * basic_ios_char basic_ios;
292 } basic_iostream_char;
294 typedef struct {
295 basic_istream_wchar base1;
296 basic_ostream_wchar base2;
297 /* virtual inheritance
298 * basic_ios_wchar basic_ios;
300 } basic_iostream_wchar;
302 typedef struct {
303 basic_ostream_char base;
304 basic_filebuf_char filebuf;
305 /* virtual inheritance
306 * basic_ios_char basic_ios;
308 } basic_ofstream_char;
310 typedef struct {
311 basic_ostream_wchar base;
312 basic_filebuf_wchar filebuf;
313 /* virtual inheritance
314 * basic_ios_wchar basic_ios;
316 } basic_ofstream_wchar;
318 typedef struct {
319 basic_istream_char base;
320 basic_filebuf_char filebuf;
321 /* virtual inheritance
322 * basic_ios_char basic_ios;
324 } basic_ifstream_char;
326 typedef struct {
327 basic_istream_wchar base;
328 basic_filebuf_wchar filebuf;
329 /* virtual inheritance
330 * basic_ios_wchar basic_ios;
332 } basic_ifstream_wchar;
334 typedef struct {
335 basic_iostream_char base;
336 basic_filebuf_char filebuf;
337 /* virtual inheritance */
338 basic_ios_char basic_ios; /* here to reserve correct stack size */
339 } basic_fstream_char;
341 typedef struct {
342 basic_iostream_wchar base;
343 basic_filebuf_wchar filebuf;
344 /* virtual inheritance */
345 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
346 } basic_fstream_wchar;
348 typedef struct {
349 basic_ostream_char base;
350 basic_stringbuf_char strbuf;
351 /* virtual inheritance
352 * basic_ios_char basic_ios;
354 } basic_ostringstream_char;
356 typedef struct {
357 basic_ostream_wchar base;
358 basic_stringbuf_wchar strbuf;
359 /* virtual inheritance
360 * basic_ios_wchar basic_ios;
362 } basic_ostringstream_wchar;
364 typedef struct {
365 basic_istream_char base;
366 basic_stringbuf_char strbuf;
367 /* virtual inheritance
368 * basic_ios_char basic_ios;
370 } basic_istringstream_char;
372 typedef struct {
373 basic_istream_wchar base;
374 basic_stringbuf_wchar strbuf;
375 /* virtual inheritance
376 * basic_ios_wchar basic_ios;
378 } basic_istringstream_wchar;
380 typedef struct {
381 basic_iostream_char base;
382 basic_stringbuf_char strbuf;
383 /* virtual inheritance */
384 basic_ios_char basic_ios; /* here to reserve correct stack size */
385 } basic_stringstream_char;
387 typedef struct {
388 basic_iostream_wchar base;
389 basic_stringbuf_wchar strbuf;
390 /* virtual inheritance */
391 basic_ios_wchar basic_ios; /* here to reserve correct stack size */
392 } basic_stringstream_wchar;
394 /* basic_string<char, char_traits<char>, allocator<char>> */
395 #define BUF_SIZE_CHAR 16
396 typedef struct _basic_string_char
398 void *allocator;
399 union {
400 char buf[BUF_SIZE_CHAR];
401 char *ptr;
402 } data;
403 size_t size;
404 size_t res;
405 } basic_string_char;
407 #define BUF_SIZE_WCHAR 8
408 typedef struct
410 void *allocator;
411 union {
412 wchar_t buf[BUF_SIZE_WCHAR];
413 wchar_t *ptr;
414 } data;
415 MSVCP_size_t size;
416 MSVCP_size_t res;
417 } basic_string_wchar;
419 typedef struct {
420 streamoff off;
421 __int64 DECLSPEC_ALIGN(8) pos;
422 int state;
423 } fpos_int;
425 /* class complex<float> */
426 typedef struct {
427 float real;
428 float imag;
429 } complex_float;
431 /* class complex<double> */
432 /* class complex<long double> */
433 typedef struct {
434 double real;
435 double imag;
436 } complex_double;
438 /* stringstream */
439 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor)(basic_stringstream_char*);
440 static basic_stringstream_char* (*__thiscall p_basic_stringstream_char_ctor_str)(basic_stringstream_char*, const basic_string_char*, int, MSVCP_bool);
441 static basic_string_char* (*__thiscall p_basic_stringstream_char_str_get)(const basic_stringstream_char*, basic_string_char*);
442 static void (*__thiscall p_basic_stringstream_char_vbase_dtor)(basic_stringstream_char*);
444 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor)(basic_stringstream_wchar*);
445 static basic_stringstream_wchar* (*__thiscall p_basic_stringstream_wchar_ctor_str)(basic_stringstream_wchar*, const basic_string_wchar*, int, MSVCP_bool);
446 static basic_string_wchar* (*__thiscall p_basic_stringstream_wchar_str_get)(const basic_stringstream_wchar*, basic_string_wchar*);
447 static void (*__thiscall p_basic_stringstream_wchar_vbase_dtor)(basic_stringstream_wchar*);
449 /* fstream */
450 static basic_fstream_char* (*__thiscall p_basic_fstream_char_ctor_name)(basic_fstream_char*, const char*, int, int, MSVCP_bool);
451 static void (*__thiscall p_basic_fstream_char_vbase_dtor)(basic_fstream_char*);
453 static basic_fstream_wchar* (*__thiscall p_basic_fstream_wchar_ctor_name)(basic_fstream_wchar*, const char*, int, int, MSVCP_bool);
454 static void (*__thiscall p_basic_fstream_wchar_vbase_dtor)(basic_fstream_wchar*);
456 /* istream */
457 static basic_istream_char* (*__thiscall p_basic_istream_char_read_uint64)(basic_istream_char*, unsigned __int64*);
458 static basic_istream_char* (*__thiscall p_basic_istream_char_read_float)(basic_istream_char*, float*);
459 static basic_istream_char* (*__thiscall p_basic_istream_char_read_double)(basic_istream_char*, double*);
460 static basic_istream_char* (*__cdecl p_basic_istream_char_read_str)(basic_istream_char*, char*);
461 static basic_istream_char* (*__cdecl p_basic_istream_char_read_complex_double)(basic_istream_char*, complex_double*);
462 static int (*__thiscall p_basic_istream_char_get)(basic_istream_char*);
463 static MSVCP_bool (*__thiscall p_basic_istream_char_ipfx)(basic_istream_char*, MSVCP_bool);
464 static basic_istream_char* (*__thiscall p_basic_istream_char_ignore)(basic_istream_char*, streamsize, int);
465 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg)(basic_istream_char*, streamoff, int);
466 static basic_istream_char* (*__thiscall p_basic_istream_char_seekg_fpos)(basic_istream_char*, fpos_int);
467 static int (*__thiscall p_basic_istream_char_peek)(basic_istream_char*);
468 static fpos_int* (*__thiscall p_basic_istream_char_tellg)(basic_istream_char*, fpos_int*);
469 static basic_istream_char* (*__cdecl p_basic_istream_char_getline_bstr_delim)(basic_istream_char*, basic_string_char*, char);
471 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_uint64)(basic_istream_wchar*, unsigned __int64*);
472 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_read_double)(basic_istream_wchar*, double *);
473 static int (*__thiscall p_basic_istream_wchar_get)(basic_istream_wchar*);
474 static MSVCP_bool (*__thiscall p_basic_istream_wchar_ipfx)(basic_istream_wchar*, MSVCP_bool);
475 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_ignore)(basic_istream_wchar*, streamsize, unsigned short);
476 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg)(basic_istream_wchar*, streamoff, int);
477 static basic_istream_wchar* (*__thiscall p_basic_istream_wchar_seekg_fpos)(basic_istream_wchar*, fpos_int);
478 static unsigned short (*__thiscall p_basic_istream_wchar_peek)(basic_istream_wchar*);
479 static fpos_int* (*__thiscall p_basic_istream_wchar_tellg)(basic_istream_wchar*, fpos_int*);
480 static basic_istream_wchar* (*__cdecl p_basic_istream_wchar_getline_bstr_delim)(basic_istream_wchar*, basic_string_wchar*, wchar_t);
482 /* ostream */
483 static basic_ostream_char* (*__thiscall p_basic_ostream_char_print_float)(basic_ostream_char*, float);
485 static basic_ostream_char* (*__thiscall p_basic_ostream_char_print_double)(basic_ostream_char*, double);
487 static basic_ostream_wchar* (*__thiscall p_basic_ostream_wchar_print_double)(basic_ostream_wchar*, double);
489 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_float)(basic_ostream_char*, complex_float*);
491 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_double)(basic_ostream_char*, complex_double*);
493 static basic_ostream_char* (*__cdecl p_basic_ostream_char_print_complex_ldouble)(basic_ostream_char*, complex_double*);
495 static basic_ostream_wchar* (*__thiscall p_basic_ostream_short_print_ushort)(basic_ostream_wchar*, unsigned short);
497 /* basic_ios */
498 static locale* (*__thiscall p_basic_ios_char_imbue)(basic_ios_char*, locale*, const locale*);
500 static locale* (*__thiscall p_basic_ios_wchar_imbue)(basic_ios_wchar*, locale*, const locale*);
502 /* ios_base */
503 static IOSB_iostate (*__thiscall p_ios_base_rdstate)(const ios_base*);
504 static IOSB_fmtflags (*__thiscall p_ios_base_setf_mask)(ios_base*, IOSB_fmtflags, IOSB_fmtflags);
505 static void (*__thiscall p_ios_base_unsetf)(ios_base*, IOSB_fmtflags);
506 static streamsize (*__thiscall p_ios_base_precision_set)(ios_base*, streamsize);
508 /* locale */
509 static locale* (*__thiscall p_locale_ctor_cstr)(locale*, const char*, int /* FIXME: category */);
510 static void (*__thiscall p_locale_dtor)(locale *this);
512 /* basic_string */
513 static basic_string_char* (__thiscall *p_basic_string_char_ctor_cstr)(basic_string_char*, const char*);
514 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
515 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
517 static basic_string_wchar* (__thiscall *p_basic_string_wchar_ctor_cstr)(basic_string_wchar*, const wchar_t*);
518 static const wchar_t* (__thiscall *p_basic_string_wchar_cstr)(basic_string_wchar*);
519 static void (__thiscall *p_basic_string_wchar_dtor)(basic_string_wchar*);
521 static int invalid_parameter = 0;
522 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
523 const wchar_t *function, const wchar_t *file,
524 unsigned line, uintptr_t arg)
526 ok(expression == NULL, "expression is not NULL\n");
527 ok(function == NULL, "function is not NULL\n");
528 ok(file == NULL, "file is not NULL\n");
529 ok(line == 0, "line = %u\n", line);
530 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
531 invalid_parameter++;
534 static inline const char* debugstr_longlong(ULONGLONG ll)
536 /* return a different string if called up to 4 times in the same ok() */
537 static char string[4][17];
538 static int which;
540 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
541 sprintf(string[which & 3], "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll);
542 else
543 sprintf(string[which & 3], "%lx", (unsigned long)ll);
544 return string[which++ & 3];
547 /* Emulate a __thiscall */
548 #ifdef __i386__
550 #include "pshpack1.h"
551 struct thiscall_thunk
553 BYTE pop_eax; /* popl %eax (ret addr) */
554 BYTE pop_edx; /* popl %edx (func) */
555 BYTE pop_ecx; /* popl %ecx (this) */
556 BYTE push_eax; /* pushl %eax */
557 WORD jmp_edx; /* jmp *%edx */
559 #include "poppack.h"
561 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
562 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
563 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
564 static void * (WINAPI *call_thiscall_func4)( void *func, void *this, const void *a, const void *b,
565 const void *c );
566 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
567 const void *c, const void *d );
569 /* to silence compiler errors */
570 static void * (WINAPI *call_thiscall_func2_ptr_dbl)( void *func, void *this, double a );
571 static void * (WINAPI *call_thiscall_func2_ptr_flt)( void *func, void *this, float a );
572 static void * (WINAPI *call_thiscall_func2_ptr_fpos)( void *func, void *this, fpos_int a );
574 static void init_thiscall_thunk(void)
576 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
577 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
578 thunk->pop_eax = 0x58; /* popl %eax */
579 thunk->pop_edx = 0x5a; /* popl %edx */
580 thunk->pop_ecx = 0x59; /* popl %ecx */
581 thunk->push_eax = 0x50; /* pushl %eax */
582 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
583 call_thiscall_func1 = (void *)thunk;
584 call_thiscall_func2 = (void *)thunk;
585 call_thiscall_func3 = (void *)thunk;
586 call_thiscall_func4 = (void *)thunk;
587 call_thiscall_func5 = (void *)thunk;
589 call_thiscall_func2_ptr_dbl = (void *)thunk;
590 call_thiscall_func2_ptr_flt = (void *)thunk;
591 call_thiscall_func2_ptr_fpos = (void *)thunk;
594 #define call_func1(func,_this) call_thiscall_func1(func,_this)
595 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
596 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
597 #define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),(const void*)(b), \
598 (const void*)(c))
599 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
600 (const void*)(c), (const void *)(d))
602 #define call_func2_ptr_dbl(func,_this,a) call_thiscall_func2_ptr_dbl(func,_this,a)
603 #define call_func2_ptr_flt(func,_this,a) call_thiscall_func2_ptr_flt(func,_this,a)
604 #define call_func2_ptr_fpos(func,_this,a) call_thiscall_func2_ptr_fpos(func,_this,a)
606 #else
608 #define init_thiscall_thunk()
609 #define call_func1(func,_this) func(_this)
610 #define call_func2(func,_this,a) func(_this,a)
611 #define call_func3(func,_this,a,b) func(_this,a,b)
612 #define call_func4(func,_this,a,b,c) func(_this,a,b,c)
613 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
615 #define call_func2_ptr_dbl call_func2
616 #define call_func2_ptr_flt call_func2
617 #define call_func2_ptr_fpos call_func2
619 #endif /* __i386__ */
621 static HMODULE msvcr, msvcp;
622 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
623 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
624 static BOOL init(void)
626 msvcr = LoadLibraryA("msvcr90.dll");
627 msvcp = LoadLibraryA("msvcp90.dll");
628 if(!msvcr || !msvcp) {
629 win_skip("msvcp90.dll or msvcr90.dll not installed\n");
630 return FALSE;
633 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
634 p_free = (void*)GetProcAddress(msvcr, "free");
635 if(!p_set_invalid_parameter_handler || !p_free) {
636 win_skip("Error setting tests environment\n");
637 return FALSE;
640 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
642 if(sizeof(void*) == 8) { /* 64-bit initialization */
643 SET(p_basic_stringstream_char_ctor,
644 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
645 SET(p_basic_stringstream_char_ctor_str,
646 "??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");
647 SET(p_basic_stringstream_char_str_get,
648 "?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");
649 SET(p_basic_stringstream_char_vbase_dtor,
650 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
652 SET(p_basic_stringstream_wchar_ctor,
653 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
654 SET(p_basic_stringstream_wchar_ctor_str,
655 "??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");
656 SET(p_basic_stringstream_wchar_str_get,
657 "?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");
658 SET(p_basic_stringstream_wchar_vbase_dtor,
659 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ");
661 SET(p_basic_fstream_char_ctor_name,
662 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z");
663 SET(p_basic_fstream_char_vbase_dtor,
664 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ");
666 SET(p_basic_fstream_wchar_ctor_name,
667 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z");
668 SET(p_basic_fstream_wchar_vbase_dtor,
669 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ");
671 SET(p_basic_istream_char_read_uint64,
672 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z");
673 SET(p_basic_istream_char_read_float,
674 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z");
675 SET(p_basic_istream_char_read_double,
676 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z");
677 SET(p_basic_istream_char_read_str,
678 "??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z");
679 SET(p_basic_istream_char_read_complex_double,
680 "??$?5NDU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$complex@N@0@@Z");
681 SET(p_basic_istream_char_get,
682 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
683 SET(p_basic_istream_char_ipfx,
684 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z");
685 SET(p_basic_istream_char_ignore,
686 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
687 SET(p_basic_istream_char_seekg,
688 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z");
689 SET(p_basic_istream_char_seekg_fpos,
690 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
691 SET(p_basic_istream_char_peek,
692 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ");
693 SET(p_basic_istream_char_tellg,
694 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
695 SET(p_basic_istream_char_getline_bstr_delim,
696 "??$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");
698 SET(p_basic_istream_wchar_read_uint64,
699 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z");
700 SET(p_basic_istream_wchar_read_double,
701 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z");
702 SET(p_basic_istream_wchar_get,
703 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
704 SET(p_basic_istream_wchar_ipfx,
705 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z");
706 SET(p_basic_istream_wchar_ignore,
707 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z");
708 SET(p_basic_istream_wchar_seekg,
709 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z");
710 SET(p_basic_istream_wchar_seekg_fpos,
711 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z");
712 SET(p_basic_istream_wchar_peek,
713 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ");
714 SET(p_basic_istream_wchar_tellg,
715 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ");
716 SET(p_basic_istream_wchar_getline_bstr_delim,
717 "??$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");
719 SET(p_basic_ostream_char_print_float,
720 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z");
722 SET(p_basic_ostream_char_print_double,
723 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z");
725 SET(p_basic_ostream_wchar_print_double,
726 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z");
728 SET(p_basic_ostream_short_print_ushort,
729 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@G@Z");
731 SET(p_basic_ostream_char_print_complex_float,
732 "??$?6MDU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@M@0@@Z");
734 SET(p_basic_ostream_char_print_complex_double,
735 "??$?6NDU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@N@0@@Z");
737 SET(p_basic_ostream_char_print_complex_ldouble,
738 "??$?6ODU?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$complex@O@0@@Z");
740 SET(p_ios_base_rdstate,
741 "?rdstate@ios_base@std@@QEBAHXZ");
742 SET(p_ios_base_setf_mask,
743 "?setf@ios_base@std@@QEAAHHH@Z");
744 SET(p_ios_base_unsetf,
745 "?unsetf@ios_base@std@@QEAAXH@Z");
746 SET(p_ios_base_precision_set,
747 "?precision@ios_base@std@@QEAA_J_J@Z");
749 SET(p_basic_ios_char_imbue,
750 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
752 SET(p_basic_ios_wchar_imbue,
753 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z");
755 SET(p_locale_ctor_cstr,
756 "??0locale@std@@QEAA@PEBDH@Z");
757 SET(p_locale_dtor,
758 "??1locale@std@@QEAA@XZ");
760 SET(p_basic_string_char_ctor_cstr,
761 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBD@Z");
762 SET(p_basic_string_char_cstr,
763 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
764 SET(p_basic_string_char_dtor,
765 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
767 SET(p_basic_string_wchar_ctor_cstr,
768 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@PEB_W@Z");
769 SET(p_basic_string_wchar_cstr,
770 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
771 SET(p_basic_string_wchar_dtor,
772 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@XZ");
773 } else {
774 #ifdef __arm__
775 SET(p_basic_stringstream_char_ctor,
776 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
777 SET(p_basic_stringstream_char_ctor_str,
778 "??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");
779 SET(p_basic_stringstream_char_str_get,
780 "?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");
781 SET(p_basic_stringstream_char_vbase_dtor,
782 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
784 SET(p_basic_stringstream_wchar_ctor,
785 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
786 SET(p_basic_stringstream_wchar_ctor_str,
787 "??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");
788 SET(p_basic_stringstream_wchar_str_get,
789 "?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");
790 SET(p_basic_stringstream_wchar_vbase_dtor,
791 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
793 SET(p_basic_fstream_char_ctor_name,
794 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
795 SET(p_basic_fstream_char_vbase_dtor,
796 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
798 SET(p_basic_fstream_wchar_ctor_name,
799 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
800 SET(p_basic_fstream_wchar_vbase_dtor,
801 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
803 SET(p_basic_istream_char_read_uint64,
804 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AA_K@Z");
805 SET(p_basic_istream_char_read_float,
806 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AAM@Z");
807 SET(p_basic_istream_char_read_double,
808 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV01@AAN@Z");
809 SET(p_basic_istream_char_read_str,
810 "??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z");
811 SET(p_basic_istream_char_read_complex_double,
812 "??$?5NDU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$complex@N@0@@Z");
813 SET(p_basic_istream_char_get,
814 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAHXZ");
815 SET(p_basic_istream_char_ipfx,
816 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAA_N_N@Z");
817 SET(p_basic_istream_char_ignore,
818 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
819 SET(p_basic_istream_char_seekg,
820 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
821 SET(p_basic_istream_char_seekg_fpos,
822 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAAAV12@V?$fpos@H@2@@Z");
823 SET(p_basic_istream_char_peek,
824 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAAHXZ");
825 SET(p_basic_istream_char_tellg,
826 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAA?AV?$fpos@H@2@XZ");
827 SET(p_basic_istream_char_getline_bstr_delim,
828 "??$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");
830 SET(p_basic_istream_wchar_read_uint64,
831 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@AA_K@Z");
832 SET(p_basic_istream_wchar_read_double,
833 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@AAN@Z");
834 SET(p_basic_istream_wchar_get,
835 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAGXZ");
836 SET(p_basic_istream_wchar_ipfx,
837 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAA_N_N@Z");
838 SET(p_basic_istream_wchar_ignore,
839 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
840 SET(p_basic_istream_wchar_seekg,
841 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
842 SET(p_basic_istream_wchar_seekg_fpos,
843 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAAAV12@V?$fpos@H@2@@Z");
844 SET(p_basic_istream_wchar_peek,
845 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAAGXZ");
846 SET(p_basic_istream_wchar_tellg,
847 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAA?AV?$fpos@H@2@XZ");
848 SET(p_basic_istream_wchar_getline_bstr_delim,
849 "??$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");
851 SET(p_basic_ostream_char_print_float,
852 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAAAAV01@M@Z");
854 SET(p_basic_ostream_char_print_double,
855 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAAAAV01@N@Z");
857 SET(p_basic_ostream_wchar_print_double,
858 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAAAAV01@N@Z");
860 SET(p_basic_ostream_short_print_ushort,
861 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAAAAV01@G@Z");
863 SET(p_basic_ostream_char_print_complex_float,
864 "??$?6MDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@M@0@@Z");
866 SET(p_basic_ostream_char_print_complex_double,
867 "??$?6NDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@N@0@@Z");
869 SET(p_basic_ostream_char_print_complex_ldouble,
870 "??$?6ODU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@O@0@@Z");
872 SET(p_ios_base_rdstate,
873 "?rdstate@ios_base@std@@QBAHXZ");
874 SET(p_ios_base_setf_mask,
875 "?setf@ios_base@std@@QAAHHH@Z");
876 SET(p_ios_base_unsetf,
877 "?unsetf@ios_base@std@@QAAXH@Z");
878 SET(p_ios_base_precision_set,
879 "?precision@ios_base@std@@QAEHH@Z");
881 SET(p_basic_ios_char_imbue,
882 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAA?AVlocale@2@ABV32@@Z");
884 SET(p_basic_ios_wchar_imbue,
885 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAA?AVlocale@2@ABV32@@Z");
887 SET(p_locale_ctor_cstr,
888 "??0locale@std@@QAE@PBDH@Z");
889 SET(p_locale_dtor,
890 "??1locale@std@@QAE@XZ");
892 SET(p_basic_string_char_ctor_cstr,
893 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
894 SET(p_basic_string_char_cstr,
895 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
896 SET(p_basic_string_char_dtor,
897 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
899 SET(p_basic_string_wchar_ctor_cstr,
900 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
901 SET(p_basic_string_wchar_cstr,
902 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
903 SET(p_basic_string_wchar_dtor,
904 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
905 #else
906 SET(p_basic_stringstream_char_ctor,
907 "??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
908 SET(p_basic_stringstream_char_ctor_str,
909 "??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");
910 SET(p_basic_stringstream_char_str_get,
911 "?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");
912 SET(p_basic_stringstream_char_vbase_dtor,
913 "??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
915 SET(p_basic_stringstream_wchar_ctor,
916 "??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
917 SET(p_basic_stringstream_wchar_ctor_str,
918 "??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");
919 SET(p_basic_stringstream_wchar_str_get,
920 "?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");
921 SET(p_basic_stringstream_wchar_vbase_dtor,
922 "??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ");
924 SET(p_basic_fstream_char_ctor_name,
925 "??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z");
926 SET(p_basic_fstream_char_vbase_dtor,
927 "??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ");
929 SET(p_basic_fstream_wchar_ctor_name,
930 "??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z");
931 SET(p_basic_fstream_wchar_vbase_dtor,
932 "??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ");
934 SET(p_basic_istream_char_read_uint64,
935 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z");
936 SET(p_basic_istream_char_read_float,
937 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z");
938 SET(p_basic_istream_char_read_double,
939 "??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z");
940 SET(p_basic_istream_char_read_str,
941 "??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z");
942 SET(p_basic_istream_char_read_complex_double,
943 "??$?5NDU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$complex@N@0@@Z");
944 SET(p_basic_istream_char_get,
945 "?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
946 SET(p_basic_istream_char_ipfx,
947 "?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z");
948 SET(p_basic_istream_char_ignore,
949 "?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z");
950 SET(p_basic_istream_char_seekg,
951 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z");
952 SET(p_basic_istream_char_seekg_fpos,
953 "?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
954 SET(p_basic_istream_char_peek,
955 "?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ");
956 SET(p_basic_istream_char_tellg,
957 "?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ");
958 SET(p_basic_istream_char_getline_bstr_delim,
959 "??$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");
961 SET(p_basic_istream_wchar_read_uint64,
962 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z");
963 SET(p_basic_istream_wchar_read_double,
964 "??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z");
965 SET(p_basic_istream_wchar_get,
966 "?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
967 SET(p_basic_istream_wchar_ipfx,
968 "?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z");
969 SET(p_basic_istream_wchar_ignore,
970 "?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z");
971 SET(p_basic_istream_wchar_seekg,
972 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z");
973 SET(p_basic_istream_wchar_seekg_fpos,
974 "?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z");
975 SET(p_basic_istream_wchar_peek,
976 "?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ");
977 SET(p_basic_istream_wchar_tellg,
978 "?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ");
979 SET(p_basic_istream_wchar_getline_bstr_delim,
980 "??$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");
982 SET(p_basic_ostream_char_print_float,
983 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z");
985 SET(p_basic_ostream_char_print_double,
986 "??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z");
988 SET(p_basic_ostream_wchar_print_double,
989 "??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z");
991 SET(p_basic_ostream_short_print_ushort,
992 "??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@G@Z");
994 SET(p_basic_ostream_char_print_complex_float,
995 "??$?6MDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@M@0@@Z");
997 SET(p_basic_ostream_char_print_complex_double,
998 "??$?6NDU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@N@0@@Z");
1000 SET(p_basic_ostream_char_print_complex_ldouble,
1001 "??$?6ODU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$complex@O@0@@Z");
1003 SET(p_ios_base_rdstate,
1004 "?rdstate@ios_base@std@@QBEHXZ");
1005 SET(p_ios_base_setf_mask,
1006 "?setf@ios_base@std@@QAEHHH@Z");
1007 SET(p_ios_base_unsetf,
1008 "?unsetf@ios_base@std@@QAEXH@Z");
1009 SET(p_ios_base_precision_set,
1010 "?precision@ios_base@std@@QAEHH@Z");
1012 SET(p_basic_ios_char_imbue,
1013 "?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
1015 SET(p_basic_ios_wchar_imbue,
1016 "?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z");
1018 SET(p_locale_ctor_cstr,
1019 "??0locale@std@@QAE@PBDH@Z");
1020 SET(p_locale_dtor,
1021 "??1locale@std@@QAE@XZ");
1023 SET(p_basic_string_char_ctor_cstr,
1024 "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z");
1025 SET(p_basic_string_char_cstr,
1026 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
1027 SET(p_basic_string_char_dtor,
1028 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
1030 SET(p_basic_string_wchar_ctor_cstr,
1031 "??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@PB_W@Z");
1032 SET(p_basic_string_wchar_cstr,
1033 "?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
1034 SET(p_basic_string_wchar_dtor,
1035 "??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
1036 #endif
1039 init_thiscall_thunk();
1040 return TRUE;
1043 /* convert a dll name A->W without depending on the current codepage */
1044 static wchar_t *AtoW( wchar_t *nameW, const char *nameA, unsigned int len )
1046 unsigned int i;
1048 for (i = 0; i < len; i++) nameW[i] = nameA[i];
1049 nameW[i] = 0;
1050 return nameW;
1053 static void test_num_get_get_uint64(void)
1055 unsigned short testus, nextus;
1056 basic_stringstream_wchar wss;
1057 basic_stringstream_char ss;
1058 basic_string_wchar wstr;
1059 basic_string_char str;
1060 IOSB_iostate state;
1061 locale lcl, retlcl;
1062 wchar_t wide[64];
1063 ULONGLONG val;
1064 int i, next;
1066 /* makes tables narrower */
1067 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1069 struct _test_num_get {
1070 const char *str;
1071 const char *lcl;
1072 IOSB_fmtflags fmtfl;
1073 IOSB_iostate state;
1074 ULONGLONG val;
1075 int next;
1076 } tests[] = {
1077 /* simple cases */
1078 { "0", NULL, FMTFLAG_dec, IOSTATE_eofbit, 0, EOF },
1079 { "1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
1080 { "+1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF },
1081 { "-1234567", NULL, FMTFLAG_dec, IOSTATE_eofbit, -1234567, EOF },
1082 { "", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF },
1084 /* different bases */
1085 /* (with and without zero are both tested, since 0 can signal a prefix check) */
1086 { "0x1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* lowercase x */
1087 { "0X1000", NULL, FMTFLAG_hex, IOSTATE_eofbit, 4096, EOF }, /* uppercase X */
1088 { "010", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
1089 { "010", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
1090 { "010", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
1091 { "10", NULL, FMTFLAG_hex, IOSTATE_eofbit, 16, EOF },
1092 { "10", NULL, FMTFLAG_dec, IOSTATE_eofbit, 10, EOF },
1093 { "10", NULL, FMTFLAG_oct, IOSTATE_eofbit, 8, EOF },
1094 { "10", NULL, 0, IOSTATE_eofbit, 10, EOF }, /* discover dec */
1095 { "010", NULL, 0, IOSTATE_eofbit, 8, EOF }, /* discover oct */
1096 { "0xD", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (upper) */
1097 { "0xd", NULL, 0, IOSTATE_eofbit, 13, EOF }, /* discover hex (lower) */
1099 /* test grouping - default/"C" has no grouping, named English/German locales do */
1100 { "0.", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, '.' },
1101 { "0,", NULL, FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
1102 { "0,", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with , */
1103 { "0.", "German", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* trailing group with . */
1104 { "0,", "German", FMTFLAG_dec, IOSTATE_goodbit, 0, ',' },
1105 { ",0", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group at start */
1107 { "1,234,567", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* no grouping */
1108 { "1,234,567", "English", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with , */
1109 { "1.234.567", "German", FMTFLAG_dec, IOSTATE_eofbit, 1234567, EOF }, /* grouping with . */
1110 { "1,,234", NULL, FMTFLAG_dec, IOSTATE_goodbit, 1, ',' }, /* empty group */
1111 { "1,,234", "English", FMTFLAG_dec, IOSTATE_failbit, 42, EOF }, /* empty group */
1112 { "0x1,000,000", "English", FMTFLAG_hex, IOSTATE_eofbit, 16777216, EOF }, /* yeah, hex can group */
1113 { "1,23,34", "English", FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid size group */
1114 { "0,123", "English", FMTFLAG_dec, IOSTATE_eofbit, 123, EOF }, /* 0 solo in group */
1116 { "18446744073709551615", NULL, FMTFLAG_dec, IOSTATE_eofbit, ~0, EOF }, /* max value */
1117 { "99999999999999999999", NULL, FMTFLAG_dec, IOSTATE_faileof, 42, EOF }, /* invalid value */
1119 /* test invalid formats */
1120 { "0000x10", NULL, FMTFLAG_hex, IOSTATE_goodbit, 0, 'x' },
1121 { "x10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
1122 { "0xx10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
1125 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1126 /* char version */
1127 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1128 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1130 if(tests[i].lcl) {
1131 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1132 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1135 val = 42;
1136 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
1137 call_func2(p_basic_istream_char_read_uint64, &ss.base.base1, &val);
1138 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1139 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1141 if(state==IOSTATE_faileof && tests[i].val==~0) {
1142 /* Maximal uint64 test is broken on 9.0.21022.8 */
1143 skip("basic_istream_char_read_uint64(MAX_UINT64) is broken\n");
1144 continue;
1147 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1148 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
1149 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
1150 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1152 if(tests[i].lcl)
1153 call_func1(p_locale_dtor, &lcl);
1155 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1156 call_func1(p_basic_string_char_dtor, &str);
1158 /* wchar_t version */
1159 AtoW(wide, tests[i].str, strlen(tests[i].str));
1160 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1161 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1163 if(tests[i].lcl) {
1164 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1165 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1168 val = 42;
1169 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_basefield);
1170 call_func2(p_basic_istream_wchar_read_uint64, &wss.base.base1, &val);
1171 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1172 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1174 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1175 ok(tests[i].val == val, "wrong val, expected = %lx%08lx found %lx%08lx\n", (unsigned long)(tests[i].val >> 32),
1176 (unsigned long)tests[i].val, (unsigned long)(val >> 32), (unsigned long)val);
1177 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1178 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1180 if(tests[i].lcl)
1181 call_func1(p_locale_dtor, &lcl);
1183 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1184 call_func1(p_basic_string_wchar_dtor, &wstr);
1189 static void test_num_get_get_double(void)
1191 unsigned short testus, nextus;
1192 basic_stringstream_wchar wss;
1193 basic_stringstream_char ss;
1194 basic_string_wchar wstr;
1195 basic_string_char str;
1196 IOSB_iostate state;
1197 locale lcl, retlcl;
1198 wchar_t wide[64];
1199 int i, next;
1200 double val;
1202 /* makes tables narrower */
1203 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1205 struct _test_num_get {
1206 const char *str;
1207 const char *lcl;
1208 IOSB_iostate state;
1209 double val;
1210 int next;
1211 } tests[] = {
1212 /* simple cases */
1213 { "0", NULL, IOSTATE_eofbit, 0.0, EOF },
1214 { "10", NULL, IOSTATE_eofbit, 10.0, EOF },
1215 { "+10", NULL, IOSTATE_eofbit, 10.0, EOF },
1216 { "-10", NULL, IOSTATE_eofbit, -10.0, EOF },
1217 { "+010", NULL, IOSTATE_eofbit, 10.0, EOF }, /* leading zero */
1219 /* test grouping - default/"C" has no grouping, named English/German locales do */
1220 { "1,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* with comma */
1221 { "1,000", "English", IOSTATE_eofbit, 1000.0, EOF },
1222 { "1,000", "German", IOSTATE_eofbit, 1.0, EOF },
1224 { "1.000", NULL, IOSTATE_eofbit, 1.0, EOF }, /* with period */
1225 { "1.000", "English", IOSTATE_eofbit, 1.0, EOF },
1226 { "1.000", "German", IOSTATE_eofbit, 1000.0, EOF },
1228 { "1,234.", NULL, IOSTATE_goodbit, 1.0, ',' },
1229 { "1,234.", "English", IOSTATE_eofbit, 1234.0, EOF }, /* trailing decimal */
1230 { "1,234.", "German", IOSTATE_goodbit, 1.234, '.' },
1231 { "1,234.5", "English", IOSTATE_eofbit, 1234.5, EOF }, /* group + decimal */
1232 { "1,234.5", "German", IOSTATE_goodbit, 1.234, '.' },
1234 { "1,234,567,890", NULL, IOSTATE_goodbit, 1.0, ',' }, /* more groups */
1235 { "1,234,567,890", "English", IOSTATE_eofbit, 1234567890.0, EOF },
1236 { "1,234,567,890", "German", IOSTATE_goodbit, 1.234, ',' },
1237 { "1.234.567.890", "German", IOSTATE_eofbit, 1234567890.0, EOF },
1239 /* extra digits and stuff */
1240 { "00000.123456", NULL, IOSTATE_eofbit, 0.123456, EOF },
1241 { "0.1234560000", NULL, IOSTATE_eofbit, 0.123456, EOF },
1242 { "100aaaa", NULL, IOSTATE_goodbit, 100.0, 'a' },
1244 /* exponent */
1245 { "10e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* lowercase e */
1246 { "10E10", NULL, IOSTATE_eofbit, 10E10, EOF }, /* uppercase E */
1247 { "10e+10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* sign */
1248 { "10e-10", NULL, IOSTATE_eofbit, 10e-10, EOF },
1249 { "10.e10", NULL, IOSTATE_eofbit, 10e10, EOF }, /* trailing decimal before exponent */
1250 { "-10.e-10", NULL, IOSTATE_eofbit, -10e-10, EOF },
1251 { "-12.345e-10", NULL, IOSTATE_eofbit, -12.345e-10, EOF },
1252 { "1,234e10", NULL, IOSTATE_goodbit, 1.0, ',' },
1253 { "1,234e10", "English", IOSTATE_eofbit, 1234.0e10, EOF },
1254 { "1,234e10", "German", IOSTATE_eofbit, 1.234e10, EOF },
1255 { "1.0e999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too big */
1256 { "1.0e-999", NULL, IOSTATE_faileof, 42.0, EOF }, /* too small */
1258 /* bad form */
1259 { "1,000,", NULL, IOSTATE_goodbit, 1.0, ',' }, /* trailing group */
1260 { "1,000,", "English", IOSTATE_faileof, 42.0, EOF },
1261 { "1.000.", "German", IOSTATE_faileof, 42.0, EOF },
1263 { "1,,000", NULL, IOSTATE_goodbit, 1.0, ',' }, /* empty group */
1264 { "1,,000", "English", IOSTATE_failbit, 42.0, EOF },
1265 { "1..000", "German", IOSTATE_failbit, 42.0, EOF },
1267 { "1.0,00", "English", IOSTATE_goodbit, 1.0, ',' },
1268 { "1.0,00", "German", IOSTATE_faileof, 42.0, EOF },
1270 { "1.0ee10", NULL, IOSTATE_failbit, 42.0, EOF }, /* dup exp */
1271 { "1.0e1.0", NULL, IOSTATE_goodbit, 10.0, '.' }, /* decimal in exponent */
1272 { "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
1275 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1276 /* char version */
1277 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1278 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1280 if(tests[i].lcl) {
1281 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1282 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1285 val = 42.0;
1286 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
1287 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1288 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1290 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1291 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1292 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1294 if(tests[i].lcl)
1295 call_func1(p_locale_dtor, &lcl);
1297 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1298 call_func1(p_basic_string_char_dtor, &str);
1300 /* wchar_t version */
1301 AtoW(wide, tests[i].str, strlen(tests[i].str));
1302 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1303 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1305 if(tests[i].lcl) {
1306 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1307 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1310 val = 42.0;
1311 call_func2(p_basic_istream_wchar_read_double, &wss.base.base1, &val);
1312 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1313 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1315 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1316 ok(tests[i].val == val, "wrong val, expected = %g found %g\n", tests[i].val, val);
1317 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1318 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1320 if(tests[i].lcl)
1321 call_func1(p_locale_dtor, &lcl);
1323 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1324 call_func1(p_basic_string_wchar_dtor, &wstr);
1329 static void test_num_put_put_double(void)
1331 basic_stringstream_wchar wss;
1332 basic_stringstream_char ss;
1333 basic_string_wchar pwstr;
1334 basic_string_char pstr;
1335 locale lcl, retlcl;
1336 const wchar_t *wstr;
1337 const char *str;
1338 wchar_t wide[64];
1339 int i;
1341 struct _test_num_get {
1342 double val;
1343 const char *lcl;
1344 streamsize prec; /* set to -1 for default */
1345 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
1346 const char *str;
1347 } tests[] = {
1348 { 0.0, NULL, -1, 0, "0" },
1350 /* simple cases */
1351 { 0.123, NULL, -1, 0, "0.123" },
1352 { 0.123, NULL, 6, 0, "0.123" },
1353 { 0.123, NULL, 0, 0, "0.123" },
1355 /* fixed format */
1356 { 0.123, NULL, -1, FMTFLAG_fixed, "0.123000" },
1357 { 0.123, NULL, 6, FMTFLAG_fixed, "0.123000" },
1358 { 0.123, NULL, 0, FMTFLAG_fixed, "0" },
1360 /* scientific format */
1361 { 123456.789, NULL, -1, FMTFLAG_scientific, "1.234568e+005" },
1362 { 123456.789, NULL, 0, FMTFLAG_scientific, "1.234568e+005" },
1363 { 123456.789, NULL, 9, FMTFLAG_scientific, "1.234567890e+005" },
1364 { 123456.789, "German", 9, FMTFLAG_scientific, "1,234567890e+005" },
1366 /* different locales */
1367 { 0.123, "C", -1, 0, "0.123" },
1368 { 0.123, "English", -1, 0, "0.123" },
1369 { 0.123, "German", -1, 0, "0,123" },
1371 { 123456.789, "C", -1, 0, "123457" },
1372 { 123456.789, "English", -1, 0, "123,457" },
1373 { 123456.789, "German", -1, 0, "123.457" },
1375 /* signs and exponents */
1376 { 1.0e-9, NULL, -1, 0, "1e-009" },
1377 { 1.0e-9, NULL, 9, 0, "1e-009" },
1378 { -1.0e9, NULL, -1, 0, "-1e+009" },
1379 { -1.0e9, NULL, 9, 0, "-1e+009" },
1381 { 1.0e-9, NULL, 0, FMTFLAG_fixed, "0" },
1382 { 1.0e-9, NULL, 6, FMTFLAG_fixed, "0.000000" },
1383 { 1.0e-9, NULL, 9, FMTFLAG_fixed, "0.000000001" },
1384 { -1.0e9, NULL, 0, FMTFLAG_fixed, "-1000000000" },
1385 { -1.0e9, NULL, 6, FMTFLAG_fixed, "-1000000000.000000" },
1387 { -1.23456789e9, NULL, 0, 0, "-1.23457e+009" },
1388 { -1.23456789e9, NULL, 0, FMTFLAG_fixed, "-1234567890" },
1389 { -1.23456789e9, NULL, 6, FMTFLAG_fixed, "-1234567890.000000" },
1390 { -1.23456789e-9, NULL, 6, FMTFLAG_fixed, "-0.000000" },
1391 { -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
1394 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1395 /* char version */
1396 call_func1(p_basic_stringstream_char_ctor, &ss);
1398 if(tests[i].lcl) {
1399 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1400 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
1403 /* set format and precision only if specified, so we can try defaults */
1404 if(tests[i].fmtfl)
1405 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1406 if(tests[i].prec != -1)
1407 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
1408 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, tests[i].val);
1410 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
1411 str = call_func1(p_basic_string_char_cstr, &pstr);
1413 ok(!strcmp(tests[i].str, str), "wrong output, expected = %s found = %s\n", tests[i].str, str);
1414 call_func1(p_basic_string_char_dtor, &pstr);
1416 if(tests[i].lcl)
1417 call_func1(p_locale_dtor, &lcl);
1419 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1421 /* wchar_t version */
1422 call_func1(p_basic_stringstream_wchar_ctor, &wss);
1424 if(tests[i].lcl) {
1425 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
1426 call_func3(p_basic_ios_wchar_imbue, &wss.basic_ios, &retlcl, &lcl);
1429 /* set format and precision only if specified, so we can try defaults */
1430 if(tests[i].fmtfl)
1431 call_func3(p_ios_base_setf_mask, &wss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
1432 if(tests[i].prec != -1)
1433 call_func2(p_ios_base_precision_set, &wss.basic_ios.base, tests[i].prec);
1434 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, tests[i].val);
1436 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
1437 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
1439 AtoW(wide, tests[i].str, strlen(tests[i].str));
1440 ok(!lstrcmpW(wide, wstr), "wrong output, expected = %s found = %s\n", tests[i].str, wine_dbgstr_w(wstr));
1441 call_func1(p_basic_string_wchar_dtor, &pwstr);
1443 if(tests[i].lcl)
1444 call_func1(p_locale_dtor, &lcl);
1446 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1451 static void test_istream_ipfx(void)
1453 unsigned short testus, nextus;
1454 basic_stringstream_wchar wss;
1455 basic_stringstream_char ss;
1456 basic_string_wchar wstr;
1457 basic_string_char str;
1458 IOSB_iostate state;
1459 wchar_t wide[64];
1460 int i, ret, next;
1462 /* makes tables narrower */
1463 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1465 struct _test_istream_ipfx {
1466 const char *str;
1467 int unset_skipws;
1468 int noskip;
1469 int ret;
1470 IOSB_iostate state;
1471 int next;
1472 } tests[] = {
1473 /* string unset noskip return state next char */
1474 { "", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* empty string */
1475 { " ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* just ws */
1476 { "\t \n \f ", FALSE, FALSE, FALSE, IOSTATE_faileof, EOF }, /* different ws */
1477 { "simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1478 { " simple", FALSE, FALSE, TRUE, IOSTATE_goodbit, 's' },
1479 { " simple", TRUE, FALSE, TRUE, IOSTATE_goodbit, ' ' }, /* unset skipws */
1480 { " simple", FALSE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* ipfx(true) */
1481 { " simple", TRUE, TRUE, TRUE, IOSTATE_goodbit, ' ' }, /* both */
1482 { "\n\t ws", FALSE, FALSE, TRUE, IOSTATE_goodbit, 'w' },
1483 { "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
1486 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1487 /* char version */
1488 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1489 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1491 /* set format and precision only if specified, so we can try defaults */
1492 if(tests[i].unset_skipws)
1493 call_func2(p_ios_base_unsetf, &ss.basic_ios.base, TRUE);
1495 ret = (int)call_func2(p_basic_istream_char_ipfx, &ss.base.base1, tests[i].noskip);
1496 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1497 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1499 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1500 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1501 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1503 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1504 call_func1(p_basic_string_char_dtor, &str);
1506 /* wchar_t version */
1507 AtoW(wide, tests[i].str, strlen(tests[i].str));
1508 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1509 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1511 /* set format and precision only if specified, so we can try defaults */
1512 if(tests[i].unset_skipws)
1513 call_func2(p_ios_base_unsetf, &wss.basic_ios.base, TRUE);
1515 ret = (int)call_func2(p_basic_istream_wchar_ipfx, &wss.base.base1, tests[i].noskip);
1516 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1517 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1519 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1520 ok(tests[i].ret == ret, "wrong return, expected = %i found = %i\n", tests[i].ret, ret);
1521 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1522 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1524 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1525 call_func1(p_basic_string_wchar_dtor, &wstr);
1530 static void test_istream_ignore(void)
1532 unsigned short testus, nextus;
1533 basic_stringstream_wchar wss;
1534 basic_stringstream_char ss;
1535 basic_string_wchar wstr;
1536 basic_string_char str;
1537 IOSB_iostate state;
1538 wchar_t wide[64];
1539 int i, next;
1541 struct _test_istream_ignore {
1542 const char *str;
1543 streamsize count;
1544 int delim;
1545 IOSB_iostate state;
1546 int next;
1547 } tests[] = {
1548 /* string count delim state next */
1549 { "", 0, '\n', IOSTATE_goodbit, EOF }, /* empty string */
1551 /* different counts */
1552 { "ABCDEF", 2, '\n', IOSTATE_goodbit, 'C' }, /* easy case */
1553 { "ABCDEF", 42, '\n', IOSTATE_eofbit, EOF }, /* ignore too much */
1554 { "ABCDEF", -2, '\n', IOSTATE_goodbit, 'A' }, /* negative count */
1555 { "ABCDEF", 6, '\n', IOSTATE_goodbit, EOF }, /* is eof not set at end */
1556 { "ABCDEF", 7, '\n', IOSTATE_eofbit, EOF }, /* eof is set just after end */
1558 /* different delimiters */
1559 { "ABCDEF", 42, '\0', IOSTATE_eofbit, EOF }, /* null as delim */
1560 { "ABC DEF GHI", 0, ' ', IOSTATE_goodbit, 'A' },
1561 { "ABC DEF GHI", 42, ' ', IOSTATE_goodbit, 'D' },
1562 { "ABC DEF\tGHI", 42, '\t', IOSTATE_goodbit, 'G' },
1563 { "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
1566 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1567 /* char version */
1568 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1569 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1571 call_func3(p_basic_istream_char_ignore, &ss.base.base1, tests[i].count, tests[i].delim);
1572 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1573 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1575 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1576 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1578 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1579 call_func1(p_basic_string_char_dtor, &str);
1581 /* wchar_t version */
1582 AtoW(wide, tests[i].str, strlen(tests[i].str));
1583 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1584 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1586 call_func3(p_basic_istream_wchar_ignore, &wss.base.base1, tests[i].count, tests[i].delim);
1587 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1588 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1590 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1591 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1592 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1594 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1595 call_func1(p_basic_string_wchar_dtor, &wstr);
1600 static void test_istream_seekg(void)
1602 unsigned short testus, nextus;
1603 basic_stringstream_wchar wss;
1604 basic_stringstream_char ss;
1605 basic_string_wchar wstr;
1606 basic_string_char str;
1607 IOSB_iostate state;
1608 wchar_t wide[64];
1609 int i, next;
1611 struct _test_istream_seekg {
1612 const char *str;
1613 streamoff off;
1614 IOSB_seekdir dir;
1615 IOSB_iostate state;
1616 int next;
1617 } tests[] = {
1618 { "ABCDEFGHIJ", 0, SEEKDIR_beg, IOSTATE_goodbit, 'A' },
1619 { "ABCDEFGHIJ", 1, SEEKDIR_beg, IOSTATE_goodbit, 'B' },
1620 { "ABCDEFGHIJ", 5, SEEKDIR_cur, IOSTATE_goodbit, 'F' },
1621 { "ABCDEFGHIJ", -3, SEEKDIR_end, IOSTATE_goodbit, 'H' },
1623 /* bad offsets */
1624 { "ABCDEFGHIJ", -1, SEEKDIR_beg, IOSTATE_failbit, EOF },
1625 { "ABCDEFGHIJ", 42, SEEKDIR_cur, IOSTATE_failbit, EOF },
1626 { "ABCDEFGHIJ", 42, SEEKDIR_end, IOSTATE_failbit, EOF },
1627 { "", 0, SEEKDIR_beg, IOSTATE_failbit, EOF },
1630 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1631 /* char version */
1632 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1633 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1635 call_func3(p_basic_istream_char_seekg, &ss.base.base1, tests[i].off, tests[i].dir);
1636 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1637 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1639 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1640 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1642 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1643 call_func1(p_basic_string_char_dtor, &str);
1645 /* wchar_t version */
1646 AtoW(wide, tests[i].str, strlen(tests[i].str));
1647 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1648 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1650 call_func3(p_basic_istream_wchar_seekg, &wss.base.base1, tests[i].off, tests[i].dir);
1651 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1652 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1654 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1655 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1656 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1658 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1659 call_func1(p_basic_string_wchar_dtor, &wstr);
1664 static void test_istream_seekg_fpos(void)
1666 unsigned short testus, nextus;
1667 basic_stringstream_wchar wss;
1668 basic_stringstream_char ss;
1669 basic_string_wchar wstr;
1670 basic_string_char str;
1671 IOSB_iostate state;
1672 wchar_t wide[64];
1673 fpos_int pos;
1674 int i, next;
1676 struct _test_istream_seekg_fpos {
1677 const char *str;
1678 streamoff off;
1679 IOSB_iostate state;
1680 int next;
1681 } tests[] = {
1682 { "ABCDEFGHIJ", 0, IOSTATE_goodbit, 'A' },
1683 { "ABCDEFGHIJ", 9, IOSTATE_goodbit, 'J' },
1684 { "ABCDEFGHIJ", 10, IOSTATE_goodbit, EOF }, /* beyond end, but still good */
1685 { "ABCDEFGHIJ", -1, IOSTATE_failbit, EOF },
1686 { "", 0, IOSTATE_failbit, EOF },
1689 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1690 /* char version */
1691 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1692 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1694 pos.off = tests[i].off;
1695 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1696 pos.state = 0;
1697 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, pos);
1698 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1699 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1701 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1702 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1704 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1705 call_func1(p_basic_string_char_dtor, &str);
1707 /* wchar_t version */
1708 AtoW(wide, tests[i].str, strlen(tests[i].str));
1709 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1710 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1712 pos.off = tests[i].off;
1713 pos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1714 pos.state = 0;
1715 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, pos);
1716 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1717 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1719 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1720 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1721 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1723 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1724 call_func1(p_basic_string_wchar_dtor, &wstr);
1729 static void test_istream_peek(void)
1731 unsigned short testus, nextus, peekus;
1732 basic_stringstream_wchar wss;
1733 basic_stringstream_char ss;
1734 basic_string_wchar wstr;
1735 basic_string_char str;
1736 IOSB_iostate state;
1737 int i, next, peek;
1738 wchar_t wide[64];
1740 struct _test_istream_peek {
1741 const char *str;
1742 int peek;
1743 int next;
1744 IOSB_iostate state;
1745 } tests[] = {
1746 { "", EOF, EOF, IOSTATE_eofbit },
1747 { "ABCDEF", 'A', 'A', IOSTATE_goodbit },
1750 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1751 /* char version */
1752 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1753 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1755 peek = (int)call_func1(p_basic_istream_char_peek, &ss.base.base1);
1756 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1757 next = (int)call_func1(p_basic_istream_char_get, &ss.base.base1);
1759 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1760 ok(tests[i].next == next, "wrong next, expected = %c (%i) found = %c (%i)\n", tests[i].next, tests[i].next, next, next);
1761 ok(peek == next, "wrong peek, expected %c (%i) found = %c (%i)\n", peek, peek, next, next);
1763 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1764 call_func1(p_basic_string_char_dtor, &str);
1766 /* wchar_t version */
1767 AtoW(wide, tests[i].str, strlen(tests[i].str));
1768 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1769 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1771 peekus = (unsigned short)(int)call_func1(p_basic_istream_wchar_peek, &wss.base.base1);
1772 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1773 nextus = (unsigned short)(int)call_func1(p_basic_istream_wchar_get, &wss.base.base1);
1775 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1776 testus = tests[i].next == EOF ? WEOF : (unsigned short)tests[i].next;
1777 ok(testus == nextus, "wrong next, expected = %c (%i) found = %c (%i)\n", testus, testus, nextus, nextus);
1778 ok(peekus == nextus, "wrong peek, expected %c (%i) found = %c (%i)\n", peekus, peekus, nextus, nextus);
1780 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1781 call_func1(p_basic_string_wchar_dtor, &wstr);
1786 static void test_istream_tellg(void)
1788 basic_stringstream_wchar wss;
1789 basic_stringstream_char ss;
1790 basic_fstream_wchar wfs;
1791 basic_fstream_char fs;
1792 basic_string_wchar wstr;
1793 basic_string_char str;
1794 fpos_int spos, tpos, *rpos;
1795 wchar_t wide[64];
1796 FILE *file;
1797 int i;
1799 const char *testfile = "file.txt";
1801 struct _test_istream_tellg_fpos {
1802 const char *str;
1803 streamoff seekoff;
1804 streamoff telloff_ss; /* offset for stringstream */
1805 streamoff telloff_fs; /* offset for fstream */
1806 __int64 tellpos;
1807 } tests[] = {
1808 /* empty strings */
1809 { "", -1, -1, 0, 0 }, /* tellg on defaults */
1810 { "", 0, -1, 0, 0 }, /* tellg after seek 0 */
1811 { "", 42, -1, 0, 42 }, /* tellg after seek beyond end */
1812 { "", -6, -1, -1, 0 }, /* tellg after seek beyond beg */
1814 /* non-empty strings */
1815 { "ABCDEFGHIJ", -1, 0, 0, 0 },
1816 { "ABCDEFGHIJ", 3, 3, 0, 3 },
1817 { "ABCDEFGHIJ", 42, -1, 0, 42 },
1818 { "ABCDEFGHIJ", -6, -1, -1, 0 }
1821 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1822 /* stringstream<char> version */
1823 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1824 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1826 spos.off = tests[i].seekoff;
1827 spos.pos = 0;
1828 spos.state = 0;
1830 tpos.off = 0xdeadbeef;
1831 tpos.pos = 0xdeadbeef;
1832 tpos.state = 0xdeadbeef;
1834 if (tests[i].seekoff != -1) /* to test without seek */
1835 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &ss.base.base1, spos);
1836 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &ss.base.base1, &tpos);
1838 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1839 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1840 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1841 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1842 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1843 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1845 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1846 call_func1(p_basic_string_char_dtor, &str);
1848 /* stringstream<wchar_t> version */
1849 AtoW(wide, tests[i].str, strlen(tests[i].str));
1850 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1851 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1853 spos.off = tests[i].seekoff;
1854 spos.pos = 0; /* FIXME: a later patch will test this with filebuf */
1855 spos.state = 0;
1857 tpos.off = 0xdeadbeef;
1858 tpos.pos = 0xdeadbeef;
1859 tpos.state = 0xdeadbeef;
1861 if (tests[i].seekoff != -1) /* to test without seek */
1862 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wss.base.base1, spos);
1863 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wss.base.base1, &tpos);
1865 ok(tests[i].telloff_ss == tpos.off, "wrong offset, expected = %ld found = %ld\n", tests[i].telloff_ss, tpos.off);
1866 if (tests[i].telloff_ss != -1 && spos.off != -1) /* check if tell == seek but only if not hit EOF */
1867 ok(spos.off == tpos.off, "tell doesn't match seek, seek = %ld tell = %ld\n", spos.off, tpos.off);
1868 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1869 ok(tpos.pos == 0, "wrong position, expected = 0 found = %s\n", debugstr_longlong(tpos.pos));
1870 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1872 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
1873 call_func1(p_basic_string_wchar_dtor, &wstr);
1875 /* filebuf */
1876 file = fopen(testfile, "wt");
1877 fprintf(file, tests[i].str);
1878 fclose(file);
1880 /* fstream<char> version */
1881 call_func5(p_basic_fstream_char_ctor_name, &fs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1883 spos.off = tests[i].seekoff;
1884 spos.pos = 0;
1885 spos.state = 0;
1887 tpos.off = 0xdeadbeef;
1888 tpos.pos = 0xdeadbeef;
1889 tpos.state = 0xdeadbeef;
1891 if (tests[i].seekoff != -1) /* to test without seek */
1892 call_func2_ptr_fpos(p_basic_istream_char_seekg_fpos, &fs.base.base1, spos);
1893 rpos = (fpos_int *)call_func2(p_basic_istream_char_tellg, &fs.base.base1, &tpos);
1895 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1896 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1897 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1898 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1899 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1901 call_func1(p_basic_fstream_char_vbase_dtor, &fs);
1903 /* fstream<wchar_t> version */
1904 call_func5(p_basic_fstream_wchar_ctor_name, &wfs, testfile, OPENMODE_out|OPENMODE_in, SH_DENYNO, TRUE);
1906 spos.off = tests[i].seekoff;
1907 spos.pos = 0;
1908 spos.state = 0;
1910 tpos.off = 0xdeadbeef;
1911 tpos.pos = 0xdeadbeef;
1912 tpos.state = 0xdeadbeef;
1914 if (tests[i].seekoff != -1) /* to test without seek */
1915 call_func2_ptr_fpos(p_basic_istream_wchar_seekg_fpos, &wfs.base.base1, spos);
1916 rpos = (fpos_int *)call_func2(p_basic_istream_wchar_tellg, &wfs.base.base1, &tpos);
1918 ok(tests[i].tellpos == tpos.pos, "wrong filepos, expected = %s found = %s\n",
1919 debugstr_longlong(tests[i].tellpos), debugstr_longlong(tpos.pos));
1920 ok(rpos == &tpos, "wrong return fpos, expected = %p found = %p\n", rpos, &tpos);
1921 ok(tpos.off == tests[i].telloff_fs, "wrong offset, expected %ld found %ld\n", tests[i].telloff_fs, tpos.off);
1922 ok(tpos.state == 0, "wrong state, expected = 0 found = %d\n", tpos.state);
1924 call_func1(p_basic_fstream_wchar_vbase_dtor, &wfs);
1926 unlink(testfile);
1931 static void test_istream_getline(void)
1933 basic_stringstream_wchar wss;
1934 basic_stringstream_char ss;
1935 basic_string_wchar wstr;
1936 basic_string_char str;
1937 IOSB_iostate state;
1938 wchar_t wide[64];
1939 int i;
1940 const char *cstr;
1941 const wchar_t *wcstr;
1943 /* makes tables narrower */
1944 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
1946 struct _test_istream_getline {
1947 const char *str;
1948 const char *line;
1949 int delim;
1950 IOSB_iostate state;
1951 const char *nextline;
1952 int nextdelim;
1953 IOSB_iostate nextstate;
1954 } tests[] = {
1955 { "", "", '\n', IOSTATE_faileof, "", '\n', IOSTATE_faileof },
1957 { "this\n", "this", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1958 { "this\nis\nsome\ntext\n", "this", '\n', IOSTATE_goodbit, "is", '\n', IOSTATE_goodbit },
1960 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is", ' ', IOSTATE_goodbit },
1961 { "this is some text\n", "this", ' ', IOSTATE_goodbit, "is some text", '\n', IOSTATE_goodbit },
1963 { "this is some text\n", "this is some text", '\n', IOSTATE_goodbit, "", '\n', IOSTATE_faileof },
1964 { "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit, "this is some text\n", '\n', IOSTATE_faileof },
1967 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
1968 /* char version */
1969 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
1970 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
1972 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].delim);
1973 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1974 cstr = call_func1(p_basic_string_char_cstr, &str);
1976 ok(!strcmp(tests[i].line, cstr), "wrong line, expected = %s found = %s\n", tests[i].line, cstr);
1977 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
1979 /* next line */
1980 p_basic_istream_char_getline_bstr_delim(&ss.base.base1, &str, tests[i].nextdelim);
1981 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
1982 cstr = call_func1(p_basic_string_char_cstr, &str);
1984 ok(!strcmp(tests[i].nextline, cstr), "wrong next line, expected = %s found = %s\n", tests[i].nextline, cstr);
1985 ok(tests[i].nextstate == state, "wrong next state, expected = %x found = %x\n", tests[i].nextstate, state);
1987 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
1988 call_func1(p_basic_string_char_dtor, &str);
1990 /* wchar_t version */
1991 AtoW(wide, tests[i].str, strlen(tests[i].str));
1992 call_func2(p_basic_string_wchar_ctor_cstr, &wstr, wide);
1993 call_func4(p_basic_stringstream_wchar_ctor_str, &wss, &wstr, OPENMODE_out|OPENMODE_in, TRUE);
1995 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].delim);
1996 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
1997 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
1999 AtoW(wide, tests[i].line, strlen(tests[i].line));
2000 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].line, wine_dbgstr_w(wcstr));
2001 ok(tests[i].state == state, "wrong state, expected = %x found = %x\n", tests[i].state, state);
2003 /* next line */
2004 p_basic_istream_wchar_getline_bstr_delim(&wss.base.base1, &wstr, tests[i].nextdelim);
2005 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &wss.basic_ios.base);
2006 wcstr = call_func1(p_basic_string_wchar_cstr, &wstr);
2008 AtoW(wide, tests[i].nextline, strlen(tests[i].nextline));
2009 ok(!lstrcmpW(wide, wcstr), "wrong line, expected = %s found = %s\n", tests[i].nextline, wine_dbgstr_w(wcstr));
2010 ok(tests[i].nextstate == state, "wrong state, expected = %x found = %x\n", tests[i].nextstate, state);
2012 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2013 call_func1(p_basic_string_wchar_dtor, &wstr);
2017 static void test_ostream_print_ushort(void)
2019 static const wchar_t str65[] = { '6','5',0 };
2021 basic_stringstream_wchar wss;
2022 basic_string_wchar pwstr;
2023 const wchar_t *wstr;
2025 call_func1(p_basic_stringstream_wchar_ctor, &wss);
2026 call_func2(p_basic_ostream_short_print_ushort, &wss.base.base2, 65);
2028 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
2029 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
2030 ok(!lstrcmpW(str65, wstr), "wstr = %s\n", wine_dbgstr_w(wstr));
2032 call_func1(p_basic_string_wchar_dtor, &pwstr);
2033 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2036 static void test_ostream_print_float(void)
2038 static const char float_str[] = "3.14159";
2040 basic_stringstream_char ss;
2041 basic_string_char pstr;
2042 const char *str;
2043 float val;
2044 val = 3.14159;
2046 call_func1(p_basic_stringstream_char_ctor, &ss);
2047 call_func2_ptr_flt(p_basic_ostream_char_print_float, &ss.base.base2, val);
2048 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2049 str = call_func1(p_basic_string_char_cstr, &pstr);
2050 ok(!strcmp(float_str, str), "str = %s\n", str);
2052 call_func1(p_basic_string_char_dtor, &pstr);
2053 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2056 static void test_ostream_print_double(void)
2058 static const char double_str[] = "3.14159";
2060 basic_stringstream_char ss;
2061 basic_string_char pstr;
2062 const char *str;
2063 double val;
2064 val = 3.14159;
2066 call_func1(p_basic_stringstream_char_ctor, &ss);
2067 call_func2_ptr_dbl(p_basic_ostream_char_print_double, &ss.base.base2, val);
2068 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2069 str = call_func1(p_basic_string_char_cstr, &pstr);
2070 ok(!strcmp(double_str, str), "str = %s\n", str);
2072 call_func1(p_basic_string_char_dtor, &pstr);
2073 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2076 static void test_ostream_wchar_print_double(void)
2078 static const wchar_t double_str[] = { '3', '.', '1', '4', '1', '5', '9', 0 };
2080 basic_stringstream_wchar wss;
2081 basic_string_wchar pwstr;
2082 const wchar_t *wstr;
2083 double val;
2084 val = 3.14159;
2086 call_func1(p_basic_stringstream_wchar_ctor, &wss);
2087 call_func2_ptr_dbl(p_basic_ostream_wchar_print_double, &wss.base.base2, val);
2089 call_func2(p_basic_stringstream_wchar_str_get, &wss, &pwstr);
2090 wstr = call_func1(p_basic_string_wchar_cstr, &pwstr);
2092 ok(!lstrcmpW(double_str, wstr), "wstr = %s\n", wine_dbgstr_w(wstr));
2093 call_func1(p_basic_string_wchar_dtor, &pwstr);
2094 call_func1(p_basic_stringstream_wchar_vbase_dtor, &wss);
2097 static void test_istream_read_float(void)
2099 basic_stringstream_char ss;
2100 basic_string_char str;
2101 const char *test_str;
2102 float val, correct_val;
2104 test_str = "3.14159";
2105 call_func2(p_basic_string_char_ctor_cstr, &str, test_str);
2106 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_in, TRUE);
2108 val = 0;
2109 call_func2(p_basic_istream_char_read_float, &ss.base.base1, &val);
2110 correct_val = 3.14159;
2111 ok(correct_val == val, "wrong val, expected = %g found %g\n", correct_val, val);
2113 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2114 call_func1(p_basic_string_char_dtor, &str);
2117 static void test_istream_read_double(void)
2119 basic_stringstream_char ss;
2120 basic_string_char str;
2121 const char *test_str;
2122 double val, correct_val;
2124 test_str = "3.14159";
2125 call_func2(p_basic_string_char_ctor_cstr, &str, test_str);
2126 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_in, TRUE);
2128 val = 0;
2129 call_func2(p_basic_istream_char_read_double, &ss.base.base1, &val);
2130 correct_val = 3.14159;
2131 ok(correct_val == val, "wrong val, expected = %g found %g\n", correct_val, val);
2133 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2134 call_func1(p_basic_string_char_dtor, &str);
2137 static void test_ostream_print_complex_float(void)
2139 basic_stringstream_char ss;
2140 basic_string_char pstr;
2141 const char *str;
2142 locale lcl, retlcl;
2143 int i;
2144 struct _test_print_complex_float {
2145 complex_float val;
2146 const char *lcl;
2147 streamsize prec; /* set to -1 for default */
2148 IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */
2149 const char *str;
2150 } tests[] = {
2151 /* simple cases */
2152 { {0.123,-4.5}, NULL, -1, 0, "(0.123,-4.5)" },
2153 { {0.123,-4.5}, NULL, 6, 0, "(0.123,-4.5)" },
2154 { {0.123,-4.5}, NULL, 0, 0, "(0.123,-4.5)" },
2156 /*{ fixed format */
2157 { {0.123,-4.6}, NULL, 0, FMTFLAG_fixed, "(0,-5)" },
2158 { {0.123,-4.6}, NULL, -1, FMTFLAG_fixed, "(0.123000,-4.600000)" },
2159 { {0.123,-4.6}, NULL, 6, FMTFLAG_fixed, "(0.123000,-4.600000)" },
2161 /*{ scientific format */
2162 { {123456.789,-4.5678}, NULL, -1, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" },
2163 { {123456.789,-4.5678}, NULL, 0, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" },
2164 { {123456.789,-4.5678}, NULL, 9, FMTFLAG_scientific, "(1.234567891e+005,-4.567800045e+000)" },
2165 { {123456.789,-4.5678}, "German", 9, FMTFLAG_scientific, "(1,234567891e+005,-4,567800045e+000)" },
2167 /*{ different locales */
2168 { {0.123,-4.5}, "C", -1, 0, "(0.123,-4.5)" },
2169 { {0.123,-4.5}, "English", -1, 0, "(0.123,-4.5)" },
2170 { {0.123,-4.5}, "German", -1, 0, "(0,123,-4,5)" },
2172 { {123456.789,-4.5678}, "C", -1, 0, "(123457,-4.5678)" },
2173 { {123456.789,-4.5678}, "English", -1, 0, "(123,457,-4.5678)" },
2174 { {123456.789,-4.5678}, "German", -1, 0, "(123.457,-4,5678)" },
2176 /*{ signs and exponents */
2177 { { 1.0e-9,-4.1e-3}, NULL, -1, 0, "(1e-009,-0.0041)" },
2178 { { 1.0e-9,-4.1e-3}, NULL, 9, 0, "(9.99999972e-010,-0.00410000002)" },
2179 { {-1.0e9,-4.1e-3}, NULL, -1, 0, "(-1e+009,-0.0041)" },
2180 { {-1.0e9,-4.1e-3}, NULL, 9, 0, "(-1e+009,-0.00410000002)" },
2182 { { 1.0e-9,0}, NULL, 0, FMTFLAG_fixed, "(0,0)" },
2183 { { 1.0e-9,0}, NULL, 6, FMTFLAG_fixed, "(0.000000,0.000000)" },
2184 { { 1.0e-9,0}, NULL, 9, FMTFLAG_fixed, "(0.000000001,0.000000000)" },
2185 { {-1.0e9, 0}, NULL, 0, FMTFLAG_fixed, "(-1000000000,0)" },
2186 { {-1.0e9, 0}, NULL, 6, FMTFLAG_fixed, "(-1000000000.000000,0.000000)" },
2188 { {-1.23456789e9,2.3456789e9}, NULL, 0, 0, "(-1.23457e+009,2.34568e+009)" },
2189 { {-1.23456789e9,2.3456789e9}, NULL, 0, FMTFLAG_fixed, "(-1234567936,2345678848)" },
2190 { {-1.23456789e9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-1234567936.000000,2345678848.000000)" },
2191 { {-1.23456789e-9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-0.000000,2345678848.000000)" },
2192 { {-1.23456789e-9,2.3456789e9}, NULL, 9, FMTFLAG_fixed, "(-0.000000001,2345678848.000000000)" }
2195 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
2196 call_func1(p_basic_stringstream_char_ctor, &ss);
2198 if(tests[i].lcl) {
2199 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
2200 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
2203 /* set format and precision only if specified, so we can try defaults */
2204 if(tests[i].fmtfl)
2205 call_func3(p_ios_base_setf_mask, &ss.basic_ios.base, tests[i].fmtfl, FMTFLAG_floatfield);
2206 if(tests[i].prec != -1)
2207 call_func2(p_ios_base_precision_set, &ss.basic_ios.base, tests[i].prec);
2208 p_basic_ostream_char_print_complex_float(&ss.base.base2, &tests[i].val);
2210 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2211 str = call_func1(p_basic_string_char_cstr, &pstr);
2212 ok(!strcmp(str, tests[i].str), "test %d fail, str = %s\n", i+1, str);
2213 call_func1(p_basic_string_char_dtor, &pstr);
2214 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2218 static void test_ostream_print_complex_double(void)
2220 static const char complex_double_str[] = "(3.14159,1.23459)";
2222 basic_stringstream_char ss;
2223 basic_string_char pstr;
2224 const char *str;
2225 complex_double val= {3.14159, 1.23459};
2227 call_func1(p_basic_stringstream_char_ctor, &ss);
2228 p_basic_ostream_char_print_complex_double(&ss.base.base2, &val);
2230 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2231 str = call_func1(p_basic_string_char_cstr, &pstr);
2232 ok(!strcmp(complex_double_str, str), "str = %s\n", str);
2234 call_func1(p_basic_string_char_dtor, &pstr);
2235 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2238 static void test_ostream_print_complex_ldouble(void)
2240 static const char complex_double_str[] = "(3.14159,1.23459)";
2242 basic_stringstream_char ss;
2243 basic_string_char pstr;
2244 const char *str;
2245 complex_double val = {3.14159, 1.23459};
2247 call_func1(p_basic_stringstream_char_ctor, &ss);
2248 p_basic_ostream_char_print_complex_ldouble(&ss.base.base2, &val);
2250 call_func2(p_basic_stringstream_char_str_get, &ss, &pstr);
2251 str = call_func1(p_basic_string_char_cstr, &pstr);
2252 ok(!strcmp(complex_double_str, str), "str = %s\n", str);
2254 call_func1(p_basic_string_char_dtor, &pstr);
2255 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2258 static void test_istream_read_complex_double(void)
2260 basic_string_char str;
2261 IOSB_iostate state;
2262 complex_double val;
2263 locale lcl, retlcl;
2264 basic_stringstream_char ss;
2265 int i;
2266 char next[100];
2267 const char deadbeef_str[] = "(3.14159,3456.7890)";
2268 const complex_double deadbeef = {3.14159, 3456.7890};
2269 const IOSB_iostate IOSTATE_faileof = IOSTATE_failbit|IOSTATE_eofbit;
2271 struct _test_istream_read_complex_double {
2272 const char *complex_double_str;
2273 const char *lcl;
2274 complex_double correct_val;
2275 IOSB_iostate state;
2276 const char *str;
2277 } tests[] = {
2278 /* supported format: real */
2279 { "-12 3", NULL, {-12 , 0}, IOSTATE_goodbit, "3"},
2280 { "1e2,3", NULL, {100 , 0}, IOSTATE_goodbit, ",3"},
2281 { "3E2,,", NULL, {300 , 0}, IOSTATE_goodbit, ",,"},
2283 /* supported format: (real) */
2284 { "(3.)", NULL, {3., 0}, IOSTATE_goodbit, "" },
2285 { "(3E10)1", NULL, {3e+10, 0}, IOSTATE_goodbit, "1"},
2287 /* supported format: (real,imaginary) */
2288 { "(3, -.4)", NULL, {3, -0.4} , IOSTATE_goodbit, ""},
2289 { " (6.6,\n1.1\t)", NULL, {6.6, 1.1}, IOSTATE_goodbit, ""},
2290 { "(6.666 , 7.77)mark", NULL, {6.666, 7.77}, IOSTATE_goodbit, "mark"},
2292 /* different locales */
2293 { "1,234e10", "English", {1234.0e10, 0}, IOSTATE_eofbit, ""},
2294 { "1,234e10", "German" , {1.234e10, 0}, IOSTATE_eofbit, ""},
2295 { "1,234,567,890", "English", {1234567890.0, 0}, IOSTATE_eofbit , ""},
2296 { "1,234,567,890", "German" , {1.234, 0} , IOSTATE_goodbit, ",567,890"},
2297 { "(0.123,-4.5)", "English", {0.123,-4.5}, IOSTATE_goodbit, ""},
2298 { "(0,123,4,5)" , "German" , {0.123,4.5 }, IOSTATE_goodbit, ""},
2299 { "(123,456.,4.5678)", "English", {123456,4.5678}, IOSTATE_goodbit, ""},
2300 { "(123.456,,4,5678)", "German" , {123456,4.5678}, IOSTATE_goodbit, ""},
2302 /* eofbit */
2303 { ".09", NULL, {0.09, 0}, IOSTATE_eofbit, ""},
2304 { "\t-1e2", NULL, {-100, 0}, IOSTATE_eofbit, ""},
2305 { "+", NULL, deadbeef, IOSTATE_faileof, ""},
2306 { "(-1.1,3 \t " , NULL, deadbeef, IOSTATE_faileof, ""},
2307 { "(-1.1 , \t -3.4E3 \t ", NULL, deadbeef, IOSTATE_faileof, ""},
2309 /* nonsupported formats */
2310 { "(*)" , NULL, deadbeef, IOSTATE_failbit, ""},
2311 { "(\n*" , NULL, deadbeef, IOSTATE_failbit, ""},
2312 { "(6..)" , NULL, deadbeef, IOSTATE_failbit, ""},
2313 { "(3.12,*", NULL, deadbeef, IOSTATE_failbit, ""},
2314 { "(3.12,)", NULL, deadbeef, IOSTATE_failbit, ""},
2315 { "(1.0eE10, 3)" , NULL, deadbeef, IOSTATE_failbit, ""},
2318 for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
2319 call_func2(p_basic_string_char_ctor_cstr, &str, deadbeef_str);
2320 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
2321 p_basic_istream_char_read_complex_double(&ss.base.base1, &val);
2323 call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].complex_double_str);
2324 call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
2325 if(tests[i].lcl) {
2326 call_func3(p_locale_ctor_cstr, &lcl, tests[i].lcl, 0x3f /* FIXME: support categories */);
2327 call_func3(p_basic_ios_char_imbue, &ss.basic_ios, &retlcl, &lcl);
2329 p_basic_istream_char_read_complex_double(&ss.base.base1, &val);
2330 state = (IOSB_iostate)call_func1(p_ios_base_rdstate, &ss.basic_ios.base);
2332 memset(next, 0, sizeof(next));
2333 p_basic_istream_char_read_str(&ss.base.base1, next);
2335 ok(tests[i].state == state, "test %d fail, wrong state, expected = %x found = %x\n", i+1, tests[i].state, state);
2336 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);
2337 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);
2338 ok(!strcmp(tests[i].str, next), "test %d fail, wrong next, expected = %s found %s\n", i+1, tests[i].str, next);
2340 if(tests[i].lcl)
2341 call_func1(p_locale_dtor, &lcl);
2342 call_func1(p_basic_stringstream_char_vbase_dtor, &ss);
2343 call_func1(p_basic_string_char_dtor, &str);
2347 START_TEST(ios)
2349 if(!init())
2350 return;
2352 test_num_get_get_uint64();
2353 test_num_get_get_double();
2354 test_num_put_put_double();
2355 test_istream_ipfx();
2356 test_istream_ignore();
2357 test_istream_seekg();
2358 test_istream_seekg_fpos();
2359 test_istream_peek();
2360 test_istream_tellg();
2361 test_istream_getline();
2362 test_ostream_print_ushort();
2363 test_ostream_print_float();
2364 test_ostream_print_double();
2365 test_ostream_wchar_print_double();
2366 test_istream_read_float();
2367 test_istream_read_double();
2368 test_ostream_print_complex_float();
2369 test_ostream_print_complex_double();
2370 test_ostream_print_complex_ldouble();
2371 test_istream_read_complex_double();
2373 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
2375 FreeLibrary(msvcr);
2376 FreeLibrary(msvcp);