user32/tests: Don't test function directly when reporting GetLastError().
[wine/multimedia.git] / dlls / msvcp90 / tests / misc.c
bloba4e07d7dabfc452e5e795a45d3b18fb35762db17
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 typedef double LDOUBLE; /* long double is just a double */
32 typedef struct {
33 LCID handle;
34 unsigned page;
35 short *table;
36 int delfl;
37 } MSVCP__Ctypevec;
39 typedef struct {
40 LCID handle;
41 unsigned page;
42 } MSVCP__Collvec;
44 /* basic_string<char, char_traits<char>, allocator<char>> */
45 #define BUF_SIZE_CHAR 16
46 typedef struct
48 void *allocator;
49 union {
50 char buf[BUF_SIZE_CHAR];
51 char *ptr;
52 } data;
53 size_t size;
54 size_t res;
55 } basic_string_char;
57 /* class complex<float> */
58 typedef struct {
59 float real;
60 float imag;
61 } complex_float;
63 static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
64 static _locale_t (__cdecl *p__get_current_locale)(void);
65 static void (__cdecl *p__free_locale)(_locale_t);
66 static void (__cdecl *p_free)(void*);
67 static int * (__cdecl *p_errno)(void);
69 static void (__cdecl *p_char_assign)(void*, const void*);
70 static void (__cdecl *p_wchar_assign)(void*, const void*);
71 static void (__cdecl *p_short_assign)(void*, const void*);
73 static BYTE (__cdecl *p_char_eq)(const void*, const void*);
74 static BYTE (__cdecl *p_wchar_eq)(const void*, const void*);
75 static BYTE (__cdecl *p_short_eq)(const void*, const void*);
77 static char* (__cdecl *p_Copy_s)(char*, size_t, const char*, size_t);
79 static unsigned short (__cdecl *p_wctype)(const char*);
80 static MSVCP__Ctypevec* (__cdecl *p__Getctype)(MSVCP__Ctypevec*);
81 static /*MSVCP__Collvec*/ULONGLONG (__cdecl *p__Getcoll)(void);
82 static wctrans_t (__cdecl *p_wctrans)(const char*);
83 static wint_t (__cdecl *p_towctrans)(wint_t, wctrans_t);
85 #undef __thiscall
86 #ifdef __i386__
87 #define __thiscall __stdcall
88 #else
89 #define __thiscall __cdecl
90 #endif
92 static char* (__thiscall *p_char_address)(void*, char*);
93 static void* (__thiscall *p_char_ctor)(void*);
94 static void (__thiscall *p_char_deallocate)(void*, char*, size_t);
95 static char* (__thiscall *p_char_allocate)(void*, size_t);
96 static void (__thiscall *p_char_construct)(void*, char*, const char*);
97 static size_t (__thiscall *p_char_max_size)(void*);
99 static void* (__thiscall *p_collate_char_ctor_refs)(void*, size_t);
100 static int (__thiscall *p_collate_char_compare)(const void*, const char*,
101 const char*, const char*, const char*);
102 static void (__thiscall *p_collate_char_dtor)(void*);
103 static void* (__thiscall *p_numpunct_char_ctor)(void*);
104 static basic_string_char* (__thiscall *p_numpunct_char_falsename)(void*,basic_string_char*);
105 static void (__thiscall *p_numpunct_char_dtor)(void*);
106 static void (__thiscall *p_basic_string_char_dtor)(basic_string_char*);
107 static const char* (__thiscall *p_basic_string_char_cstr)(basic_string_char*);
109 static const int *basic_ostringstream_char_vbtable;
110 static /*basic_ostringstream_char*/void* (__thiscall *p_basic_ostringstream_char_ctor_mode)(
111 /*basic_ostringstream_char*/void*, int, /*MSVCP_bool*/int);
112 static void (__thiscall *p_basic_ostringstream_char_dtor)(/*basic_ostringstream_char*/void*);
113 static void (__thiscall *p_basic_ostringstream_char_vbase_dtor)(/*basic_ostringstream_char*/void*);
114 static void (__thiscall *p_basic_ios_char_dtor)(/*basic_ios_char*/void*);
116 static BOOL (__cdecl *p_std_Ctraits_float__Isnan)(float);
117 static BOOL (__cdecl *p_std_Ctraits_double__Isnan)(double);
118 static BOOL (__cdecl *p_std_Ctraits_long_double__Isnan)(LDOUBLE);
120 static complex_float* (__thiscall *p_complex_float_ctor)(complex_float*, const float*, const float*);
121 static complex_float* (__cdecl *p_complex_float_add)(complex_float*, const complex_float*, const complex_float*);
122 static complex_float* (__cdecl *p_complex_float_div)(complex_float*, const complex_float*, const complex_float*);
123 static float (__cdecl *p_complex_float__Fabs)(const complex_float*, int*);
124 static complex_float* (__cdecl *p_complex_float_tan)(complex_float*, const complex_float*);
125 static complex_float* (__cdecl *p_complex_float_tanh)(complex_float*, const complex_float*);
126 static complex_float* (__cdecl *p_complex_float_log10)(complex_float*, const complex_float*);
127 static complex_float* (__cdecl *p_complex_float_sqrt)(complex_float*, const complex_float*);
128 static complex_float* (__cdecl *p_complex_float_pow_ci)(complex_float*, const complex_float*, int);
129 static complex_float* (__cdecl *p_complex_float_pow_fc)(complex_float*, const float*, const complex_float*);
130 static complex_float* (__cdecl *p_complex_float_pow_cf)(complex_float*, const complex_float*, const float*);
132 static int invalid_parameter = 0;
133 static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
134 const wchar_t *function, const wchar_t *file,
135 unsigned line, uintptr_t arg)
137 ok(expression == NULL, "expression is not NULL\n");
138 ok(function == NULL, "function is not NULL\n");
139 ok(file == NULL, "file is not NULL\n");
140 ok(line == 0, "line = %u\n", line);
141 ok(arg == 0, "arg = %lx\n", (UINT_PTR)arg);
142 invalid_parameter++;
145 /* Emulate a __thiscall */
146 #ifdef __i386__
148 #include "pshpack1.h"
149 struct thiscall_thunk
151 BYTE pop_eax; /* popl %eax (ret addr) */
152 BYTE pop_edx; /* popl %edx (func) */
153 BYTE pop_ecx; /* popl %ecx (this) */
154 BYTE push_eax; /* pushl %eax */
155 WORD jmp_edx; /* jmp *%edx */
157 #include "poppack.h"
159 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
160 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
161 static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void *a, const void *b );
162 static void * (WINAPI *call_thiscall_func5)( void *func, void *this, const void *a, const void *b,
163 const void *c, const void *d );
165 static void init_thiscall_thunk(void)
167 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
168 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
169 thunk->pop_eax = 0x58; /* popl %eax */
170 thunk->pop_edx = 0x5a; /* popl %edx */
171 thunk->pop_ecx = 0x59; /* popl %ecx */
172 thunk->push_eax = 0x50; /* pushl %eax */
173 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
174 call_thiscall_func1 = (void *)thunk;
175 call_thiscall_func2 = (void *)thunk;
176 call_thiscall_func3 = (void *)thunk;
177 call_thiscall_func5 = (void *)thunk;
180 #define call_func1(func,_this) call_thiscall_func1(func,_this)
181 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)(a))
182 #define call_func3(func,_this,a,b) call_thiscall_func3(func,_this,(const void*)(a),(const void*)(b))
183 #define call_func5(func,_this,a,b,c,d) call_thiscall_func5(func,_this,(const void*)(a),(const void*)(b), \
184 (const void*)(c), (const void *)(d))
186 #else
188 #define init_thiscall_thunk()
189 #define call_func1(func,_this) func(_this)
190 #define call_func2(func,_this,a) func(_this,a)
191 #define call_func3(func,_this,a,b) func(_this,a,b)
192 #define call_func5(func,_this,a,b,c,d) func(_this,a,b,c,d)
194 #endif /* __i386__ */
196 static HMODULE msvcr, msvcp;
197 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
198 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
199 static BOOL init(void)
201 msvcr = LoadLibraryA("msvcr90.dll");
202 msvcp = LoadLibraryA("msvcp90.dll");
203 if(!msvcr || !msvcp) {
204 win_skip("msvcp90.dll or msvcrt90.dll not installed\n");
205 return FALSE;
208 p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
209 p__get_current_locale = (void*)GetProcAddress(msvcr, "_get_current_locale");
210 p__free_locale = (void*)GetProcAddress(msvcr, "_free_locale");
211 p_free = (void*)GetProcAddress(msvcr, "free");
212 p_errno = (void*)GetProcAddress(msvcr, "_errno");
213 if(!p_set_invalid_parameter_handler || !p__get_current_locale || !p__free_locale || !p_free || !p_errno) {
214 win_skip("Error setting tests environment\n");
215 return FALSE;
218 p_set_invalid_parameter_handler(test_invalid_parameter_handler);
220 SET(p_wctype, "wctype");
221 SET(p__Getctype, "_Getctype");
222 SET(p__Getcoll, "_Getcoll");
223 SET(p_wctrans, "wctrans");
224 SET(p_towctrans, "towctrans");
225 SET(basic_ostringstream_char_vbtable, "??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@");
227 SET(p_std_Ctraits_float__Isnan, "?_Isnan@?$_Ctraits@M@std@@SA_NM@Z");
228 SET(p_std_Ctraits_double__Isnan, "?_Isnan@?$_Ctraits@N@std@@SA_NN@Z");
229 SET(p_std_Ctraits_long_double__Isnan, "?_Isnan@?$_Ctraits@O@std@@SA_NO@Z");
231 if(sizeof(void*) == 8) { /* 64-bit initialization */
232 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAEADAEBD@Z");
233 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAEA_WAEB_W@Z");
234 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAEAGAEBG@Z");
236 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NAEBD0@Z");
237 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAEB_W0@Z");
238 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NAEBG0@Z");
240 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z");
242 SET(p_char_address, "?address@?$allocator@D@std@@QEBAPEADAEAD@Z");
243 SET(p_char_ctor, "??0?$allocator@D@std@@QEAA@XZ");
244 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QEAAXPEAD_K@Z");
245 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QEAAPEAD_K@Z");
246 SET(p_char_construct, "?construct@?$allocator@D@std@@QEAAXPEADAEBD@Z");
247 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QEBA_KXZ");
249 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QEAA@_K@Z");
250 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QEBAHPEBD000@Z");
251 SET(p_collate_char_dtor, "??1?$collate@D@std@@MEAA@XZ");
252 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QEAAXXZ");
253 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
254 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MEAA@XZ");
255 SET(p_basic_string_char_dtor,
256 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ");
257 SET(p_basic_string_char_cstr,
258 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
260 SET(p_basic_ostringstream_char_ctor_mode,
261 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z");
262 SET(p_basic_ostringstream_char_dtor,
263 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ");
264 SET(p_basic_ostringstream_char_vbase_dtor,
265 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ");
266 SET(p_basic_ios_char_dtor,
267 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ");
269 SET(p_complex_float_ctor,
270 "??0?$complex@M@std@@QEAA@AEBM0@Z");
271 SET(p_complex_float_add,
272 "??$?HM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
273 SET(p_complex_float_div,
274 "??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z");
275 SET(p_complex_float__Fabs,
276 "??$_Fabs@M@std@@YAMAEBV?$complex@M@0@PEAH@Z");
277 SET(p_complex_float_tan,
278 "??$tan@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
279 SET(p_complex_float_tanh,
280 "??$tanh@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
281 SET(p_complex_float_log10,
282 "??$log10@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
283 SET(p_complex_float_sqrt,
284 "??$sqrt@M@std@@YA?AV?$complex@M@0@AEBV10@@Z");
285 SET(p_complex_float_pow_ci,
286 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@H@Z");
287 SET(p_complex_float_pow_fc,
288 "??$pow@M@std@@YA?AV?$complex@M@0@AEBMAEBV10@@Z");
289 SET(p_complex_float_pow_cf,
290 "??$pow@M@std@@YA?AV?$complex@M@0@AEBV10@AEBM@Z");
291 } else {
292 #ifdef __arm__
293 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
294 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
295 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
297 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
298 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
299 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
301 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
303 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
304 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
305 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
306 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
307 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
308 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
310 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
311 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
312 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
313 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
314 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
315 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
316 SET(p_basic_string_char_dtor,
317 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
318 SET(p_basic_string_char_cstr,
319 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
321 SET(p_basic_ostringstream_char_ctor_mode,
322 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
323 SET(p_basic_ostringstream_char_dtor,
324 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
325 SET(p_basic_ostringstream_char_vbase_dtor,
326 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
327 SET(p_basic_ios_char_dtor,
328 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAA@XZ");
330 SET(p_complex_float_ctor,
331 "??0?$complex@M@std@@QAE@ABM0@Z");
332 SET(p_complex_float_add,
333 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
334 SET(p_complex_float_div,
335 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
336 SET(p_complex_float__Fabs,
337 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
338 SET(p_complex_float_tan,
339 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
340 SET(p_complex_float_tanh,
341 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
342 SET(p_complex_float_log10,
343 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
344 SET(p_complex_float_sqrt,
345 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
346 SET(p_complex_float_pow_ci,
347 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
348 SET(p_complex_float_pow_fc,
349 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
350 SET(p_complex_float_pow_cf,
351 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
352 #else
353 SET(p_char_assign, "?assign@?$char_traits@D@std@@SAXAADABD@Z");
354 SET(p_wchar_assign, "?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z");
355 SET(p_short_assign, "?assign@?$char_traits@G@std@@SAXAAGABG@Z");
357 SET(p_char_eq, "?eq@?$char_traits@D@std@@SA_NABD0@Z");
358 SET(p_wchar_eq, "?eq@?$char_traits@_W@std@@SA_NAB_W0@Z");
359 SET(p_short_eq, "?eq@?$char_traits@G@std@@SA_NABG0@Z");
361 SET(p_Copy_s, "?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z");
363 SET(p_char_address, "?address@?$allocator@D@std@@QBEPADAAD@Z");
364 SET(p_char_ctor, "??0?$allocator@D@std@@QAE@XZ");
365 SET(p_char_deallocate, "?deallocate@?$allocator@D@std@@QAEXPADI@Z");
366 SET(p_char_allocate, "?allocate@?$allocator@D@std@@QAEPADI@Z");
367 SET(p_char_construct, "?construct@?$allocator@D@std@@QAEXPADABD@Z");
368 SET(p_char_max_size, "?max_size@?$allocator@D@std@@QBEIXZ");
370 SET(p_collate_char_ctor_refs, "??0?$collate@D@std@@QAE@I@Z");
371 SET(p_collate_char_compare, "?compare@?$collate@D@std@@QBEHPBD000@Z");
372 SET(p_collate_char_dtor, "??1?$collate@D@std@@MAE@XZ");
373 SET(p_numpunct_char_ctor, "??_F?$numpunct@D@std@@QAEXXZ");
374 SET(p_numpunct_char_falsename, "?falsename@?$numpunct@D@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ");
375 SET(p_numpunct_char_dtor, "??1?$numpunct@D@std@@MAE@XZ");
376 SET(p_basic_string_char_dtor,
377 "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ");
378 SET(p_basic_string_char_cstr,
379 "?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
381 SET(p_basic_ostringstream_char_ctor_mode,
382 "??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z");
383 SET(p_basic_ostringstream_char_dtor,
384 "??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ");
385 SET(p_basic_ostringstream_char_vbase_dtor,
386 "??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ");
387 SET(p_basic_ios_char_dtor,
388 "??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ");
390 SET(p_complex_float_ctor,
391 "??0?$complex@M@std@@QAE@ABM0@Z");
392 SET(p_complex_float_add,
393 "??$?HM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
394 SET(p_complex_float_div,
395 "??$?KM@std@@YA?AV?$complex@M@0@ABV10@0@Z");
396 SET(p_complex_float__Fabs,
397 "??$_Fabs@M@std@@YAMABV?$complex@M@0@PAH@Z");
398 SET(p_complex_float_tan,
399 "??$tan@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
400 SET(p_complex_float_tanh,
401 "??$tanh@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
402 SET(p_complex_float_log10,
403 "??$log10@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
404 SET(p_complex_float_sqrt,
405 "??$sqrt@M@std@@YA?AV?$complex@M@0@ABV10@@Z");
406 SET(p_complex_float_pow_ci,
407 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@H@Z");
408 SET(p_complex_float_pow_fc,
409 "??$pow@M@std@@YA?AV?$complex@M@0@ABMABV10@@Z");
410 SET(p_complex_float_pow_cf,
411 "??$pow@M@std@@YA?AV?$complex@M@0@ABV10@ABM@Z");
412 #endif
415 init_thiscall_thunk();
416 return TRUE;
419 static void test_assign(void)
421 const char in[] = "abc";
422 char out[4];
424 out[1] = '#';
425 p_char_assign(out, in);
426 ok(out[0] == in[0], "out[0] = %c\n", out[0]);
427 ok(out[1] == '#', "out[1] = %c\n", out[1]);
429 out[2] = '#';
430 p_wchar_assign(out, in);
431 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
432 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
433 ok(out[2] == '#', "out[2] = %c\n", out[2]);
435 out[2] = '#';
436 p_short_assign(out, in);
437 ok(*((char*)out)==in[0] && *((char*)out+1)==in[1],
438 "out[0] = %d, out[1] = %d\n", (int)out[0], (int)out[1]);
439 ok(out[2] == '#', "out[2] = %c\n", out[2]);
442 static void test_equal(void)
444 static const char in1[] = "abc";
445 static const char in2[] = "ab";
446 static const char in3[] = "a";
447 static const char in4[] = "b";
448 BYTE ret;
450 ret = p_char_eq(in1, in2);
451 ok(ret == TRUE, "ret = %d\n", (int)ret);
452 ret = p_char_eq(in1, in3);
453 ok(ret == TRUE, "ret = %d\n", (int)ret);
454 ret = p_char_eq(in1, in4);
455 ok(ret == FALSE, "ret = %d\n", (int)ret);
457 ret = p_wchar_eq(in1, in2);
458 ok(ret == TRUE, "ret = %d\n", (int)ret);
459 ret = p_wchar_eq(in1, in3);
460 ok(ret == FALSE, "ret = %d\n", (int)ret);
461 ret = p_wchar_eq(in1, in4);
462 ok(ret == FALSE, "ret = %d\n", (int)ret);
464 ret = p_short_eq(in1, in2);
465 ok(ret == TRUE, "ret = %d\n", (int)ret);
466 ret = p_short_eq(in1, in3);
467 ok(ret == FALSE, "ret = %d\n", (int)ret);
468 ret = p_short_eq(in1, in4);
469 ok(ret == FALSE, "ret = %d\n", (int)ret);
472 static void test_Copy_s(void)
474 static const char src[] = "abcd";
475 char dest[32], *ret;
477 dest[4] = '#';
478 dest[5] = '\0';
479 ret = p_Copy_s(dest, 4, src, 4);
480 ok(ret == dest, "ret != dest\n");
481 ok(dest[4] == '#', "dest[4] != '#'\n");
482 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
484 ret = p_Copy_s(dest, 32, src, 4);
485 ok(ret == dest, "ret != dest\n");
486 ok(dest[4] == '#', "dest[4] != '#'\n");
487 ok(!memcmp(dest, src, sizeof(char[4])), "dest = %s\n", dest);
489 *p_errno() = 0xdeadbeef;
490 dest[0] = '#';
491 ret = p_Copy_s(dest, 3, src, 4);
492 ok(ret == dest, "ret != dest\n");
493 ok(dest[0] == '\0', "dest[0] != 0\n");
494 ok(invalid_parameter==1, "invalid_parameter = %d\n",
495 invalid_parameter);
496 invalid_parameter = 0;
497 ok(*p_errno() == ERANGE, "errno = %d\n", *p_errno());
499 *p_errno() = 0xdeadbeef;
500 p_Copy_s(NULL, 32, src, 4);
501 ok(invalid_parameter==1, "invalid_parameter = %d\n",
502 invalid_parameter);
503 invalid_parameter = 0;
504 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
506 *p_errno() = 0xdeadbeef;
507 p_Copy_s(dest, 32, NULL, 4);
508 ok(invalid_parameter==1, "invalid_parameter = %d\n",
509 invalid_parameter);
510 invalid_parameter = 0;
511 ok(*p_errno() == EINVAL, "errno = %d\n", *p_errno());
514 static void test_wctype(void)
516 static const struct {
517 const char *name;
518 unsigned short mask;
519 } properties[] = {
520 { "alnum", 0x107 },
521 { "alpha", 0x103 },
522 { "cntrl", 0x020 },
523 { "digit", 0x004 },
524 { "graph", 0x117 },
525 { "lower", 0x002 },
526 { "print", 0x157 },
527 { "punct", 0x010 },
528 { "space", 0x008 },
529 { "upper", 0x001 },
530 { "xdigit", 0x080 },
531 { "ALNUM", 0x000 },
532 { "Alnum", 0x000 },
533 { "", 0x000 }
535 int i, ret;
537 for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++) {
538 ret = p_wctype(properties[i].name);
539 ok(properties[i].mask == ret, "%d - Expected %x, got %x\n", i, properties[i].mask, ret);
543 static void test__Getctype(void)
545 MSVCP__Ctypevec ret;
546 _locale_t locale;
548 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
549 ok(ret.handle == 0, "ret.handle = %d\n", ret.handle);
550 ok(ret.page == 0, "ret.page = %d\n", ret.page);
551 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
552 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
553 p_free(ret.table);
555 locale = p__get_current_locale();
556 locale->locinfo->lc_handle[LC_COLLATE] = 0x1234567;
557 p__free_locale(locale);
558 ok(p__Getctype(&ret) == &ret, "__Getctype returned incorrect pointer\n");
559 ok(ret.handle == 0x1234567, "ret.handle = %d\n", ret.handle);
560 ok(ret.page == 0, "ret.page = %d\n", ret.page);
561 ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
562 ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
563 p_free(ret.table);
566 static void test__Getcoll(void)
568 ULONGLONG (__cdecl *p__Getcoll_arg)(MSVCP__Collvec*);
569 _locale_t locale;
571 union {
572 MSVCP__Collvec collvec;
573 ULONGLONG ull;
574 }ret;
576 locale = p__get_current_locale();
577 locale->locinfo->lc_handle[LC_COLLATE] = 0x7654321;
578 p__free_locale(locale);
579 ret.ull = 0;
580 p__Getcoll_arg = (void*)p__Getcoll;
581 p__Getcoll_arg(&ret.collvec);
582 ok(ret.collvec.handle == 0, "ret.handle = %x\n", ret.collvec.handle);
583 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
585 ret.ull = p__Getcoll();
586 ok(ret.collvec.handle == 0x7654321, "ret.collvec.handle = %x\n", ret.collvec.handle);
587 ok(ret.collvec.page == 0, "ret.page = %x\n", ret.collvec.page);
590 static void test_towctrans(void)
592 wchar_t ret;
594 ret = p_wctrans("tolower");
595 ok(ret == 2, "wctrans returned %d, expected 2\n", ret);
596 ret = p_wctrans("toupper");
597 ok(ret == 1, "wctrans returned %d, expected 1\n", ret);
598 ret = p_wctrans("toLower");
599 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
600 ret = p_wctrans("");
601 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
602 if(0) { /* crashes on windows */
603 ret = p_wctrans(NULL);
604 ok(ret == 0, "wctrans returned %d, expected 0\n", ret);
607 ret = p_towctrans('t', 2);
608 ok(ret == 't', "towctrans('t', 2) returned %c, expected t\n", ret);
609 ret = p_towctrans('T', 2);
610 ok(ret == 't', "towctrans('T', 2) returned %c, expected t\n", ret);
611 ret = p_towctrans('T', 0);
612 ok(ret == 't', "towctrans('T', 0) returned %c, expected t\n", ret);
613 ret = p_towctrans('T', 3);
614 ok(ret == 't', "towctrans('T', 3) returned %c, expected t\n", ret);
615 ret = p_towctrans('t', 1);
616 ok(ret == 'T', "towctrans('t', 1) returned %c, expected T\n", ret);
617 ret = p_towctrans('T', 1);
618 ok(ret == 'T', "towctrans('T', 1) returned %c, expected T\n", ret);
621 static void test_allocator_char(void)
623 void *allocator = (void*)0xdeadbeef;
624 char *ptr;
625 char val;
626 unsigned int size;
628 allocator = call_func1(p_char_ctor, allocator);
629 ok(allocator == (void*)0xdeadbeef, "allocator = %p\n", allocator);
631 ptr = call_func2(p_char_address, NULL, (void*)0xdeadbeef);
632 ok(ptr == (void*)0xdeadbeef, "incorrect address (%p)\n", ptr);
634 ptr = NULL;
635 ptr = call_func2(p_char_allocate, allocator, 10);
636 ok(ptr != NULL, "Memory allocation failed\n");
638 ptr[0] = ptr[1] = '#';
639 val = 'a';
640 call_func3(p_char_construct, allocator, ptr, &val);
641 val = 'b';
642 call_func3(p_char_construct, allocator, (ptr+1), &val);
643 ok(ptr[0] == 'a', "ptr[0] = %c\n", ptr[0]);
644 ok(ptr[1] == 'b', "ptr[1] = %c\n", ptr[1]);
646 call_func3(p_char_deallocate, allocator, ptr, -1);
648 size = (unsigned int)call_func1(p_char_max_size, allocator);
649 ok(size == (unsigned int)0xffffffff, "size = %x\n", size);
652 static void test_virtual_call(void)
654 BYTE this[256];
655 basic_string_char bstr;
656 _locale_t locale;
657 const char *p;
658 char str1[] = "test";
659 char str2[] = "TEST";
660 int ret;
662 locale = p__get_current_locale();
663 locale->locinfo->lc_handle[LC_COLLATE] = 1;
664 p__free_locale(locale);
665 call_func2(p_collate_char_ctor_refs, this, 0);
666 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+4, str1, str1+4);
667 ok(ret == 0, "collate<char>::compare returned %d\n", ret);
668 ret = (int)call_func5(p_collate_char_compare, this, str2, str2+4, str1, str1+4);
669 ok(ret == 1, "collate<char>::compare returned %d\n", ret);
670 ret = (int)call_func5(p_collate_char_compare, this, str1, str1+3, str1, str1+4);
671 ok(ret == -1, "collate<char>::compare returned %d\n", ret);
672 call_func1(p_collate_char_dtor, this);
674 call_func1(p_numpunct_char_ctor, this);
675 call_func2(p_numpunct_char_falsename, this, &bstr);
676 p = call_func1(p_basic_string_char_cstr, &bstr);
677 ok(!strcmp(p, "false"), "numpunct<char>::falsename returned %s\n", p);
678 call_func1(p_basic_string_char_dtor, &bstr);
679 call_func1(p_numpunct_char_dtor, this);
682 static void test_virtual_base_dtors(void)
684 char this[512];
686 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 1);
687 call_func1(p_basic_ostringstream_char_vbase_dtor, this);
689 /* this test uses vbtable set by earlier test */
690 call_func3(p_basic_ostringstream_char_ctor_mode, this, 0, 0);
691 call_func1(p_basic_ostringstream_char_dtor, this+basic_ostringstream_char_vbtable[1]);
692 call_func1(p_basic_ios_char_dtor, this+((int**)this)[0][1]);
695 static BOOL almost_eq(float f1, float f2)
697 f1 = (f1-f2)/f1;
698 if(f1 < 0)
699 f1 = -f1;
700 return f1 < 0.0001;
703 static void test_Ctraits_math_functions(void)
705 BYTE ret;
707 ret = p_std_Ctraits_float__Isnan(0.0);
708 ok(ret == FALSE, "ret = %d\n", ret);
710 ret = p_std_Ctraits_float__Isnan(0.0 / 0.0);
711 ok(ret == TRUE, "ret = %d\n", ret);
713 ret = p_std_Ctraits_float__Isnan(1.0 / 0.0);
714 ok(ret == FALSE, "ret = %d\n", ret);
716 ret = p_std_Ctraits_float__Isnan(-1.0 / 0.0);
717 ok(ret == FALSE, "ret = %d\n", ret);
719 ret = p_std_Ctraits_float__Isnan(log(-1.0));
720 ok(ret == TRUE, "ret = %d\n", ret);
722 ret = p_std_Ctraits_float__Isnan(sqrt(-1.0));
723 ok(ret == TRUE, "ret = %d\n", ret);
725 ret = p_std_Ctraits_double__Isnan(3.14159 / 0.0);
726 ok(ret == FALSE, "ret = %d\n", ret);
728 ret = p_std_Ctraits_double__Isnan(log(-3.14159));
729 ok(ret == TRUE, "ret = %d\n", ret);
731 ret = p_std_Ctraits_long_double__Isnan(3.14159 / 0.0);
732 ok(ret == FALSE, "ret = %d\n", ret);
734 ret = p_std_Ctraits_long_double__Isnan(sqrt(-3.14159));
735 ok(ret == TRUE, "ret = %d\n", ret);
738 static void test_complex(void)
740 complex_float c1, c2, c3;
741 float f1, f2;
742 int scale;
743 int r;
745 f1 = 1;
746 f2 = 2;
747 call_func3(p_complex_float_ctor, &c1, &f1, &f2);
748 ok(c1.real == 1, "c1.real = %f\n", c1.real);
749 ok(c1.imag == 2, "c1.imag = %f\n", c1.imag);
751 f1 = p_complex_float__Fabs(&c1, &scale);
752 ok(almost_eq(f1, 0.559017), "abs(1+2i) = %f\n", f1);
753 ok(scale == 2, "scale = %d\n", scale);
755 f1 = -1;
756 f2 = 1;
757 call_func3(p_complex_float_ctor, &c2, &f1, &f2);
758 ok(c2.real == -1, "c2.real = %f\n", c1.real);
759 ok(c2.imag == 1, "c2.imag = %f\n", c1.imag);
761 f1 = p_complex_float__Fabs(&c2, &scale);
762 ok(almost_eq(f1, 0.353553), "abs(1-1i) = %f\n", f1);
763 ok(scale == 2, "scale = %d\n", scale);
765 p_complex_float_add(&c3, &c1, &c2);
766 ok(c3.real == 0, "c3.real = %f\n", c3.real);
767 ok(c3.imag == 3, "c3.imag = %f\n", c3.imag);
769 f1 = p_complex_float__Fabs(&c3, &scale);
770 ok(almost_eq(f1, 0.75), "abs(0+3i) = %f\n", f1);
771 ok(scale == 2, "scale = %d\n", scale);
773 p_complex_float_add(&c2, &c1, &c3);
774 ok(c2.real == 1, "c2.real = %f\n", c1.real);
775 ok(c2.imag == 5, "c2.imag = %f\n", c1.imag);
777 f1 = p_complex_float__Fabs(&c3, &scale);
778 ok(almost_eq(f1, 0.75), "abs(1+5i) = %f\n", f1);
779 ok(scale == 2, "scale = %d\n", scale);
781 /* (1+5i) / (0+3i) */
782 p_complex_float_div(&c1, &c2, &c3);
783 ok(almost_eq(c1.real, 1.666667), "c1.real = %f\n", c1.real);
784 ok(almost_eq(c1.imag, -0.33333), "c1.imag = %f\n", c1.imag);
786 /* (1+5i) / (2+0i) */
787 c3.real = 2;
788 c3.imag = 0;
789 p_complex_float_div(&c1, &c2, &c3);
790 ok(almost_eq(c1.real, 0.5), "c1.real = %f\n", c1.real);
791 ok(almost_eq(c1.imag, 2.5), "c1.imag = %f\n", c1.imag);
793 f1 = p_complex_float__Fabs(&c1, &scale);
794 ok(almost_eq(f1, 0.637377), "abs(0.5+2.5i) = %f\n", f1);
795 ok(scale == 2, "scale = %d\n", scale);
797 /* (1+5i) / 0 */
798 c3.real = 0;
799 p_complex_float_div(&c1, &c2, &c3);
800 ok(_isnan(c1.real), "c1.real = %f\n", c1.real);
801 ok(_isnan(c1.imag), "c1.imag = %f\n", c1.imag);
803 f1 = p_complex_float__Fabs(&c1, &scale);
804 ok(_isnan(f1), "abs(NaN+NaNi) = %f\n", f1);
805 ok(scale == 0, "scale = %d\n", scale);
807 /* (1+5i) / (NaN-2i) */
808 c1.imag = -2;
809 p_complex_float_div(&c3, &c2, &c1);
810 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
811 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
813 /* (NaN-2i) / (1+0i) */
814 c2.imag = 0;
815 p_complex_float_div(&c3, &c1, &c2);
816 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
817 ok(_isnan(c3.imag), "c3.imag = %f\n", c3.imag);
819 /* (1+0i) + (NaN-2i) */
820 p_complex_float_add(&c3, &c2, &c1);
821 ok(_isnan(c3.real), "c3.real = %f\n", c3.real);
822 ok(c3.imag == -2, "c3.imag = %f\n", c3.imag);
824 f1 = p_complex_float__Fabs(&c3, &scale);
825 ok(_isnan(f1), "abs(NaN-2i) = %f\n", f1);
826 ok(scale == 0, "scale = %d\n", scale);
828 c3.real = 1000;
829 f1 = p_complex_float__Fabs(&c3, &scale);
830 ok(almost_eq(f1, 250.000504), "abs(1000-2i) = %f\n", f1);
831 ok(scale == 2, "scale = %d\n", scale);
833 c3.real = 0.1;
834 c3.imag = 0.1;
835 f1 = p_complex_float__Fabs(&c3, &scale);
836 ok(almost_eq(f1, 0.565685), "abs(0.1+0.1i) = %f\n", f1);
837 ok(scale == -2, "scale = %d\n", scale);
839 c3.real = 1;
840 c3.imag = 0;
841 f1 = p_complex_float__Fabs(&c3, &scale);
842 ok(almost_eq(f1, 0.25), "abs(1+0i) = %f\n", f1);
843 ok(scale == 2, "scale = %d\n", scale);
845 c3.real = 0.99;
846 c3.imag = 0;
847 f1 = p_complex_float__Fabs(&c3, &scale);
848 ok(almost_eq(f1, 3.96), "abs(0.99+0i) = %f\n", f1);
849 ok(scale == -2, "scale = %d\n", scale);
851 c3.real = 0;
852 c3.imag = 0;
853 f1 = p_complex_float__Fabs(&c3, &scale);
854 ok(f1 == 0, "abs(0+0i) = %f\n", f1);
855 ok(scale == 0, "scale = %d\n", scale);
857 c1.real = 0;
858 c1.imag = 0;
859 r = 3;
860 f1 = 3.312;
861 p_complex_float_tan(&c2, &c1);
862 ok(c2.real == 0, "c2.real = %f\n", c2.real);
863 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
864 p_complex_float_tanh(&c2, &c1);
865 ok(c2.real == 0, "c2.real = %f\n", c2.real);
866 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
867 p_complex_float_log10(&c2, &c1);
868 ok(c2.real < -FLT_MAX /* c2.real == -inf */, "c2.real = %f\n", c2.real);
869 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
870 p_complex_float_sqrt(&c2, &c1);
871 ok(c2.real == 0, "c2.real = %f\n", c2.real);
872 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
873 p_complex_float_pow_ci(&c2, &c1, r);
874 ok(c2.real == 0, "c2.real = %f\n", c2.real);
875 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
876 p_complex_float_pow_fc(&c2, &f1, &c1);
877 ok(c2.real == 1, "c2.real = %f\n", c2.real);
878 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
879 p_complex_float_pow_cf(&c2, &c1, &f1);
880 ok(c2.real == 0, "c2.real = %f\n", c2.real);
881 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
883 c1.real = 3.14159/2;
884 c1.imag = 0;
885 p_complex_float_tan(&c2, &c1);
886 ok(almost_eq(c2.real, 788906.062500), "c2.real = %f\n", c2.real);
887 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
888 p_complex_float_tanh(&c2, &c1);
889 ok(almost_eq(c2.real, 0.917152), "c2.real = %f\n", c2.real);
890 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
891 p_complex_float_log10(&c2, &c1);
892 ok(almost_eq(c2.real, 0.196120), "c2.real = %f\n", c2.real);
893 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
894 p_complex_float_sqrt(&c2, &c1);
895 ok(almost_eq(c2.real, 1.253314), "c2.real = %f\n", c2.real);
896 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
897 p_complex_float_pow_ci(&c2, &c1, r);
898 ok(almost_eq(c2.real, 3.875775), "c2.real = %f\n", c2.real);
899 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
900 r = -r;
901 p_complex_float_pow_ci(&c2, &c1, r);
902 ok(almost_eq(c2.real, 0.258013), "c2.real = %f\n", c2.real);
903 ok(c2.imag == 0, "c2.imag = %g\n", c2.imag);
904 r = -r;
905 p_complex_float_pow_fc(&c2, &f1, &c1);
906 ok(almost_eq(c2.real, 6.560778), "c2.real = %f\n", c2.real);
907 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
908 p_complex_float_pow_cf(&c2, &c1, &f1);
909 ok(almost_eq(c2.real, 4.462188), "c2.real = %f\n", c2.real);
910 ok(c2.imag == 0, "c2.imag = %f\n", c2.imag);
912 c1.real = 7.12;
913 c1.imag = 0.17;
914 p_complex_float_tan(&c2, &c1);
915 ok(almost_eq(c2.real, 1.040818), "c2.real = %f\n", c2.real);
916 ok(almost_eq(c2.imag, 0.362651), "c2.imag = %f\n", c2.imag);
917 p_complex_float_tanh(&c2, &c1);
918 ok(almost_eq(c2.real, 0.999999), "c2.real = %f\n", c2.real);
919 ok(almost_eq(c2.imag, 4.3627e-7), "c2.imag = %g\n", c2.imag);
920 p_complex_float_log10(&c2, &c1);
921 ok(almost_eq(c2.real, 0.852604), "c2.real = %f\n", c2.real);
922 ok(almost_eq(c2.imag, 0.0103674), "c2.imag = %g\n", c2.imag);
923 p_complex_float_sqrt(&c2, &c1);
924 ok(almost_eq(c2.real, 2.668523), "c2.real = %f\n", c2.real);
925 ok(almost_eq(c2.imag, 0.0318528), "c2.imag = %g\n", c2.imag);
926 p_complex_float_pow_ci(&c2, &c1, r);
927 ok(almost_eq(c2.real, 360.326782), "c2.real = %f\n", c2.real);
928 ok(almost_eq(c2.imag, 25.849230), "c2.imag = %g\n", c2.imag);
929 r = -r;
930 p_complex_float_pow_ci(&c2, &c1, r);
931 ok(almost_eq(c2.real, 0.002761), "c2.real = %f\n", c2.real);
932 ok(almost_eq(c2.imag, -0.000198073), "c2.imag = %g\n", c2.imag);
933 r = -r;
934 p_complex_float_pow_fc(&c2, &f1, &c1);
935 ok(almost_eq(c2.real, 4942.879395), "c2.real = %f\n", c2.real);
936 ok(almost_eq(c2.imag, 1020.427368), "c2.imag = %g\n", c2.imag);
937 p_complex_float_pow_cf(&c2, &c1, &f1);
938 ok(almost_eq(c2.real, 664.453918), "c2.real = %f\n", c2.real);
939 ok(almost_eq(c2.imag, 52.643879), "c2.imag = %g\n", c2.imag);
941 c1.real = 0.14;
942 c1.imag = 0.19;
943 p_complex_float_tan(&c2, &c1);
944 ok(almost_eq(c2.real, 0.135859), "c2.real = %f\n", c2.real);
945 ok(almost_eq(c2.imag, 0.191341), "c2.imag = %f\n", c2.imag);
946 p_complex_float_tanh(&c2, &c1);
947 ok(almost_eq(c2.real, 0.144134), "c2.real = %f\n", c2.real);
948 ok(almost_eq(c2.imag, 0.188464), "c2.imag = %f\n", c2.imag);
949 p_complex_float_log10(&c2, &c1);
950 ok(almost_eq(c2.real, -0.627072), "c2.real = %f\n", c2.real);
951 ok(almost_eq(c2.imag, 0.4064), "c2.imag = %g\n", c2.imag);
952 p_complex_float_sqrt(&c2, &c1);
953 ok(almost_eq(c2.real, 0.433595), "c2.real = %f\n", c2.real);
954 ok(almost_eq(c2.imag, 0.219099), "c2.imag = %g\n", c2.imag);
955 p_complex_float_pow_ci(&c2, &c1, r);
956 ok(almost_eq(c2.real, -0.012418), "c2.real = %f\n", c2.real);
957 ok(almost_eq(c2.imag, 0.004313), "c2.imag = %g\n", c2.imag);
958 r = -r;
959 p_complex_float_pow_ci(&c2, &c1, r);
960 ok(almost_eq(c2.real, -71.859810), "c2.real = %f\n", c2.real);
961 ok(almost_eq(c2.imag, -24.958229), "c2.imag = %g\n", c2.imag);
962 p_complex_float_pow_fc(&c2, &f1, &c1);
963 ok(almost_eq(c2.real, 1.152052), "c2.real = %f\n", c2.real);
964 ok(almost_eq(c2.imag, 0.266751), "c2.imag = %g\n", c2.imag);
965 p_complex_float_pow_cf(&c2, &c1, &f1);
966 ok(almost_eq(c2.real, -0.008370), "c2.real = %f\n", c2.real);
967 ok(almost_eq(c2.imag, 0.00035447), "c2.imag = %g\n", c2.imag);
970 START_TEST(misc)
972 if(!init())
973 return;
975 test_assign();
976 test_equal();
977 test_Copy_s();
978 test_wctype();
979 test__Getctype();
980 test__Getcoll();
981 test_towctrans();
982 test_virtual_call();
983 test_virtual_base_dtors();
984 test_allocator_char();
985 test_Ctraits_math_functions();
986 test_complex();
988 ok(!invalid_parameter, "invalid_parameter_handler was invoked too many times\n");
990 FreeLibrary(msvcr);
991 FreeLibrary(msvcp);