winemac: Fix the logic for checking if a view is already in the intended z-order.
[wine.git] / dlls / msvcp90 / tests / misc.c
blob2c61bccb1880dad20753da55445d5ee9e45f150c
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_infinity(void)
32 static const unsigned __inf_bytes = 0x7f800000;
33 return *(const float *)&__inf_bytes;
35 #define INFINITY __port_infinity()
37 static inline float __port_nan(void)
39 static const unsigned __nan_bytes = 0x7fc00000;
40 return *(const float *)&__nan_bytes;
42 #define NAN __port_nan()
44 static inline float __port_ind(void)
46 static const unsigned __ind_bytes = 0xffc00000;
47 return *(const float *)&__ind_bytes;
49 #define IND __port_ind()
51 typedef double LDOUBLE; /* long double is just a double */
53 typedef struct {
54 LCID handle;
55 unsigned page;
56 short *table;
57 int delfl;
58 } MSVCP__Ctypevec;
60 typedef struct {
61 LCID handle;
62 unsigned page;
63 } MSVCP__Collvec;
65 /* basic_string<char, char_traits<char>, allocator<char>> */
66 #define BUF_SIZE_CHAR 16
67 typedef struct
69 void *allocator;
70 union {
71 char buf[BUF_SIZE_CHAR];
72 char *ptr;
73 } data;
74 size_t size;
75 size_t res;
76 } basic_string_char;
78 /* class complex<float> */
79 typedef struct {
80 float real;
81 float imag;
82 } complex_float;
84 typedef struct {
85 void *vtable;
86 size_t refs;
87 } locale_facet;
89 typedef unsigned char MSVCP_bool;
91 typedef struct _locale__Locimp {
92 locale_facet facet;
93 locale_facet **facetvec;
94 size_t facet_cnt;
95 int catmask;
96 MSVCP_bool transparent;
97 basic_string_char name;
98 } locale__Locimp;
100 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
101 static _locale_t (__cdecl *p__get_current_locale)(void);
102 static void (__cdecl *p__free_locale)(_locale_t);
103 static void (__cdecl *p_free)(void*);
104 static int * (__cdecl *p_errno)(void);
106 static void (__cdecl *p_char_assign)(void*, const void*);
107 static void (__cdecl *p_wchar_assign)(void*, const void*);
108 static void (__cdecl *p_short_assign)(void*, const void*);
110 static BYTE (__cdecl *p_char_eq)(const void*, const void*);
111 static BYTE (__cdecl *p_wchar_eq)(const void*, const void*);
112 static BYTE (__cdecl *p_short_eq)(const void*, const void*);
114 static char* (__cdecl *p_Copy_s)(char*, size_t, const char*, size_t);
116 static unsigned short (__cdecl *p_wctype)(const char*);
117 static MSVCP__Ctypevec* (__cdecl *p__Getctype)(MSVCP__Ctypevec*);
118 static /*MSVCP__Collvec*/ULONGLONG (__cdecl *p__Getcoll)(void);
119 static wctrans_t (__cdecl *p_wctrans)(const char*);
120 static wint_t (__cdecl *p_towctrans)(wint_t, wctrans_t);
121 static void (__cdecl *p_locale__Locimp__Locimp_Addfac)(locale__Locimp*,locale_facet*,size_t);
123 #undef __thiscall
124 #ifdef __i386__
125 #define __thiscall __stdcall
126 #else
127 #define __thiscall __cdecl
128 #endif
130 static char* (__thiscall *p_char_address)(void*, char*);
131 static void* (__thiscall *p_char_ctor)(void*);
132 static void (__thiscall *p_char_deallocate)(void*, char*, size_t);
133 static char* (__thiscall *p_char_allocate)(void*, size_t);
134 static void (__thiscall *p_char_construct)(void*, char*, const char*);
135 static size_t (__thiscall *p_char_max_size)(void*);
137 static void* (__thiscall *p_collate_char_ctor_refs)(void*, size_t);
138 static int (__thiscall *p_collate_char_compare)(const void*, const char*,
139 const char*, const char*, const char*);
140 static void (__thiscall *p_collate_char_dtor)(void*);
141 static void* (__thiscall *p_numpunct_char_ctor)(void*);
142 static basic_string_char* (__thiscall *p_numpunct_char_falsename)(void*,basic_string_char*);
143 static void (__thiscall *p_numpunct_char_dtor)(void*);
144 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
145 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
147 static const int *basic_ostringstream_char_vbtable;
148 static /*basic_ostringstream_char*/void* (__thiscall *p_basic_ostringstream_char_ctor_mode)(
149 /*basic_ostringstream_char*/void*, int, /*MSVCP_bool*/int);
150 static void (__thiscall *p_basic_ostringstream_char_dtor)(/*basic_ostringstream_char*/void*);
151 static void (__thiscall *p_basic_ostringstream_char_vbase_dtor)(/*basic_ostringstream_char*/void*);
152 static void (__thiscall *p_basic_ios_char_dtor)(/*basic_ios_char*/void*);
154 static BOOL (__cdecl *p_std_Ctraits_float__Isnan)(float);
155 static BOOL (__cdecl *p_std_Ctraits_double__Isnan)(double);
156 static BOOL (__cdecl *p_std_Ctraits_long_double__Isnan)(LDOUBLE);
158 static complex_float* (__thiscall *p_complex_float_ctor)(complex_float*, const float*, const float*);
159 static complex_float* (__cdecl *p_complex_float_add)(complex_float*, const complex_float*, const complex_float*);
160 static complex_float* (__cdecl *p_complex_float_div)(complex_float*, const complex_float*, const complex_float*);
161 static float (__cdecl *p_complex_float__Fabs)(const complex_float*, int*);
162 static complex_float* (__cdecl *p_complex_float_tan)(complex_float*, const complex_float*);
163 static complex_float* (__cdecl *p_complex_float_tanh)(complex_float*, const complex_float*);
164 static complex_float* (__cdecl *p_complex_float_log10)(complex_float*, const complex_float*);
165 static complex_float* (__cdecl *p_complex_float_sqrt)(complex_float*, const complex_float*);
166 static complex_float* (__cdecl *p_complex_float_pow_ci)(complex_float*, const complex_float*, int);
167 static complex_float* (__cdecl *p_complex_float_pow_fc)(complex_float*, const float*, const complex_float*);
168 static complex_float* (__cdecl *p_complex_float_pow_cf)(complex_float*, const complex_float*, const float*);
170 static int invalid_parameter = 0;
171 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
172 const wchar_t *function, const wchar_t *file,
173 unsigned line, uintptr_t arg)
175 ok(expression == NULL, "expression is not NULL\n");
176 ok(function == NULL, "function is not NULL\n");
177 ok(file == NULL, "file is not NULL\n");
178 ok(line == 0, "line = %u\n", line);
179 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
180 invalid_parameter++;
183 /* Emulate a __thiscall */
184 #ifdef __i386__
186 #include "pshpack1.h"
187 struct thiscall_thunk
189 BYTE pop_eax; /* popl %eax (ret addr) */
190 BYTE pop_edx; /* popl %edx (func) */
191 BYTE pop_ecx; /* popl %ecx (this) */
192 BYTE push_eax; /* pushl %eax */
193 WORD jmp_edx; /* jmp *%edx */
195 #include "poppack.h"
197 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
198 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
199 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
200 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
201 const void *c, const void *d );
203 static void init_thiscall_thunk(void)
205 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
206 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
207 thunk->pop_eax = 0x58; /* popl %eax */
208 thunk->pop_edx = 0x5a; /* popl %edx */
209 thunk->pop_ecx = 0x59; /* popl %ecx */
210 thunk->push_eax = 0x50; /* pushl %eax */
211 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
212 call_thiscall_func1 = (void *)thunk;
213 call_thiscall_func2 = (void *)thunk;
214 call_thiscall_func3 = (void *)thunk;
215 call_thiscall_func5 = (void *)thunk;
218 #define call_func1(func,_this) call_thiscall_func1(func,_this)
219 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
220 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
221 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
222 (const void*)(c), (const void *)(d))
224 #else
226 #define init_thiscall_thunk()
227 #define call_func1(func,_this) func(_this)
228 #define call_func2(func,_this,a) func(_this,a)
229 #define call_func3(func,_this,a,b) func(_this,a,b)
230 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
232 #endif /* __i386__ */
234 static HMODULE msvcr, msvcp;
235 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
236 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
237 static BOOL init(void)
239 msvcr = LoadLibraryA("msvcr90.dll");
240 msvcp = LoadLibraryA("msvcp90.dll");
241 if(!msvcr || !msvcp) {
242 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
243 return FALSE;
246 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
247 p__get_current_locale = (void*)GetProcAddress(msvcr, "_get_current_locale");
248 p__free_locale = (void*)GetProcAddress(msvcr, "_free_locale");
249 p_free = (void*)GetProcAddress(msvcr, "free");
250 p_errno = (void*)GetProcAddress(msvcr, "_errno");
251 if(!p_set_invalid_parameter_handler || !p__get_current_locale || !p__free_locale || !p_free || !p_errno) {
252 win_skip("Error setting tests environment\n");
253 return FALSE;
256 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
258 SET(p_wctype, "wctype");
259 SET(p__Getctype, "_Getctype");
260 SET(p__Getcoll, "_Getcoll");
261 SET(p_wctrans, "wctrans");
262 SET(p_towctrans, "towctrans");
263 SET(basic_ostringstream_char_vbtable, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@");
265 SET(p_std_Ctraits_float__Isnan, "?_Isnan@?$_Ctraits@M@std@@SA_NM@Z");
266 SET(p_std_Ctraits_double__Isnan, "?_Isnan@?$_Ctraits@N@std@@SA_NN@Z");
267 SET(p_std_Ctraits_long_double__Isnan, "?_Isnan@?$_Ctraits@O@std@@SA_NO@Z");
269 if(sizeof(void*) == 8) { /* 64-bit initialization */
270 SET(p_locale__Locimp__Locimp_Addfac,
271 "?_Locimp_Addfac@_Locimp@locale@std@@CAXPEAV123@PEAVfacet@23@_K@Z");
272 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAEADAEBD@Z");
273 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAEA_WAEB_W@Z");
274 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAEAGAEBG@Z");
276 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NAEBD0@Z");
277 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAEB_W0@Z");
278 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NAEBG0@Z");
280 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z");
282 SET(p_char_address, "?address@?$allocator@D@std@@QEBAPEADAEAD@Z");
283 SET(p_char_ctor, "??0?$allocator@D@std@@QEAA@XZ");
284 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QEAAXPEAD_K@Z");
285 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QEAAPEAD_K@Z");
286 SET(p_char_construct, "?construct@?$allocator@D@std@@QEAAXPEADAEBD@Z");
287 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QEBA_KXZ");
289 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QEAA@_K@Z");
290 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QEBAHPEBD000@Z");
291 SET(p_collate_char_dtor, "??1?$collate@D@std@@MEAA@XZ");
292 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QEAAXXZ");
293 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
294 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MEAA@XZ");
295 SET(p_basic_string_char_dtor,
296 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
297 SET(p_basic_string_char_cstr,
298 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
300 SET(p_basic_ostringstream_char_ctor_mode,
301 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z");
302 SET(p_basic_ostringstream_char_dtor,
303 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ");
304 SET(p_basic_ostringstream_char_vbase_dtor,
305 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
306 SET(p_basic_ios_char_dtor,
307 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ");
309 SET(p_complex_float_ctor,
310 "??0?$complex@M@std@@QEAA@AEBM0@Z");
311 SET(p_complex_float_add,
312 "??$?HM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
313 SET(p_complex_float_div,
314 "??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
315 SET(p_complex_float__Fabs,
316 "??$_Fabs@M@std@@YAMAEBV?$complex@M@0@PEAH@Z");
317 SET(p_complex_float_tan,
318 "??$tan@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
319 SET(p_complex_float_tanh,
320 "??$tanh@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
321 SET(p_complex_float_log10,
322 "??$log10@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
323 SET(p_complex_float_sqrt,
324 "??$sqrt@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
325 SET(p_complex_float_pow_ci,
326 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@H@Z");
327 SET(p_complex_float_pow_fc,
328 "??$pow@M@std@@YA?AV?$complex@M@0@AEBMAEBV10@@Z");
329 SET(p_complex_float_pow_cf,
330 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@AEBM@Z");
331 } else {
332 SET(p_locale__Locimp__Locimp_Addfac,
333 "?_Locimp_Addfac@_Locimp@locale@std@@CAXPAV123@PAVfacet@23@I@Z");
334 #ifdef __arm__
335 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
336 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
337 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
339 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
340 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
341 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
343 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
345 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
346 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
347 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
348 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
349 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
350 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
352 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
353 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
354 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
355 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
356 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
357 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
358 SET(p_basic_string_char_dtor,
359 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
360 SET(p_basic_string_char_cstr,
361 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
363 SET(p_basic_ostringstream_char_ctor_mode,
364 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
365 SET(p_basic_ostringstream_char_dtor,
366 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
367 SET(p_basic_ostringstream_char_vbase_dtor,
368 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
369 SET(p_basic_ios_char_dtor,
370 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAA@XZ");
372 SET(p_complex_float_ctor,
373 "??0?$complex@M@std@@QAE@ABM0@Z");
374 SET(p_complex_float_add,
375 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
376 SET(p_complex_float_div,
377 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
378 SET(p_complex_float__Fabs,
379 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
380 SET(p_complex_float_tan,
381 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
382 SET(p_complex_float_tanh,
383 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
384 SET(p_complex_float_log10,
385 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
386 SET(p_complex_float_sqrt,
387 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
388 SET(p_complex_float_pow_ci,
389 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
390 SET(p_complex_float_pow_fc,
391 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
392 SET(p_complex_float_pow_cf,
393 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
394 #else
395 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
396 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
397 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
399 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
400 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
401 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
403 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
405 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
406 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
407 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
408 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
409 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
410 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
412 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
413 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
414 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
415 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
416 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
417 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
418 SET(p_basic_string_char_dtor,
419 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
420 SET(p_basic_string_char_cstr,
421 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
423 SET(p_basic_ostringstream_char_ctor_mode,
424 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
425 SET(p_basic_ostringstream_char_dtor,
426 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
427 SET(p_basic_ostringstream_char_vbase_dtor,
428 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
429 SET(p_basic_ios_char_dtor,
430 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ");
432 SET(p_complex_float_ctor,
433 "??0?$complex@M@std@@QAE@ABM0@Z");
434 SET(p_complex_float_add,
435 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
436 SET(p_complex_float_div,
437 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
438 SET(p_complex_float__Fabs,
439 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
440 SET(p_complex_float_tan,
441 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
442 SET(p_complex_float_tanh,
443 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
444 SET(p_complex_float_log10,
445 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
446 SET(p_complex_float_sqrt,
447 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
448 SET(p_complex_float_pow_ci,
449 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
450 SET(p_complex_float_pow_fc,
451 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
452 SET(p_complex_float_pow_cf,
453 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
454 #endif
457 init_thiscall_thunk();
458 return TRUE;
461 static void test_assign(void)
463 const char in[] = "abc";
464 char out[4];
466 out[1] = '#';
467 p_char_assign(out, in);
468 ok(out[0] == in[0], "out[0] = %c\n", out[0]);
469 ok(out[1] == '#', "out[1] = %c\n", out[1]);
471 out[2] = '#';
472 p_wchar_assign(out, in);
473 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
474 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
475 ok(out[2] == '#', "out[2] = %c\n", out[2]);
477 out[2] = '#';
478 p_short_assign(out, in);
479 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
480 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
481 ok(out[2] == '#', "out[2] = %c\n", out[2]);
484 static void test_equal(void)
486 static const char in1[] = "abc";
487 static const char in2[] = "ab";
488 static const char in3[] = "a";
489 static const char in4[] = "b";
490 BYTE ret;
492 ret = p_char_eq(in1, in2);
493 ok(ret == TRUE, "ret = %d\n", (int)ret);
494 ret = p_char_eq(in1, in3);
495 ok(ret == TRUE, "ret = %d\n", (int)ret);
496 ret = p_char_eq(in1, in4);
497 ok(ret == FALSE, "ret = %d\n", (int)ret);
499 ret = p_wchar_eq(in1, in2);
500 ok(ret == TRUE, "ret = %d\n", (int)ret);
501 ret = p_wchar_eq(in1, in3);
502 ok(ret == FALSE, "ret = %d\n", (int)ret);
503 ret = p_wchar_eq(in1, in4);
504 ok(ret == FALSE, "ret = %d\n", (int)ret);
506 ret = p_short_eq(in1, in2);
507 ok(ret == TRUE, "ret = %d\n", (int)ret);
508 ret = p_short_eq(in1, in3);
509 ok(ret == FALSE, "ret = %d\n", (int)ret);
510 ret = p_short_eq(in1, in4);
511 ok(ret == FALSE, "ret = %d\n", (int)ret);
514 static void test_Copy_s(void)
516 static const char src[] = "abcd";
517 char dest[32], *ret;
519 dest[4] = '#';
520 dest[5] = '\0';
521 ret = p_Copy_s(dest, 4, src, 4);
522 ok(ret == dest, "ret != dest\n");
523 ok(dest[4] == '#', "dest[4] != '#'\n");
524 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
526 ret = p_Copy_s(dest, 32, src, 4);
527 ok(ret == dest, "ret != dest\n");
528 ok(dest[4] == '#', "dest[4] != '#'\n");
529 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
531 *p_errno() = 0xdeadbeef;
532 dest[0] = '#';
533 ret = p_Copy_s(dest, 3, src, 4);
534 ok(ret == dest, "ret != dest\n");
535 ok(dest[0] == '\0', "dest[0] != 0\n");
536 ok(invalid_parameter==1, "invalid_parameter = %d\n",
537 invalid_parameter);
538 invalid_parameter = 0;
539 ok(*p_errno() == ERANGE, "errno = %d\n", *p_errno());
541 *p_errno() = 0xdeadbeef;
542 p_Copy_s(NULL, 32, src, 4);
543 ok(invalid_parameter==1, "invalid_parameter = %d\n",
544 invalid_parameter);
545 invalid_parameter = 0;
546 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
548 *p_errno() = 0xdeadbeef;
549 p_Copy_s(dest, 32, NULL, 4);
550 ok(invalid_parameter==1, "invalid_parameter = %d\n",
551 invalid_parameter);
552 invalid_parameter = 0;
553 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
556 static void test_wctype(void)
558 static const struct {
559 const char *name;
560 unsigned short mask;
561 } properties[] = {
562 { "alnum", 0x107 },
563 { "alpha", 0x103 },
564 { "cntrl", 0x020 },
565 { "digit", 0x004 },
566 { "graph", 0x117 },
567 { "lower", 0x002 },
568 { "print", 0x157 },
569 { "punct", 0x010 },
570 { "space", 0x008 },
571 { "upper", 0x001 },
572 { "xdigit", 0x080 },
573 { "ALNUM", 0x000 },
574 { "Alnum", 0x000 },
575 { "", 0x000 }
577 int i, ret;
579 for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++) {
580 ret = p_wctype(properties[i].name);
581 ok(properties[i].mask == ret, "%d - Expected %x, got %x\n", i, properties[i].mask, ret);
585 static void test__Getctype(void)
587 MSVCP__Ctypevec ret;
588 _locale_t locale;
590 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
591 ok(ret.handle == 0, "ret.handle = %d\n", ret.handle);
592 ok(ret.page == 0, "ret.page = %d\n", ret.page);
593 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
594 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
595 p_free(ret.table);
597 locale = p__get_current_locale();
598 locale->locinfo->lc_handle[LC_COLLATE] = 0x1234567;
599 p__free_locale(locale);
600 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
601 ok(ret.handle == 0x1234567, "ret.handle = %d\n", ret.handle);
602 ok(ret.page == 0, "ret.page = %d\n", ret.page);
603 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
604 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
605 p_free(ret.table);
608 static void test__Getcoll(void)
610 ULONGLONG (__cdecl *p__Getcoll_arg)(MSVCP__Collvec*);
611 _locale_t locale;
613 union {
614 MSVCP__Collvec collvec;
615 ULONGLONG ull;
616 }ret;
618 locale = p__get_current_locale();
619 locale->locinfo->lc_handle[LC_COLLATE] = 0x7654321;
620 p__free_locale(locale);
621 ret.ull = 0;
622 p__Getcoll_arg = (void*)p__Getcoll;
623 p__Getcoll_arg(&ret.collvec);
624 ok(ret.collvec.handle == 0, "ret.handle = %x\n", ret.collvec.handle);
625 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
627 ret.ull = p__Getcoll();
628 ok(ret.collvec.handle == 0x7654321, "ret.collvec.handle = %x\n", ret.collvec.handle);
629 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
632 static void test_towctrans(void)
634 wchar_t ret;
636 ret = p_wctrans("tolower");
637 ok(ret == 2, "wctrans returned %d, expected 2\n", ret);
638 ret = p_wctrans("toupper");
639 ok(ret == 1, "wctrans returned %d, expected 1\n", ret);
640 ret = p_wctrans("toLower");
641 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
642 ret = p_wctrans("");
643 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
644 if(0) { /* crashes on windows */
645 ret = p_wctrans(NULL);
646 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
649 ret = p_towctrans('t', 2);
650 ok(ret == 't', "towctrans('t', 2) returned %c, expected t\n", ret);
651 ret = p_towctrans('T', 2);
652 ok(ret == 't', "towctrans('T', 2) returned %c, expected t\n", ret);
653 ret = p_towctrans('T', 0);
654 ok(ret == 't', "towctrans('T', 0) returned %c, expected t\n", ret);
655 ret = p_towctrans('T', 3);
656 ok(ret == 't', "towctrans('T', 3) returned %c, expected t\n", ret);
657 ret = p_towctrans('t', 1);
658 ok(ret == 'T', "towctrans('t', 1) returned %c, expected T\n", ret);
659 ret = p_towctrans('T', 1);
660 ok(ret == 'T', "towctrans('T', 1) returned %c, expected T\n", ret);
663 static void test_allocator_char(void)
665 void *allocator = (void*)0xdeadbeef;
666 char *ptr;
667 char val;
668 unsigned int size;
670 allocator = call_func1(p_char_ctor, allocator);
671 ok(allocator == (void*)0xdeadbeef, "allocator = %p\n", allocator);
673 ptr = call_func2(p_char_address, NULL, (void*)0xdeadbeef);
674 ok(ptr == (void*)0xdeadbeef, "incorrect address (%p)\n", ptr);
676 ptr = NULL;
677 ptr = call_func2(p_char_allocate, allocator, 10);
678 ok(ptr != NULL, "Memory allocation failed\n");
680 ptr[0] = ptr[1] = '#';
681 val = 'a';
682 call_func3(p_char_construct, allocator, ptr, &val);
683 val = 'b';
684 call_func3(p_char_construct, allocator, (ptr+1), &val);
685 ok(ptr[0] == 'a', "ptr[0] = %c\n", ptr[0]);
686 ok(ptr[1] == 'b', "ptr[1] = %c\n", ptr[1]);
688 call_func3(p_char_deallocate, allocator, ptr, -1);
690 size = (unsigned int)call_func1(p_char_max_size, allocator);
691 ok(size == (unsigned int)0xffffffff, "size = %x\n", size);
694 static void test_virtual_call(void)
696 BYTE this[256];
697 basic_string_char bstr;
698 _locale_t locale;
699 const char *p;
700 char str1[] = "test";
701 char str2[] = "TEST";
702 int ret;
704 locale = p__get_current_locale();
705 locale->locinfo->lc_handle[LC_COLLATE] = 1;
706 p__free_locale(locale);
707 call_func2(p_collate_char_ctor_refs, this, 0);
708 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+4, str1, str1+4);
709 ok(ret == 0, "collate<char>::compare returned %d\n", ret);
710 ret = (int)call_func5(p_collate_char_compare, this, str2, str2+4, str1, str1+4);
711 ok(ret == 1, "collate<char>::compare returned %d\n", ret);
712 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+3, str1, str1+4);
713 ok(ret == -1, "collate<char>::compare returned %d\n", ret);
714 call_func1(p_collate_char_dtor, this);
716 call_func1(p_numpunct_char_ctor, this);
717 call_func2(p_numpunct_char_falsename, this, &bstr);
718 p = call_func1(p_basic_string_char_cstr, &bstr);
719 ok(!strcmp(p, "false"), "numpunct<char>::falsename returned %s\n", p);
720 call_func1(p_basic_string_char_dtor, &bstr);
721 call_func1(p_numpunct_char_dtor, this);
724 static void test_virtual_base_dtors(void)
726 char this[512];
728 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 1);
729 call_func1(p_basic_ostringstream_char_vbase_dtor, this);
731 /* this test uses vbtable set by earlier test */
732 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 0);
733 call_func1(p_basic_ostringstream_char_dtor, this+basic_ostringstream_char_vbtable[1]);
734 call_func1(p_basic_ios_char_dtor, this+((int**)this)[0][1]);
737 static BOOL almost_eq(float f1, float f2)
739 f1 = (f1-f2)/f1;
740 if(f1 < 0)
741 f1 = -f1;
742 return f1 < 0.0001;
745 static void test_Ctraits_math_functions(void)
747 BYTE ret;
749 ret = p_std_Ctraits_float__Isnan(0.0);
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(-INFINITY);
756 ok(ret == FALSE, "ret = %d\n", ret);
758 ret = p_std_Ctraits_float__Isnan(IND);
759 ok(ret == TRUE, "ret = %d\n", ret);
761 ret = p_std_Ctraits_float__Isnan(NAN);
762 ok(ret == TRUE, "ret = %d\n", ret);
764 ret = p_std_Ctraits_double__Isnan(INFINITY);
765 ok(ret == FALSE, "ret = %d\n", ret);
767 ret = p_std_Ctraits_double__Isnan(IND);
768 ok(ret == TRUE, "ret = %d\n", ret);
770 ret = p_std_Ctraits_double__Isnan(NAN);
771 ok(ret == TRUE, "ret = %d\n", ret);
773 ret = p_std_Ctraits_long_double__Isnan(INFINITY);
774 ok(ret == FALSE, "ret = %d\n", ret);
776 ret = p_std_Ctraits_long_double__Isnan(IND);
777 ok(ret == TRUE, "ret = %d\n", ret);
779 ret = p_std_Ctraits_long_double__Isnan(NAN);
780 ok(ret == TRUE, "ret = %d\n", ret);
783 static void test_complex(void)
785 complex_float c1, c2, c3;
786 float f1, f2;
787 int scale;
788 int r;
790 f1 = 1;
791 f2 = 2;
792 call_func3(p_complex_float_ctor, &c1, &f1, &f2);
793 ok(c1.real == 1, "c1.real = %f\n", c1.real);
794 ok(c1.imag == 2, "c1.imag = %f\n", c1.imag);
796 f1 = p_complex_float__Fabs(&c1, &scale);
797 ok(almost_eq(f1, 0.559017), "abs(1+2i) = %f\n", f1);
798 ok(scale == 2, "scale = %d\n", scale);
800 f1 = -1;
801 f2 = 1;
802 call_func3(p_complex_float_ctor, &c2, &f1, &f2);
803 ok(c2.real == -1, "c2.real = %f\n", c1.real);
804 ok(c2.imag == 1, "c2.imag = %f\n", c1.imag);
806 f1 = p_complex_float__Fabs(&c2, &scale);
807 ok(almost_eq(f1, 0.353553), "abs(1-1i) = %f\n", f1);
808 ok(scale == 2, "scale = %d\n", scale);
810 p_complex_float_add(&c3, &c1, &c2);
811 ok(c3.real == 0, "c3.real = %f\n", c3.real);
812 ok(c3.imag == 3, "c3.imag = %f\n", c3.imag);
814 f1 = p_complex_float__Fabs(&c3, &scale);
815 ok(almost_eq(f1, 0.75), "abs(0+3i) = %f\n", f1);
816 ok(scale == 2, "scale = %d\n", scale);
818 p_complex_float_add(&c2, &c1, &c3);
819 ok(c2.real == 1, "c2.real = %f\n", c1.real);
820 ok(c2.imag == 5, "c2.imag = %f\n", c1.imag);
822 f1 = p_complex_float__Fabs(&c3, &scale);
823 ok(almost_eq(f1, 0.75), "abs(1+5i) = %f\n", f1);
824 ok(scale == 2, "scale = %d\n", scale);
826 /* (1+5i) / (0+3i) */
827 p_complex_float_div(&c1, &c2, &c3);
828 ok(almost_eq(c1.real, 1.666667), "c1.real = %f\n", c1.real);
829 ok(almost_eq(c1.imag, -0.33333), "c1.imag = %f\n", c1.imag);
831 /* (1+5i) / (2+0i) */
832 c3.real = 2;
833 c3.imag = 0;
834 p_complex_float_div(&c1, &c2, &c3);
835 ok(almost_eq(c1.real, 0.5), "c1.real = %f\n", c1.real);
836 ok(almost_eq(c1.imag, 2.5), "c1.imag = %f\n", c1.imag);
838 f1 = p_complex_float__Fabs(&c1, &scale);
839 ok(almost_eq(f1, 0.637377), "abs(0.5+2.5i) = %f\n", f1);
840 ok(scale == 2, "scale = %d\n", scale);
842 /* (1+5i) / 0 */
843 c3.real = 0;
844 p_complex_float_div(&c1, &c2, &c3);
845 ok(_isnan(c1.real), "c1.real = %f\n", c1.real);
846 ok(_isnan(c1.imag), "c1.imag = %f\n", c1.imag);
848 f1 = p_complex_float__Fabs(&c1, &scale);
849 ok(_isnan(f1), "abs(NaN+NaNi) = %f\n", f1);
850 ok(scale == 0, "scale = %d\n", scale);
852 /* (1+5i) / (NaN-2i) */
853 c1.imag = -2;
854 p_complex_float_div(&c3, &c2, &c1);
855 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
856 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
858 /* (NaN-2i) / (1+0i) */
859 c2.imag = 0;
860 p_complex_float_div(&c3, &c1, &c2);
861 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
862 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
864 /* (1+0i) + (NaN-2i) */
865 p_complex_float_add(&c3, &c2, &c1);
866 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
867 ok(c3.imag == -2, "c3.imag = %f\n", c3.imag);
869 f1 = p_complex_float__Fabs(&c3, &scale);
870 ok(_isnan(f1), "abs(NaN-2i) = %f\n", f1);
871 ok(scale == 0, "scale = %d\n", scale);
873 c3.real = 1000;
874 f1 = p_complex_float__Fabs(&c3, &scale);
875 ok(almost_eq(f1, 250.000504), "abs(1000-2i) = %f\n", f1);
876 ok(scale == 2, "scale = %d\n", scale);
878 c3.real = 0.1;
879 c3.imag = 0.1;
880 f1 = p_complex_float__Fabs(&c3, &scale);
881 ok(almost_eq(f1, 0.565685), "abs(0.1+0.1i) = %f\n", f1);
882 ok(scale == -2, "scale = %d\n", scale);
884 c3.real = 1;
885 c3.imag = 0;
886 f1 = p_complex_float__Fabs(&c3, &scale);
887 ok(almost_eq(f1, 0.25), "abs(1+0i) = %f\n", f1);
888 ok(scale == 2, "scale = %d\n", scale);
890 c3.real = 0.99;
891 c3.imag = 0;
892 f1 = p_complex_float__Fabs(&c3, &scale);
893 ok(almost_eq(f1, 3.96), "abs(0.99+0i) = %f\n", f1);
894 ok(scale == -2, "scale = %d\n", scale);
896 c3.real = 0;
897 c3.imag = 0;
898 f1 = p_complex_float__Fabs(&c3, &scale);
899 ok(f1 == 0, "abs(0+0i) = %f\n", f1);
900 ok(scale == 0, "scale = %d\n", scale);
902 c1.real = 0;
903 c1.imag = 0;
904 r = 3;
905 f1 = 3.312;
906 p_complex_float_tan(&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_tanh(&c2, &c1);
910 ok(c2.real == 0, "c2.real = %f\n", c2.real);
911 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
912 p_complex_float_log10(&c2, &c1);
913 ok(c2.real < -FLT_MAX /* c2.real == -inf */, "c2.real = %f\n", c2.real);
914 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
915 p_complex_float_sqrt(&c2, &c1);
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_ci(&c2, &c1, r);
919 ok(c2.real == 0, "c2.real = %f\n", c2.real);
920 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
921 p_complex_float_pow_fc(&c2, &f1, &c1);
922 ok(c2.real == 1, "c2.real = %f\n", c2.real);
923 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
924 p_complex_float_pow_cf(&c2, &c1, &f1);
925 ok(c2.real == 0, "c2.real = %f\n", c2.real);
926 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
928 c1.real = 3.14159/2;
929 c1.imag = 0;
930 p_complex_float_tan(&c2, &c1);
931 ok(almost_eq(c2.real, 788906.062500), "c2.real = %f\n", c2.real);
932 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
933 p_complex_float_tanh(&c2, &c1);
934 ok(almost_eq(c2.real, 0.917152), "c2.real = %f\n", c2.real);
935 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
936 p_complex_float_log10(&c2, &c1);
937 ok(almost_eq(c2.real, 0.196120), "c2.real = %f\n", c2.real);
938 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
939 p_complex_float_sqrt(&c2, &c1);
940 ok(almost_eq(c2.real, 1.253314), "c2.real = %f\n", c2.real);
941 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
942 p_complex_float_pow_ci(&c2, &c1, r);
943 ok(almost_eq(c2.real, 3.875775), "c2.real = %f\n", c2.real);
944 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
945 r = -r;
946 p_complex_float_pow_ci(&c2, &c1, r);
947 ok(almost_eq(c2.real, 0.258013), "c2.real = %f\n", c2.real);
948 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
949 r = -r;
950 p_complex_float_pow_fc(&c2, &f1, &c1);
951 ok(almost_eq(c2.real, 6.560778), "c2.real = %f\n", c2.real);
952 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
953 p_complex_float_pow_cf(&c2, &c1, &f1);
954 ok(almost_eq(c2.real, 4.462188), "c2.real = %f\n", c2.real);
955 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
957 c1.real = 7.12;
958 c1.imag = 0.17;
959 p_complex_float_tan(&c2, &c1);
960 ok(almost_eq(c2.real, 1.040818), "c2.real = %f\n", c2.real);
961 ok(almost_eq(c2.imag, 0.362651), "c2.imag = %f\n", c2.imag);
962 p_complex_float_tanh(&c2, &c1);
963 ok(almost_eq(c2.real, 0.999999), "c2.real = %f\n", c2.real);
964 ok(almost_eq(c2.imag, 4.3627e-7), "c2.imag = %g\n", c2.imag);
965 p_complex_float_log10(&c2, &c1);
966 ok(almost_eq(c2.real, 0.852604), "c2.real = %f\n", c2.real);
967 ok(almost_eq(c2.imag, 0.0103674), "c2.imag = %g\n", c2.imag);
968 p_complex_float_sqrt(&c2, &c1);
969 ok(almost_eq(c2.real, 2.668523), "c2.real = %f\n", c2.real);
970 ok(almost_eq(c2.imag, 0.0318528), "c2.imag = %g\n", c2.imag);
971 p_complex_float_pow_ci(&c2, &c1, r);
972 ok(almost_eq(c2.real, 360.326782), "c2.real = %f\n", c2.real);
973 ok(almost_eq(c2.imag, 25.849230), "c2.imag = %g\n", c2.imag);
974 r = -r;
975 p_complex_float_pow_ci(&c2, &c1, r);
976 ok(almost_eq(c2.real, 0.002761), "c2.real = %f\n", c2.real);
977 ok(almost_eq(c2.imag, -0.000198073), "c2.imag = %g\n", c2.imag);
978 r = -r;
979 p_complex_float_pow_fc(&c2, &f1, &c1);
980 ok(almost_eq(c2.real, 4942.879395), "c2.real = %f\n", c2.real);
981 ok(almost_eq(c2.imag, 1020.427368), "c2.imag = %g\n", c2.imag);
982 p_complex_float_pow_cf(&c2, &c1, &f1);
983 ok(almost_eq(c2.real, 664.453918), "c2.real = %f\n", c2.real);
984 ok(almost_eq(c2.imag, 52.643879), "c2.imag = %g\n", c2.imag);
986 c1.real = 0.14;
987 c1.imag = 0.19;
988 p_complex_float_tan(&c2, &c1);
989 ok(almost_eq(c2.real, 0.135859), "c2.real = %f\n", c2.real);
990 ok(almost_eq(c2.imag, 0.191341), "c2.imag = %f\n", c2.imag);
991 p_complex_float_tanh(&c2, &c1);
992 ok(almost_eq(c2.real, 0.144134), "c2.real = %f\n", c2.real);
993 ok(almost_eq(c2.imag, 0.188464), "c2.imag = %f\n", c2.imag);
994 p_complex_float_log10(&c2, &c1);
995 ok(almost_eq(c2.real, -0.627072), "c2.real = %f\n", c2.real);
996 ok(almost_eq(c2.imag, 0.4064), "c2.imag = %g\n", c2.imag);
997 p_complex_float_sqrt(&c2, &c1);
998 ok(almost_eq(c2.real, 0.433595), "c2.real = %f\n", c2.real);
999 ok(almost_eq(c2.imag, 0.219099), "c2.imag = %g\n", c2.imag);
1000 p_complex_float_pow_ci(&c2, &c1, r);
1001 ok(almost_eq(c2.real, -0.012418), "c2.real = %f\n", c2.real);
1002 ok(almost_eq(c2.imag, 0.004313), "c2.imag = %g\n", c2.imag);
1003 r = -r;
1004 p_complex_float_pow_ci(&c2, &c1, r);
1005 ok(almost_eq(c2.real, -71.859810), "c2.real = %f\n", c2.real);
1006 ok(almost_eq(c2.imag, -24.958229), "c2.imag = %g\n", c2.imag);
1007 p_complex_float_pow_fc(&c2, &f1, &c1);
1008 ok(almost_eq(c2.real, 1.152052), "c2.real = %f\n", c2.real);
1009 ok(almost_eq(c2.imag, 0.266751), "c2.imag = %g\n", c2.imag);
1010 p_complex_float_pow_cf(&c2, &c1, &f1);
1011 ok(almost_eq(c2.real, -0.008370), "c2.real = %f\n", c2.real);
1012 ok(almost_eq(c2.imag, 0.00035447), "c2.imag = %g\n", c2.imag);
1015 static struct {
1016 int value[2];
1017 const char* export_name;
1018 } vbtable_size_exports_list[] = {
1019 {{0x5c, 0xa8}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1020 {{0x54, 0x98}, "??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1021 {{0x5c, 0xa8}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1022 {{0x54, 0x98}, "??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1023 {{0x5c, 0xa8}, "??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1024 {{0x54, 0x98}, "??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1025 {{0x58, 0xa0}, "??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@"},
1026 {{0x58, 0xa0}, "??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@"},
1027 {{0x58, 0xa0}, "??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@"},
1028 {{ 0xc, 0x18}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1029 {{ 0x4, 0x8}, "??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1030 {{ 0xc, 0x18}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1031 {{ 0x4, 0x8}, "??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1032 {{ 0xc, 0x18}, "??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1033 {{ 0x4, 0x8}, "??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1034 {{ 0x8, 0x10}, "??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@"},
1035 {{ 0x8, 0x10}, "??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@"},
1036 {{ 0x8, 0x10}, "??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@"},
1037 {{0x50, 0x90}, "??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1038 {{0x50, 0x90}, "??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1039 {{0x50, 0x90}, "??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@"},
1040 {{0x54, 0x98}, "??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@"},
1041 {{0x54, 0x98}, "??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@"},
1042 {{0x54, 0x98}, "??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@"},
1043 {{ 0x4, 0x8}, "??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@"},
1044 {{ 0x4, 0x8}, "??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@"},
1045 {{ 0x4, 0x8}, "??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@"},
1046 {{0x4c, 0x88}, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@"},
1047 {{0x4c, 0x88}, "??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@"},
1048 {{0x4c, 0x88}, "??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@"},
1049 {{0x54, 0x98}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@"},
1050 {{0x4c, 0x88}, "??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@"},
1051 {{0x54, 0x98}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@"},
1052 {{0x4c, 0x88}, "??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@"},
1053 {{0x54, 0x98}, "??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@"},
1054 {{0x4c, 0x88}, "??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@"},
1055 {{ 0x0, 0x0}, 0}
1058 static void test_vbtable_size_exports(void)
1060 int i;
1061 const int *p_vbtable;
1062 int arch_idx = (sizeof(void*) == 8);
1064 for (i = 0; vbtable_size_exports_list[i].export_name; i++)
1066 SET(p_vbtable, vbtable_size_exports_list[i].export_name);
1068 ok(p_vbtable[0] == 0, "vbtable[0] wrong, got 0x%x\n", p_vbtable[0]);
1069 ok(p_vbtable[1] == vbtable_size_exports_list[i].value[arch_idx],
1070 "%d: %s[1] wrong, got 0x%x\n", i, vbtable_size_exports_list[i].export_name, p_vbtable[1]);
1076 static void test_locale__Locimp__Locimp_Addfac(void)
1078 locale__Locimp locimp;
1079 locale_facet facet;
1081 memset(&locimp, 0, sizeof(locimp));
1082 memset(&facet, 0, sizeof(facet));
1083 p_locale__Locimp__Locimp_Addfac(&locimp, &facet, 1);
1084 ok(locimp.facet_cnt == 40, "locimp.facet_cnt = %d\n", (int)locimp.facet_cnt);
1087 START_TEST(misc)
1089 if(!init())
1090 return;
1092 test_assign();
1093 test_equal();
1094 test_Copy_s();
1095 test_wctype();
1096 test__Getctype();
1097 test__Getcoll();
1098 test_towctrans();
1099 test_virtual_call();
1100 test_virtual_base_dtors();
1101 test_allocator_char();
1102 test_Ctraits_math_functions();
1103 test_complex();
1104 test_vbtable_size_exports();
1105 test_locale__Locimp__Locimp_Addfac();
1107 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
1109 FreeLibrary(msvcr);
1110 FreeLibrary(msvcp);