mfreadwrite/reader: Add missing allocation check (Coverity).
[wine/zf.git] / dlls / msvcp90 / tests / misc.c
blob9d6fe2b9bcc529aa1520b73c8d514a155b284435
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 <wctype.h>
22 #include <math.h>
23 #include <float.h>
24 #include <errno.h>
26 #include <windef.h>
27 #include <winbase.h>
28 #include "wine/test.h"
30 static inline float __port_ind(void)
32 static const unsigned __ind_bytes = 0xffc00000;
33 return *(const float *)&__ind_bytes;
35 #define IND __port_ind()
37 typedef double LDOUBLE; /* long double is just a double */
39 typedef struct {
40 LCID handle;
41 unsigned page;
42 short *table;
43 int delfl;
44 } MSVCP__Ctypevec;
46 typedef struct {
47 LCID handle;
48 unsigned page;
49 } MSVCP__Collvec;
51 /* basic_string<char, char_traits<char>, allocator<char>> */
52 #define BUF_SIZE_CHAR 16
53 typedef struct
55 void *allocator;
56 union {
57 char buf[BUF_SIZE_CHAR];
58 char *ptr;
59 } data;
60 size_t size;
61 size_t res;
62 } basic_string_char;
64 /* class complex<float> */
65 typedef struct {
66 float real;
67 float imag;
68 } complex_float;
70 typedef struct {
71 void *vtable;
72 size_t refs;
73 } locale_facet;
75 typedef unsigned char MSVCP_bool;
77 typedef struct _locale__Locimp {
78 locale_facet facet;
79 locale_facet **facetvec;
80 size_t facet_cnt;
81 int catmask;
82 MSVCP_bool transparent;
83 basic_string_char name;
84 } locale__Locimp;
86 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
87 static _locale_t (__cdecl *p__get_current_locale)(void);
88 static void (__cdecl *p__free_locale)(_locale_t);
89 static void (__cdecl *p_free)(void*);
90 static int * (__cdecl *p_errno)(void);
92 static void (__cdecl *p_char_assign)(void*, const void*);
93 static void (__cdecl *p_wchar_assign)(void*, const void*);
94 static void (__cdecl *p_short_assign)(void*, const void*);
96 static BYTE (__cdecl *p_char_eq)(const void*, const void*);
97 static BYTE (__cdecl *p_wchar_eq)(const void*, const void*);
98 static BYTE (__cdecl *p_short_eq)(const void*, const void*);
100 static char* (__cdecl *p_Copy_s)(char*, size_t, const char*, size_t);
102 static unsigned short (__cdecl *p_wctype)(const char*);
103 static MSVCP__Ctypevec* (__cdecl *p__Getctype)(MSVCP__Ctypevec*);
104 static /*MSVCP__Collvec*/ULONGLONG (__cdecl *p__Getcoll)(void);
105 static wctrans_t (__cdecl *p_wctrans)(const char*);
106 static wint_t (__cdecl *p_towctrans)(wint_t, wctrans_t);
107 static void (__cdecl *p_locale__Locimp__Locimp_Addfac)(locale__Locimp*,locale_facet*,size_t);
108 static size_t (__cdecl *p__Strxfrm)(char*, char*, const char*, const char*, const MSVCP__Collvec*);
109 static size_t (__cdecl *p__Wcsxfrm)(wchar_t*, wchar_t*, const wchar_t*,
110 const wchar_t*, const MSVCP__Collvec*);
112 #undef __thiscall
113 #ifdef __i386__
114 #define __thiscall __stdcall
115 #else
116 #define __thiscall __cdecl
117 #endif
119 static char* (__thiscall *p_char_address)(void*, char*);
120 static void* (__thiscall *p_char_ctor)(void*);
121 static void (__thiscall *p_char_deallocate)(void*, char*, size_t);
122 static char* (__thiscall *p_char_allocate)(void*, size_t);
123 static void (__thiscall *p_char_construct)(void*, char*, const char*);
124 static size_t (__thiscall *p_char_max_size)(void*);
126 static void* (__thiscall *p_collate_char_ctor_refs)(void*, size_t);
127 static int (__thiscall *p_collate_char_compare)(const void*, const char*,
128 const char*, const char*, const char*);
129 static void (__thiscall *p_collate_char_dtor)(void*);
130 static void* (__thiscall *p_numpunct_char_ctor)(void*);
131 static basic_string_char* (__thiscall *p_numpunct_char_falsename)(void*,basic_string_char*);
132 static void (__thiscall *p_numpunct_char_dtor)(void*);
133 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
134 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
136 static const int *basic_ostringstream_char_vbtable;
137 static /*basic_ostringstream_char*/void* (__thiscall *p_basic_ostringstream_char_ctor_mode)(
138 /*basic_ostringstream_char*/void*, int, /*MSVCP_bool*/int);
139 static void (__thiscall *p_basic_ostringstream_char_dtor)(/*basic_ostringstream_char*/void*);
140 static void (__thiscall *p_basic_ostringstream_char_vbase_dtor)(/*basic_ostringstream_char*/void*);
141 static void (__thiscall *p_basic_ios_char_dtor)(/*basic_ios_char*/void*);
143 static BOOL (__cdecl *p_std_Ctraits_float__Isnan)(float);
144 static BOOL (__cdecl *p_std_Ctraits_double__Isnan)(double);
145 static BOOL (__cdecl *p_std_Ctraits_long_double__Isnan)(LDOUBLE);
147 static complex_float* (__thiscall *p_complex_float_ctor)(complex_float*, const float*, const float*);
148 static complex_float* (__cdecl *p_complex_float_add)(complex_float*, const complex_float*, const complex_float*);
149 static complex_float* (__cdecl *p_complex_float_div)(complex_float*, const complex_float*, const complex_float*);
150 static float (__cdecl *p_complex_float__Fabs)(const complex_float*, int*);
151 static complex_float* (__cdecl *p_complex_float_tan)(complex_float*, const complex_float*);
152 static complex_float* (__cdecl *p_complex_float_tanh)(complex_float*, const complex_float*);
153 static complex_float* (__cdecl *p_complex_float_log10)(complex_float*, const complex_float*);
154 static complex_float* (__cdecl *p_complex_float_sqrt)(complex_float*, const complex_float*);
155 static complex_float* (__cdecl *p_complex_float_pow_ci)(complex_float*, const complex_float*, int);
156 static complex_float* (__cdecl *p_complex_float_pow_fc)(complex_float*, const float*, const complex_float*);
157 static complex_float* (__cdecl *p_complex_float_pow_cf)(complex_float*, const complex_float*, const float*);
159 static void (CDECL **p_Raise_handler)(const void*);
161 static int invalid_parameter = 0;
162 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
163 const wchar_t *function, const wchar_t *file,
164 unsigned line, uintptr_t arg)
166 ok(expression == NULL, "expression is not NULL\n");
167 ok(function == NULL, "function is not NULL\n");
168 ok(file == NULL, "file is not NULL\n");
169 ok(line == 0, "line = %u\n", line);
170 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
171 invalid_parameter++;
174 /* Emulate a __thiscall */
175 #ifdef __i386__
177 #include "pshpack1.h"
178 struct thiscall_thunk
180 BYTE pop_eax; /* popl %eax (ret addr) */
181 BYTE pop_edx; /* popl %edx (func) */
182 BYTE pop_ecx; /* popl %ecx (this) */
183 BYTE push_eax; /* pushl %eax */
184 WORD jmp_edx; /* jmp *%edx */
186 #include "poppack.h"
188 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
189 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
190 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
191 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
192 const void *c, const void *d );
194 static void init_thiscall_thunk(void)
196 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
197 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
198 thunk->pop_eax = 0x58; /* popl %eax */
199 thunk->pop_edx = 0x5a; /* popl %edx */
200 thunk->pop_ecx = 0x59; /* popl %ecx */
201 thunk->push_eax = 0x50; /* pushl %eax */
202 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
203 call_thiscall_func1 = (void *)thunk;
204 call_thiscall_func2 = (void *)thunk;
205 call_thiscall_func3 = (void *)thunk;
206 call_thiscall_func5 = (void *)thunk;
209 #define call_func1(func,_this) call_thiscall_func1(func,_this)
210 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
211 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
212 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
213 (const void*)(c), (const void *)(d))
215 #else
217 #define init_thiscall_thunk()
218 #define call_func1(func,_this) func(_this)
219 #define call_func2(func,_this,a) func(_this,a)
220 #define call_func3(func,_this,a,b) func(_this,a,b)
221 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
223 #endif /* __i386__ */
225 static HMODULE msvcr, msvcp;
226 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
227 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
228 static BOOL init(void)
230 msvcr = LoadLibraryA("msvcr90.dll");
231 msvcp = LoadLibraryA("msvcp90.dll");
232 if(!msvcr || !msvcp) {
233 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
234 return FALSE;
237 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
238 p__get_current_locale = (void*)GetProcAddress(msvcr, "_get_current_locale");
239 p__free_locale = (void*)GetProcAddress(msvcr, "_free_locale");
240 p_free = (void*)GetProcAddress(msvcr, "free");
241 p_errno = (void*)GetProcAddress(msvcr, "_errno");
242 if(!p_set_invalid_parameter_handler || !p__get_current_locale || !p__free_locale || !p_free || !p_errno) {
243 win_skip("Error setting tests environment\n");
244 return FALSE;
247 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
249 SET(p_wctype, "wctype");
250 SET(p__Getctype, "_Getctype");
251 SET(p__Getcoll, "_Getcoll");
252 SET(p_wctrans, "wctrans");
253 SET(p_towctrans, "towctrans");
254 SET(p__Strxfrm, "_Strxfrm");
255 SET(p__Wcsxfrm, "_Wcsxfrm");
256 SET(basic_ostringstream_char_vbtable, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@");
258 SET(p_std_Ctraits_float__Isnan, "?_Isnan@?$_Ctraits@M@std@@SA_NM@Z");
259 SET(p_std_Ctraits_double__Isnan, "?_Isnan@?$_Ctraits@N@std@@SA_NN@Z");
260 SET(p_std_Ctraits_long_double__Isnan, "?_Isnan@?$_Ctraits@O@std@@SA_NO@Z");
262 if(sizeof(void*) == 8) { /* 64-bit initialization */
263 SET(p_locale__Locimp__Locimp_Addfac,
264 "?_Locimp_Addfac@_Locimp@locale@std@@CAXPEAV123@PEAVfacet@23@_K@Z");
265 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAEADAEBD@Z");
266 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAEA_WAEB_W@Z");
267 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAEAGAEBG@Z");
269 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NAEBD0@Z");
270 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAEB_W0@Z");
271 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NAEBG0@Z");
273 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z");
275 SET(p_char_address, "?address@?$allocator@D@std@@QEBAPEADAEAD@Z");
276 SET(p_char_ctor, "??0?$allocator@D@std@@QEAA@XZ");
277 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QEAAXPEAD_K@Z");
278 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QEAAPEAD_K@Z");
279 SET(p_char_construct, "?construct@?$allocator@D@std@@QEAAXPEADAEBD@Z");
280 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QEBA_KXZ");
282 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QEAA@_K@Z");
283 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QEBAHPEBD000@Z");
284 SET(p_collate_char_dtor, "??1?$collate@D@std@@MEAA@XZ");
285 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QEAAXXZ");
286 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
287 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MEAA@XZ");
288 SET(p_basic_string_char_dtor,
289 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
290 SET(p_basic_string_char_cstr,
291 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
293 SET(p_basic_ostringstream_char_ctor_mode,
294 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z");
295 SET(p_basic_ostringstream_char_dtor,
296 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ");
297 SET(p_basic_ostringstream_char_vbase_dtor,
298 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
299 SET(p_basic_ios_char_dtor,
300 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ");
302 SET(p_complex_float_ctor,
303 "??0?$complex@M@std@@QEAA@AEBM0@Z");
304 SET(p_complex_float_add,
305 "??$?HM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
306 SET(p_complex_float_div,
307 "??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
308 SET(p_complex_float__Fabs,
309 "??$_Fabs@M@std@@YAMAEBV?$complex@M@0@PEAH@Z");
310 SET(p_complex_float_tan,
311 "??$tan@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
312 SET(p_complex_float_tanh,
313 "??$tanh@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
314 SET(p_complex_float_log10,
315 "??$log10@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
316 SET(p_complex_float_sqrt,
317 "??$sqrt@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
318 SET(p_complex_float_pow_ci,
319 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@H@Z");
320 SET(p_complex_float_pow_fc,
321 "??$pow@M@std@@YA?AV?$complex@M@0@AEBMAEBV10@@Z");
322 SET(p_complex_float_pow_cf,
323 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@AEBM@Z");
324 SET(p_Raise_handler,
325 "?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA");
326 } else {
327 SET(p_locale__Locimp__Locimp_Addfac,
328 "?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z");
329 #ifdef __arm__
330 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
331 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
332 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
334 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
335 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
336 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
338 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
340 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
341 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
342 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
343 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
344 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
345 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
347 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
348 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
349 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
350 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
351 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
352 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
353 SET(p_basic_string_char_dtor,
354 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
355 SET(p_basic_string_char_cstr,
356 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
358 SET(p_basic_ostringstream_char_ctor_mode,
359 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
360 SET(p_basic_ostringstream_char_dtor,
361 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
362 SET(p_basic_ostringstream_char_vbase_dtor,
363 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
364 SET(p_basic_ios_char_dtor,
365 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAA@XZ");
367 SET(p_complex_float_ctor,
368 "??0?$complex@M@std@@QAE@ABM0@Z");
369 SET(p_complex_float_add,
370 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
371 SET(p_complex_float_div,
372 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
373 SET(p_complex_float__Fabs,
374 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
375 SET(p_complex_float_tan,
376 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
377 SET(p_complex_float_tanh,
378 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
379 SET(p_complex_float_log10,
380 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
381 SET(p_complex_float_sqrt,
382 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
383 SET(p_complex_float_pow_ci,
384 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
385 SET(p_complex_float_pow_fc,
386 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
387 SET(p_complex_float_pow_cf,
388 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
389 #else
390 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
391 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
392 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
394 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
395 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
396 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
398 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
400 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
401 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
402 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
403 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
404 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
405 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
407 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
408 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
409 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
410 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
411 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
412 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
413 SET(p_basic_string_char_dtor,
414 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
415 SET(p_basic_string_char_cstr,
416 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
418 SET(p_basic_ostringstream_char_ctor_mode,
419 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
420 SET(p_basic_ostringstream_char_dtor,
421 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
422 SET(p_basic_ostringstream_char_vbase_dtor,
423 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
424 SET(p_basic_ios_char_dtor,
425 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ");
427 SET(p_complex_float_ctor,
428 "??0?$complex@M@std@@QAE@ABM0@Z");
429 SET(p_complex_float_add,
430 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
431 SET(p_complex_float_div,
432 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
433 SET(p_complex_float__Fabs,
434 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
435 SET(p_complex_float_tan,
436 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
437 SET(p_complex_float_tanh,
438 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
439 SET(p_complex_float_log10,
440 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
441 SET(p_complex_float_sqrt,
442 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
443 SET(p_complex_float_pow_ci,
444 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
445 SET(p_complex_float_pow_fc,
446 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
447 SET(p_complex_float_pow_cf,
448 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
449 SET(p_Raise_handler,
450 "?_Raise_handler@std@@3P6AXABVexception@stdext@@@ZA");
451 #endif
454 init_thiscall_thunk();
455 return TRUE;
458 static void test_assign(void)
460 const char in[] = "abc";
461 char out[4];
463 out[1] = '#';
464 p_char_assign(out, in);
465 ok(out[0] == in[0], "out[0] = %c\n", out[0]);
466 ok(out[1] == '#', "out[1] = %c\n", out[1]);
468 out[2] = '#';
469 p_wchar_assign(out, in);
470 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
471 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
472 ok(out[2] == '#', "out[2] = %c\n", out[2]);
474 out[2] = '#';
475 p_short_assign(out, in);
476 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
477 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
478 ok(out[2] == '#', "out[2] = %c\n", out[2]);
481 static void test_equal(void)
483 static const char in1[] = "abc";
484 static const char in2[] = "ab";
485 static const char in3[] = "a";
486 static const char in4[] = "b";
487 BYTE ret;
489 ret = p_char_eq(in1, in2);
490 ok(ret == TRUE, "ret = %d\n", (int)ret);
491 ret = p_char_eq(in1, in3);
492 ok(ret == TRUE, "ret = %d\n", (int)ret);
493 ret = p_char_eq(in1, in4);
494 ok(ret == FALSE, "ret = %d\n", (int)ret);
496 ret = p_wchar_eq(in1, in2);
497 ok(ret == TRUE, "ret = %d\n", (int)ret);
498 ret = p_wchar_eq(in1, in3);
499 ok(ret == FALSE, "ret = %d\n", (int)ret);
500 ret = p_wchar_eq(in1, in4);
501 ok(ret == FALSE, "ret = %d\n", (int)ret);
503 ret = p_short_eq(in1, in2);
504 ok(ret == TRUE, "ret = %d\n", (int)ret);
505 ret = p_short_eq(in1, in3);
506 ok(ret == FALSE, "ret = %d\n", (int)ret);
507 ret = p_short_eq(in1, in4);
508 ok(ret == FALSE, "ret = %d\n", (int)ret);
511 static void test_Copy_s(void)
513 static const char src[] = "abcd";
514 char dest[32], *ret;
516 dest[4] = '#';
517 dest[5] = '\0';
518 ret = p_Copy_s(dest, 4, src, 4);
519 ok(ret == dest, "ret != dest\n");
520 ok(dest[4] == '#', "dest[4] != '#'\n");
521 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
523 ret = p_Copy_s(dest, 32, src, 4);
524 ok(ret == dest, "ret != dest\n");
525 ok(dest[4] == '#', "dest[4] != '#'\n");
526 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
528 *p_errno() = 0xdeadbeef;
529 dest[0] = '#';
530 ret = p_Copy_s(dest, 3, src, 4);
531 ok(ret == dest, "ret != dest\n");
532 ok(dest[0] == '\0', "dest[0] != 0\n");
533 ok(invalid_parameter==1, "invalid_parameter = %d\n",
534 invalid_parameter);
535 invalid_parameter = 0;
536 ok(*p_errno() == ERANGE, "errno = %d\n", *p_errno());
538 *p_errno() = 0xdeadbeef;
539 p_Copy_s(NULL, 32, src, 4);
540 ok(invalid_parameter==1, "invalid_parameter = %d\n",
541 invalid_parameter);
542 invalid_parameter = 0;
543 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
545 *p_errno() = 0xdeadbeef;
546 p_Copy_s(dest, 32, NULL, 4);
547 ok(invalid_parameter==1, "invalid_parameter = %d\n",
548 invalid_parameter);
549 invalid_parameter = 0;
550 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
553 static void test_wctype(void)
555 static const struct {
556 const char *name;
557 unsigned short mask;
558 } properties[] = {
559 { "alnum", 0x107 },
560 { "alpha", 0x103 },
561 { "cntrl", 0x020 },
562 { "digit", 0x004 },
563 { "graph", 0x117 },
564 { "lower", 0x002 },
565 { "print", 0x157 },
566 { "punct", 0x010 },
567 { "space", 0x008 },
568 { "upper", 0x001 },
569 { "xdigit", 0x080 },
570 { "ALNUM", 0x000 },
571 { "Alnum", 0x000 },
572 { "", 0x000 }
574 int i, ret;
576 for(i=0; i<ARRAY_SIZE(properties); i++) {
577 ret = p_wctype(properties[i].name);
578 ok(properties[i].mask == ret, "%d - Expected %x, got %x\n", i, properties[i].mask, ret);
582 static void test__Getctype(void)
584 MSVCP__Ctypevec ret;
585 _locale_t locale;
587 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
588 ok(ret.handle == 0, "ret.handle = %d\n", ret.handle);
589 ok(ret.page == 0, "ret.page = %d\n", ret.page);
590 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
591 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
592 p_free(ret.table);
594 locale = p__get_current_locale();
595 locale->locinfo->lc_handle[LC_COLLATE] = 0x1234567;
596 p__free_locale(locale);
597 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
598 ok(ret.handle == 0x1234567, "ret.handle = %d\n", ret.handle);
599 ok(ret.page == 0, "ret.page = %d\n", ret.page);
600 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
601 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
602 p_free(ret.table);
605 static void test__Getcoll(void)
607 ULONGLONG (__cdecl *p__Getcoll_arg)(MSVCP__Collvec*);
608 _locale_t locale;
610 union {
611 MSVCP__Collvec collvec;
612 ULONGLONG ull;
613 }ret;
615 locale = p__get_current_locale();
616 locale->locinfo->lc_handle[LC_COLLATE] = 0x7654321;
617 p__free_locale(locale);
618 ret.ull = 0;
619 p__Getcoll_arg = (void*)p__Getcoll;
620 p__Getcoll_arg(&ret.collvec);
621 ok(ret.collvec.handle == 0, "ret.handle = %x\n", ret.collvec.handle);
622 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
624 ret.ull = p__Getcoll();
625 ok(ret.collvec.handle == 0x7654321, "ret.collvec.handle = %x\n", ret.collvec.handle);
626 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
629 static void test_towctrans(void)
631 wchar_t ret;
633 ret = p_wctrans("tolower");
634 ok(ret == 2, "wctrans returned %d, expected 2\n", ret);
635 ret = p_wctrans("toupper");
636 ok(ret == 1, "wctrans returned %d, expected 1\n", ret);
637 ret = p_wctrans("toLower");
638 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
639 ret = p_wctrans("");
640 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
641 if(0) { /* crashes on windows */
642 ret = p_wctrans(NULL);
643 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
646 ret = p_towctrans('t', 2);
647 ok(ret == 't', "towctrans('t', 2) returned %c, expected t\n", ret);
648 ret = p_towctrans('T', 2);
649 ok(ret == 't', "towctrans('T', 2) returned %c, expected t\n", ret);
650 ret = p_towctrans('T', 0);
651 ok(ret == 't', "towctrans('T', 0) returned %c, expected t\n", ret);
652 ret = p_towctrans('T', 3);
653 ok(ret == 't', "towctrans('T', 3) returned %c, expected t\n", ret);
654 ret = p_towctrans('t', 1);
655 ok(ret == 'T', "towctrans('t', 1) returned %c, expected T\n", ret);
656 ret = p_towctrans('T', 1);
657 ok(ret == 'T', "towctrans('T', 1) returned %c, expected T\n", ret);
660 static void test_allocator_char(void)
662 void *allocator = (void*)0xdeadbeef;
663 char *ptr;
664 char val;
665 unsigned int size;
667 allocator = call_func1(p_char_ctor, allocator);
668 ok(allocator == (void*)0xdeadbeef, "allocator = %p\n", allocator);
670 ptr = call_func2(p_char_address, NULL, (void*)0xdeadbeef);
671 ok(ptr == (void*)0xdeadbeef, "incorrect address (%p)\n", ptr);
673 ptr = NULL;
674 ptr = call_func2(p_char_allocate, allocator, 10);
675 ok(ptr != NULL, "Memory allocation failed\n");
677 ptr[0] = ptr[1] = '#';
678 val = 'a';
679 call_func3(p_char_construct, allocator, ptr, &val);
680 val = 'b';
681 call_func3(p_char_construct, allocator, (ptr+1), &val);
682 ok(ptr[0] == 'a', "ptr[0] = %c\n", ptr[0]);
683 ok(ptr[1] == 'b', "ptr[1] = %c\n", ptr[1]);
685 call_func3(p_char_deallocate, allocator, ptr, -1);
687 size = (unsigned int)call_func1(p_char_max_size, allocator);
688 ok(size == (unsigned int)0xffffffff, "size = %x\n", size);
691 static void test_virtual_call(void)
693 BYTE this[256];
694 basic_string_char bstr;
695 _locale_t locale;
696 const char *p;
697 char str1[] = "test";
698 char str2[] = "TEST";
699 int ret;
701 locale = p__get_current_locale();
702 locale->locinfo->lc_handle[LC_COLLATE] = 1;
703 p__free_locale(locale);
704 call_func2(p_collate_char_ctor_refs, this, 0);
705 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+4, str1, str1+4);
706 ok(ret == 0, "collate<char>::compare returned %d\n", ret);
707 ret = (int)call_func5(p_collate_char_compare, this, str2, str2+4, str1, str1+4);
708 ok(ret == 1, "collate<char>::compare returned %d\n", ret);
709 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+3, str1, str1+4);
710 ok(ret == -1, "collate<char>::compare returned %d\n", ret);
711 call_func1(p_collate_char_dtor, this);
713 call_func1(p_numpunct_char_ctor, this);
714 call_func2(p_numpunct_char_falsename, this, &bstr);
715 p = call_func1(p_basic_string_char_cstr, &bstr);
716 ok(!strcmp(p, "false"), "numpunct<char>::falsename returned %s\n", p);
717 call_func1(p_basic_string_char_dtor, &bstr);
718 call_func1(p_numpunct_char_dtor, this);
721 static void test_virtual_base_dtors(void)
723 char this[512];
725 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 1);
726 call_func1(p_basic_ostringstream_char_vbase_dtor, this);
728 /* this test uses vbtable set by earlier test */
729 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 0);
730 call_func1(p_basic_ostringstream_char_dtor, this+basic_ostringstream_char_vbtable[1]);
731 call_func1(p_basic_ios_char_dtor, this+((int**)this)[0][1]);
734 static BOOL almost_eq(float f1, float f2)
736 f1 = (f1-f2)/f1;
737 if(f1 < 0)
738 f1 = -f1;
739 return f1 < 0.0001;
742 static void test_Ctraits_math_functions(void)
744 BYTE ret;
746 ret = p_std_Ctraits_float__Isnan(0.0);
747 ok(ret == FALSE, "ret = %d\n", ret);
749 ret = p_std_Ctraits_float__Isnan(INFINITY);
750 ok(ret == FALSE, "ret = %d\n", ret);
752 ret = p_std_Ctraits_float__Isnan(-INFINITY);
753 ok(ret == FALSE, "ret = %d\n", ret);
755 ret = p_std_Ctraits_float__Isnan(IND);
756 ok(ret == TRUE, "ret = %d\n", ret);
758 ret = p_std_Ctraits_float__Isnan(NAN);
759 ok(ret == TRUE, "ret = %d\n", ret);
761 ret = p_std_Ctraits_double__Isnan(INFINITY);
762 ok(ret == FALSE, "ret = %d\n", ret);
764 ret = p_std_Ctraits_double__Isnan(IND);
765 ok(ret == TRUE, "ret = %d\n", ret);
767 ret = p_std_Ctraits_double__Isnan(NAN);
768 ok(ret == TRUE, "ret = %d\n", ret);
770 ret = p_std_Ctraits_long_double__Isnan(INFINITY);
771 ok(ret == FALSE, "ret = %d\n", ret);
773 ret = p_std_Ctraits_long_double__Isnan(IND);
774 ok(ret == TRUE, "ret = %d\n", ret);
776 ret = p_std_Ctraits_long_double__Isnan(NAN);
777 ok(ret == TRUE, "ret = %d\n", ret);
780 static void test_complex(void)
782 complex_float c1, c2, c3;
783 float f1, f2;
784 int scale;
785 int r;
787 f1 = 1;
788 f2 = 2;
789 call_func3(p_complex_float_ctor, &c1, &f1, &f2);
790 ok(c1.real == 1, "c1.real = %f\n", c1.real);
791 ok(c1.imag == 2, "c1.imag = %f\n", c1.imag);
793 f1 = p_complex_float__Fabs(&c1, &scale);
794 ok(almost_eq(f1, 0.559017), "abs(1+2i) = %f\n", f1);
795 ok(scale == 2, "scale = %d\n", scale);
797 f1 = -1;
798 f2 = 1;
799 call_func3(p_complex_float_ctor, &c2, &f1, &f2);
800 ok(c2.real == -1, "c2.real = %f\n", c1.real);
801 ok(c2.imag == 1, "c2.imag = %f\n", c1.imag);
803 f1 = p_complex_float__Fabs(&c2, &scale);
804 ok(almost_eq(f1, 0.353553), "abs(1-1i) = %f\n", f1);
805 ok(scale == 2, "scale = %d\n", scale);
807 p_complex_float_add(&c3, &c1, &c2);
808 ok(c3.real == 0, "c3.real = %f\n", c3.real);
809 ok(c3.imag == 3, "c3.imag = %f\n", c3.imag);
811 f1 = p_complex_float__Fabs(&c3, &scale);
812 ok(almost_eq(f1, 0.75), "abs(0+3i) = %f\n", f1);
813 ok(scale == 2, "scale = %d\n", scale);
815 p_complex_float_add(&c2, &c1, &c3);
816 ok(c2.real == 1, "c2.real = %f\n", c1.real);
817 ok(c2.imag == 5, "c2.imag = %f\n", c1.imag);
819 f1 = p_complex_float__Fabs(&c3, &scale);
820 ok(almost_eq(f1, 0.75), "abs(1+5i) = %f\n", f1);
821 ok(scale == 2, "scale = %d\n", scale);
823 /* (1+5i) / (0+3i) */
824 p_complex_float_div(&c1, &c2, &c3);
825 ok(almost_eq(c1.real, 1.666667), "c1.real = %f\n", c1.real);
826 ok(almost_eq(c1.imag, -0.33333), "c1.imag = %f\n", c1.imag);
828 /* (1+5i) / (2+0i) */
829 c3.real = 2;
830 c3.imag = 0;
831 p_complex_float_div(&c1, &c2, &c3);
832 ok(almost_eq(c1.real, 0.5), "c1.real = %f\n", c1.real);
833 ok(almost_eq(c1.imag, 2.5), "c1.imag = %f\n", c1.imag);
835 f1 = p_complex_float__Fabs(&c1, &scale);
836 ok(almost_eq(f1, 0.637377), "abs(0.5+2.5i) = %f\n", f1);
837 ok(scale == 2, "scale = %d\n", scale);
839 /* (1+5i) / 0 */
840 c3.real = 0;
841 p_complex_float_div(&c1, &c2, &c3);
842 ok(_isnan(c1.real), "c1.real = %f\n", c1.real);
843 ok(_isnan(c1.imag), "c1.imag = %f\n", c1.imag);
845 f1 = p_complex_float__Fabs(&c1, &scale);
846 ok(_isnan(f1), "abs(NaN+NaNi) = %f\n", f1);
847 ok(scale == 0, "scale = %d\n", scale);
849 /* (1+5i) / (NaN-2i) */
850 c1.imag = -2;
851 p_complex_float_div(&c3, &c2, &c1);
852 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
853 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
855 /* (NaN-2i) / (1+0i) */
856 c2.imag = 0;
857 p_complex_float_div(&c3, &c1, &c2);
858 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
859 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
861 /* (1+0i) + (NaN-2i) */
862 p_complex_float_add(&c3, &c2, &c1);
863 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
864 ok(c3.imag == -2, "c3.imag = %f\n", c3.imag);
866 f1 = p_complex_float__Fabs(&c3, &scale);
867 ok(_isnan(f1), "abs(NaN-2i) = %f\n", f1);
868 ok(scale == 0, "scale = %d\n", scale);
870 c3.real = 1000;
871 f1 = p_complex_float__Fabs(&c3, &scale);
872 ok(almost_eq(f1, 250.000504), "abs(1000-2i) = %f\n", f1);
873 ok(scale == 2, "scale = %d\n", scale);
875 c3.real = 0.1;
876 c3.imag = 0.1;
877 f1 = p_complex_float__Fabs(&c3, &scale);
878 ok(almost_eq(f1, 0.565685), "abs(0.1+0.1i) = %f\n", f1);
879 ok(scale == -2, "scale = %d\n", scale);
881 c3.real = 1;
882 c3.imag = 0;
883 f1 = p_complex_float__Fabs(&c3, &scale);
884 ok(almost_eq(f1, 0.25), "abs(1+0i) = %f\n", f1);
885 ok(scale == 2, "scale = %d\n", scale);
887 c3.real = 0.99;
888 c3.imag = 0;
889 f1 = p_complex_float__Fabs(&c3, &scale);
890 ok(almost_eq(f1, 3.96), "abs(0.99+0i) = %f\n", f1);
891 ok(scale == -2, "scale = %d\n", scale);
893 c3.real = 0;
894 c3.imag = 0;
895 f1 = p_complex_float__Fabs(&c3, &scale);
896 ok(f1 == 0, "abs(0+0i) = %f\n", f1);
897 ok(scale == 0, "scale = %d\n", scale);
899 c1.real = 0;
900 c1.imag = 0;
901 r = 3;
902 f1 = 3.312;
903 p_complex_float_tan(&c2, &c1);
904 ok(c2.real == 0, "c2.real = %f\n", c2.real);
905 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
906 p_complex_float_tanh(&c2, &c1);
907 ok(c2.real == 0, "c2.real = %f\n", c2.real);
908 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
909 p_complex_float_log10(&c2, &c1);
910 ok(c2.real < -FLT_MAX /* c2.real == -inf */, "c2.real = %f\n", c2.real);
911 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
912 p_complex_float_sqrt(&c2, &c1);
913 ok(c2.real == 0, "c2.real = %f\n", c2.real);
914 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
915 p_complex_float_pow_ci(&c2, &c1, r);
916 ok(c2.real == 0, "c2.real = %f\n", c2.real);
917 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
918 p_complex_float_pow_fc(&c2, &f1, &c1);
919 ok(c2.real == 1, "c2.real = %f\n", c2.real);
920 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
921 p_complex_float_pow_cf(&c2, &c1, &f1);
922 ok(c2.real == 0, "c2.real = %f\n", c2.real);
923 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
925 c1.real = 3.14159/2;
926 c1.imag = 0;
927 p_complex_float_tan(&c2, &c1);
928 ok(almost_eq(c2.real, 788906.062500), "c2.real = %f\n", c2.real);
929 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
930 p_complex_float_tanh(&c2, &c1);
931 ok(almost_eq(c2.real, 0.917152), "c2.real = %f\n", c2.real);
932 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
933 p_complex_float_log10(&c2, &c1);
934 ok(almost_eq(c2.real, 0.196120), "c2.real = %f\n", c2.real);
935 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
936 p_complex_float_sqrt(&c2, &c1);
937 ok(almost_eq(c2.real, 1.253314), "c2.real = %f\n", c2.real);
938 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
939 p_complex_float_pow_ci(&c2, &c1, r);
940 ok(almost_eq(c2.real, 3.875775), "c2.real = %f\n", c2.real);
941 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
942 r = -r;
943 p_complex_float_pow_ci(&c2, &c1, r);
944 ok(almost_eq(c2.real, 0.258013), "c2.real = %f\n", c2.real);
945 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
946 r = -r;
947 p_complex_float_pow_fc(&c2, &f1, &c1);
948 ok(almost_eq(c2.real, 6.560778), "c2.real = %f\n", c2.real);
949 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
950 p_complex_float_pow_cf(&c2, &c1, &f1);
951 ok(almost_eq(c2.real, 4.462188), "c2.real = %f\n", c2.real);
952 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
954 c1.real = 7.12;
955 c1.imag = 0.17;
956 p_complex_float_tan(&c2, &c1);
957 ok(almost_eq(c2.real, 1.040818), "c2.real = %f\n", c2.real);
958 ok(almost_eq(c2.imag, 0.362651), "c2.imag = %f\n", c2.imag);
959 p_complex_float_tanh(&c2, &c1);
960 ok(almost_eq(c2.real, 0.999999), "c2.real = %f\n", c2.real);
961 ok(almost_eq(c2.imag, 4.3627e-7), "c2.imag = %g\n", c2.imag);
962 p_complex_float_log10(&c2, &c1);
963 ok(almost_eq(c2.real, 0.852604), "c2.real = %f\n", c2.real);
964 ok(almost_eq(c2.imag, 0.0103674), "c2.imag = %g\n", c2.imag);
965 p_complex_float_sqrt(&c2, &c1);
966 ok(almost_eq(c2.real, 2.668523), "c2.real = %f\n", c2.real);
967 ok(almost_eq(c2.imag, 0.0318528), "c2.imag = %g\n", c2.imag);
968 p_complex_float_pow_ci(&c2, &c1, r);
969 ok(almost_eq(c2.real, 360.326782), "c2.real = %f\n", c2.real);
970 ok(almost_eq(c2.imag, 25.849230), "c2.imag = %g\n", c2.imag);
971 r = -r;
972 p_complex_float_pow_ci(&c2, &c1, r);
973 ok(almost_eq(c2.real, 0.002761), "c2.real = %f\n", c2.real);
974 ok(almost_eq(c2.imag, -0.000198073), "c2.imag = %g\n", c2.imag);
975 r = -r;
976 p_complex_float_pow_fc(&c2, &f1, &c1);
977 ok(almost_eq(c2.real, 4942.879395), "c2.real = %f\n", c2.real);
978 ok(almost_eq(c2.imag, 1020.427368), "c2.imag = %g\n", c2.imag);
979 p_complex_float_pow_cf(&c2, &c1, &f1);
980 ok(almost_eq(c2.real, 664.453918), "c2.real = %f\n", c2.real);
981 ok(almost_eq(c2.imag, 52.643879), "c2.imag = %g\n", c2.imag);
983 c1.real = 0.14;
984 c1.imag = 0.19;
985 p_complex_float_tan(&c2, &c1);
986 ok(almost_eq(c2.real, 0.135859), "c2.real = %f\n", c2.real);
987 ok(almost_eq(c2.imag, 0.191341), "c2.imag = %f\n", c2.imag);
988 p_complex_float_tanh(&c2, &c1);
989 ok(almost_eq(c2.real, 0.144134), "c2.real = %f\n", c2.real);
990 ok(almost_eq(c2.imag, 0.188464), "c2.imag = %f\n", c2.imag);
991 p_complex_float_log10(&c2, &c1);
992 ok(almost_eq(c2.real, -0.627072), "c2.real = %f\n", c2.real);
993 ok(almost_eq(c2.imag, 0.4064), "c2.imag = %g\n", c2.imag);
994 p_complex_float_sqrt(&c2, &c1);
995 ok(almost_eq(c2.real, 0.433595), "c2.real = %f\n", c2.real);
996 ok(almost_eq(c2.imag, 0.219099), "c2.imag = %g\n", c2.imag);
997 p_complex_float_pow_ci(&c2, &c1, r);
998 ok(almost_eq(c2.real, -0.012418), "c2.real = %f\n", c2.real);
999 ok(almost_eq(c2.imag, 0.004313), "c2.imag = %g\n", c2.imag);
1000 r = -r;
1001 p_complex_float_pow_ci(&c2, &c1, r);
1002 ok(almost_eq(c2.real, -71.859810), "c2.real = %f\n", c2.real);
1003 ok(almost_eq(c2.imag, -24.958229), "c2.imag = %g\n", c2.imag);
1004 p_complex_float_pow_fc(&c2, &f1, &c1);
1005 ok(almost_eq(c2.real, 1.152052), "c2.real = %f\n", c2.real);
1006 ok(almost_eq(c2.imag, 0.266751), "c2.imag = %g\n", c2.imag);
1007 p_complex_float_pow_cf(&c2, &c1, &f1);
1008 ok(almost_eq(c2.real, -0.008370), "c2.real = %f\n", c2.real);
1009 ok(almost_eq(c2.imag, 0.00035447), "c2.imag = %g\n", c2.imag);
1012 static struct {
1013 int value[2];
1014 const char* export_name;
1015 } vbtable_size_exports_list[] = {
1016 {{0x5c, 0xa8}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1017 {{0x54, 0x98}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1018 {{0x5c, 0xa8}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1019 {{0x54, 0x98}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1020 {{0x5c, 0xa8}, "??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1021 {{0x54, 0x98}, "??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1022 {{0x58, 0xa0}, "??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@"},
1023 {{0x58, 0xa0}, "??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@"},
1024 {{0x58, 0xa0}, "??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@"},
1025 {{ 0xc, 0x18}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1026 {{ 0x4, 0x8}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1027 {{ 0xc, 0x18}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1028 {{ 0x4, 0x8}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1029 {{ 0xc, 0x18}, "??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1030 {{ 0x4, 0x8}, "??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1031 {{ 0x8, 0x10}, "??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@"},
1032 {{ 0x8, 0x10}, "??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@"},
1033 {{ 0x8, 0x10}, "??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@"},
1034 {{0x50, 0x90}, "??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1035 {{0x50, 0x90}, "??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1036 {{0x50, 0x90}, "??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@"},
1037 {{0x54, 0x98}, "??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@"},
1038 {{0x54, 0x98}, "??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@"},
1039 {{0x54, 0x98}, "??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@"},
1040 {{ 0x4, 0x8}, "??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@"},
1041 {{ 0x4, 0x8}, "??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@"},
1042 {{ 0x4, 0x8}, "??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@"},
1043 {{0x4c, 0x88}, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1044 {{0x4c, 0x88}, "??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1045 {{0x4c, 0x88}, "??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@"},
1046 {{0x54, 0x98}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1047 {{0x4c, 0x88}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1048 {{0x54, 0x98}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1049 {{0x4c, 0x88}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1050 {{0x54, 0x98}, "??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1051 {{0x4c, 0x88}, "??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1052 {{ 0x0, 0x0}, 0}
1055 static void test_vbtable_size_exports(void)
1057 int i;
1058 const int *p_vbtable;
1059 int arch_idx = (sizeof(void*) == 8);
1061 for (i = 0; vbtable_size_exports_list[i].export_name; i++)
1063 SET(p_vbtable, vbtable_size_exports_list[i].export_name);
1065 ok(p_vbtable[0] == 0, "vbtable[0] wrong, got 0x%x\n", p_vbtable[0]);
1066 ok(p_vbtable[1] == vbtable_size_exports_list[i].value[arch_idx],
1067 "%d: %s[1] wrong, got 0x%x\n", i, vbtable_size_exports_list[i].export_name, p_vbtable[1]);
1073 static void test_locale__Locimp__Locimp_Addfac(void)
1075 locale__Locimp locimp;
1076 locale_facet facet;
1078 memset(&locimp, 0, sizeof(locimp));
1079 memset(&facet, 0, sizeof(facet));
1080 p_locale__Locimp__Locimp_Addfac(&locimp, &facet, 1);
1081 ok(locimp.facet_cnt == 40, "locimp.facet_cnt = %d\n", (int)locimp.facet_cnt);
1084 static void CDECL raise_handler(const void *except)
1086 ok(0, "unexpected call\n");
1089 static void test_raise_handler(void)
1091 ok(!*p_Raise_handler, "_Raise_handler = %p\n", *p_Raise_handler);
1092 *p_Raise_handler = raise_handler;
1093 *p_Raise_handler = NULL;
1096 static void test__Strxfrm(void)
1098 const char in[] = "abc";
1100 MSVCP__Collvec coll;
1101 char out[64];
1102 size_t ret;
1104 memset(&coll, 0, sizeof(coll));
1106 out[0] = 'z';
1107 ret = p__Strxfrm(out, out + 1, in, in + 2, &coll);
1108 ok(ret == 2, "ret = %d\n", (int)ret);
1109 ok(out[0] == 'z', "out[0] = %x\n", out[0]);
1111 ret = p__Strxfrm(out, out + sizeof(out), in, in + 4, &coll);
1112 ok(ret == 4, "ret = %d\n", (int)ret);
1113 ok(!strcmp(in, out), "out = %s\n", out);
1116 static void test__Wcsxfrm(void)
1118 const wchar_t in[] = L"abc";
1120 MSVCP__Collvec coll;
1121 wchar_t out[64];
1122 size_t ret;
1124 memset(&coll, 0, sizeof(coll));
1126 out[0] = 'z';
1127 ret = p__Wcsxfrm(out, out + 1, in, in + 2, &coll);
1128 ok(ret == 2, "ret = %d\n", (int)ret);
1129 ok(out[0] == 'z', "out[0] = %x\n", out[0]);
1131 ret = p__Wcsxfrm(out, out + ARRAY_SIZE(out), in, in + 4, &coll);
1132 ok(ret == 4, "ret = %d\n", (int)ret);
1133 ok(!wcscmp(in, out), "out = %s\n", wine_dbgstr_w(out));
1136 START_TEST(misc)
1138 if(!init())
1139 return;
1141 test_assign();
1142 test_equal();
1143 test_Copy_s();
1144 test_wctype();
1145 test__Getctype();
1146 test__Getcoll();
1147 test_towctrans();
1148 test_virtual_call();
1149 test_virtual_base_dtors();
1150 test_allocator_char();
1151 test_Ctraits_math_functions();
1152 test_complex();
1153 test_vbtable_size_exports();
1154 test_locale__Locimp__Locimp_Addfac();
1155 test_raise_handler();
1156 test__Strxfrm();
1157 test__Wcsxfrm();
1159 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
1161 FreeLibrary(msvcr);
1162 FreeLibrary(msvcp);