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