1 /* Unit test suite for msvcrt C++ objects
3 * Copyright 2003 Jon Griffiths
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * This tests is only valid for ix86 platforms, on others it's a no-op.
21 * Some tests cannot be checked with ok(), for example the dtors. We simply
22 * call them to ensure we don't crash ;-)
24 * If we build this test with VC++ in debug mode, we will fail in _chkstk()
25 * or at program exit malloc() checking if these methods haven't been
26 * implemented correctly (they have).
28 * Tested with a range of native msvcrt's from v4 -> v7.
30 #include "wine/test.h"
35 /* Skip these tests for non x86 platforms */
41 typedef struct __exception
48 typedef struct __type_info
55 /* Function pointers. We need to use these to call these funcs as __thiscall */
56 static HMODULE hMsvcrt;
58 static void* (*poperator_new)(unsigned int);
59 static void (*poperator_delete)(void*);
60 static void* (*pmalloc)(unsigned int);
61 static void (*pfree)(void*);
64 static void (WINAPI *pexception_ctor)(exception*,LPCSTR*);
65 static void (WINAPI *pexception_copy_ctor)(exception*,exception*);
66 static void (WINAPI *pexception_default_ctor)(exception*);
67 static void (WINAPI *pexception_dtor)(exception*);
68 static exception* (WINAPI *pexception_opequals)(exception*,exception*);
69 static char* (WINAPI *pexception_what)(exception*);
70 static void* (WINAPI *pexception_vtable)(exception*);
71 static void (WINAPI *pexception_vector_dtor)(exception*,unsigned int);
72 static void (WINAPI *pexception_scalar_dtor)(exception*,unsigned int);
75 static void (WINAPI *pbad_typeid_ctor)(exception*,LPCSTR);
76 static void (WINAPI *pbad_typeid_ctor_closure)(exception*);
77 static void (WINAPI *pbad_typeid_copy_ctor)(exception*,exception*);
78 static void (WINAPI *pbad_typeid_dtor)(exception*);
79 static exception* (WINAPI *pbad_typeid_opequals)(exception*,exception*);
80 static char* (WINAPI *pbad_typeid_what)(exception*);
81 static void* (WINAPI *pbad_typeid_vtable)(exception*);
82 static void (WINAPI *pbad_typeid_vector_dtor)(exception*,unsigned int);
83 static void (WINAPI *pbad_typeid_scalar_dtor)(exception*,unsigned int);
86 static void (WINAPI *pbad_cast_ctor)(exception*,LPCSTR*);
87 static void (WINAPI *pbad_cast_ctor2)(exception*,LPCSTR);
88 static void (WINAPI *pbad_cast_ctor_closure)(exception*);
89 static void (WINAPI *pbad_cast_copy_ctor)(exception*,exception*);
90 static void (WINAPI *pbad_cast_dtor)(exception*);
91 static exception* (WINAPI *pbad_cast_opequals)(exception*,exception*);
92 static char* (WINAPI *pbad_cast_what)(exception*);
93 static void* (WINAPI *pbad_cast_vtable)(exception*);
94 static void (WINAPI *pbad_cast_vector_dtor)(exception*,unsigned int);
95 static void (WINAPI *pbad_cast_scalar_dtor)(exception*,unsigned int);
97 /* __non_rtti_object */
98 static void (WINAPI *p__non_rtti_object_ctor)(exception*,LPCSTR);
99 static void (WINAPI *p__non_rtti_object_copy_ctor)(exception*,exception*);
100 static void (WINAPI *p__non_rtti_object_dtor)(exception*);
101 static exception* (WINAPI *p__non_rtti_object_opequals)(exception*,exception*);
102 static char* (WINAPI *p__non_rtti_object_what)(exception*);
103 static void* (WINAPI *p__non_rtti_object_vtable)(exception*);
104 static void (WINAPI *p__non_rtti_object_vector_dtor)(exception*,unsigned int);
105 static void (WINAPI *p__non_rtti_object_scalar_dtor)(exception*,unsigned int);
108 static void (WINAPI *ptype_info_dtor)(type_info*);
109 static char* (WINAPI *ptype_info_raw_name)(type_info*);
110 static char* (WINAPI *ptype_info_name)(type_info*);
111 static int (WINAPI *ptype_info_before)(type_info*,type_info*);
112 static int (WINAPI *ptype_info_opequals_equals)(type_info*,type_info*);
113 static int (WINAPI *ptype_info_opnot_equals)(type_info*,type_info*);
116 static type_info* (*p__RTtypeid)(void*);
117 static void* (*p__RTCastToVoid)(void*);
118 static void* (*p__RTDynamicCast)(void*,int,void*,void*,int);
121 static char* (*p__unDName)(char*,const char*,int,void*,void*,unsigned short int);
124 /* _very_ early native versions have serious RTTI bugs, so we check */
125 static void* bAncientVersion;
127 /* Emulate a __thiscall */
129 static inline void* do_call_func1(void *func, void *_this)
131 volatile void* retval = 0;
140 return (void*)retval;
143 static inline void* do_call_func2(void *func, void *_this, const void* arg)
145 volatile void* retval = 0;
155 return (void*)retval;
158 static void* do_call_func1(void *func, void *_this)
161 __asm__ __volatile__ ("call *%1"
163 : "g" (func), "c" (_this)
167 static void* do_call_func2(void *func, void *_this, const void* arg)
170 __asm__ __volatile__ ("pushl %2\n\tcall *%1"
172 : "r" (func), "g" (arg), "c" (_this)
178 #define call_func1(x,y) do_call_func1((void*)x,(void*)y)
179 #define call_func2(x,y,z) do_call_func2((void*)x,(void*)y,(const void*)z)
181 /* Some exports are only available in later versions */
182 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
183 #define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
185 static void InitFunctionPtrs(void)
187 hMsvcrt = GetModuleHandleA("msvcrt.dll");
189 hMsvcrt = GetModuleHandleA("msvcrtd.dll");
190 ok(hMsvcrt != 0, "LoadLibraryA failed\n");
193 SETNOFAIL(poperator_new, "??_U@YAPAXI@Z");
194 SETNOFAIL(poperator_delete, "??_V@YAXPAX@Z");
195 SET(pmalloc, "malloc");
199 poperator_new = pmalloc;
200 if (!poperator_delete)
201 poperator_delete = pfree;
203 SET(pexception_ctor, "??0exception@@QAE@ABQBD@Z");
204 SET(pexception_copy_ctor, "??0exception@@QAE@ABV0@@Z");
205 SET(pexception_default_ctor, "??0exception@@QAE@XZ");
206 SET(pexception_dtor, "??1exception@@UAE@XZ");
207 SET(pexception_opequals, "??4exception@@QAEAAV0@ABV0@@Z");
208 SET(pexception_what, "?what@exception@@UBEPBDXZ");
209 SET(pexception_vtable, "??_7exception@@6B@");
210 SET(pexception_vector_dtor, "??_Eexception@@UAEPAXI@Z");
211 SET(pexception_scalar_dtor, "??_Gexception@@UAEPAXI@Z");
213 SET(pbad_typeid_ctor, "??0bad_typeid@@QAE@PBD@Z");
214 SETNOFAIL(pbad_typeid_ctor_closure, "??_Fbad_typeid@@QAEXXZ");
215 SET(pbad_typeid_copy_ctor, "??0bad_typeid@@QAE@ABV0@@Z");
216 SET(pbad_typeid_dtor, "??1bad_typeid@@UAE@XZ");
217 SET(pbad_typeid_opequals, "??4bad_typeid@@QAEAAV0@ABV0@@Z");
218 SET(pbad_typeid_what, "?what@exception@@UBEPBDXZ");
219 SET(pbad_typeid_vtable, "??_7bad_typeid@@6B@");
220 SET(pbad_typeid_vector_dtor, "??_Ebad_typeid@@UAEPAXI@Z");
221 SET(pbad_typeid_scalar_dtor, "??_Gbad_typeid@@UAEPAXI@Z");
223 SETNOFAIL(pbad_cast_ctor, "??0bad_cast@@QAE@ABQBD@Z");
225 SET(pbad_cast_ctor, "??0bad_cast@@AAE@PBQBD@Z");
226 SETNOFAIL(pbad_cast_ctor2, "??0bad_cast@@QAE@PBD@Z");
227 SETNOFAIL(pbad_cast_ctor_closure, "??_Fbad_cast@@QAEXXZ");
228 SET(pbad_cast_copy_ctor, "??0bad_cast@@QAE@ABV0@@Z");
229 SET(pbad_cast_dtor, "??1bad_cast@@UAE@XZ");
230 SET(pbad_cast_opequals, "??4bad_cast@@QAEAAV0@ABV0@@Z");
231 SET(pbad_cast_what, "?what@exception@@UBEPBDXZ");
232 SET(pbad_cast_vtable, "??_7bad_cast@@6B@");
233 SET(pbad_cast_vector_dtor, "??_Ebad_cast@@UAEPAXI@Z");
234 SET(pbad_cast_scalar_dtor, "??_Gbad_cast@@UAEPAXI@Z");
236 SET(p__non_rtti_object_ctor, "??0__non_rtti_object@@QAE@PBD@Z");
237 SET(p__non_rtti_object_copy_ctor, "??0__non_rtti_object@@QAE@ABV0@@Z");
238 SET(p__non_rtti_object_dtor, "??1__non_rtti_object@@UAE@XZ");
239 SET(p__non_rtti_object_opequals, "??4__non_rtti_object@@QAEAAV0@ABV0@@Z");
240 SET(p__non_rtti_object_what, "?what@exception@@UBEPBDXZ");
241 SET(p__non_rtti_object_vtable, "??_7__non_rtti_object@@6B@");
242 SET(p__non_rtti_object_vector_dtor, "??_E__non_rtti_object@@UAEPAXI@Z");
243 SET(p__non_rtti_object_scalar_dtor, "??_G__non_rtti_object@@UAEPAXI@Z");
245 SET(ptype_info_dtor, "??1type_info@@UAE@XZ");
246 SET(ptype_info_raw_name, "?raw_name@type_info@@QBEPBDXZ");
247 SET(ptype_info_name, "?name@type_info@@QBEPBDXZ");
248 SET(ptype_info_before, "?before@type_info@@QBEHABV1@@Z");
249 SET(ptype_info_opequals_equals, "??8type_info@@QBEHABV0@@Z");
250 SET(ptype_info_opnot_equals, "??9type_info@@QBEHABV0@@Z");
252 SET(p__RTtypeid, "__RTtypeid");
253 SET(p__RTCastToVoid, "__RTCastToVoid");
254 SET(p__RTDynamicCast, "__RTDynamicCast");
256 SET(p__unDName,"__unDName");
258 /* Extremely early versions export logic_error, and crash in RTTI */
259 SETNOFAIL(bAncientVersion, "??0logic_error@@QAE@ABQBD@Z");
263 static void test_exception(void)
265 static const char* e_name = "An exception name";
267 exception e, e2, e3, *pe;
269 if (!poperator_new || !poperator_delete ||
270 !pexception_ctor || !pexception_copy_ctor || !pexception_default_ctor ||
271 !pexception_dtor || !pexception_opequals || !pexception_what ||
272 !pexception_vtable || !pexception_vector_dtor || !pexception_scalar_dtor)
275 /* 'const char*&' ctor */
276 memset(&e, 0, sizeof(e));
277 call_func2(pexception_ctor, &e, &e_name);
278 ok(e.vtable != NULL, "Null exception vtable for e\n");
279 ok(e.name && e.name != e_name && !strcmp(e.name, "An exception name"), "Bad name '%s' for e\n", e.name);
280 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
283 memset(&e2, 0, sizeof(e2));
284 call_func2(pexception_copy_ctor, &e2, &e);
285 ok(e2.vtable != NULL, "Null exception vtable for e2\n");
286 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
287 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
290 memset(&e3, 1, sizeof(e3));
291 call_func1(pexception_default_ctor, &e3);
292 ok(e3.vtable != NULL, "Null exception vtable for e3\n");
293 ok(e3.name == NULL, "Bad exception name for e3\n");
294 ok(e3.do_free == 0, "do_free set to %d for e3\n", e3.do_free);
296 ok(e.vtable == e2.vtable && e.vtable == e3.vtable, "exception vtables differ!\n");
298 /* Test calling the dtors */
299 call_func1(pexception_dtor, &e2);
300 call_func1(pexception_dtor, &e3);
302 /* Operator equals */
303 memset(&e2, 0, sizeof(e2));
304 pe = call_func2(pexception_opequals, &e2, &e);
305 ok(e2.vtable != NULL, "Null exception vtable for e2\n");
306 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
307 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
308 ok(pe == &e2, "opequals didn't return e2\n");
311 name = call_func1(pexception_what, &e2);
312 ok(e2.name == name, "Bad exception name from e2::what()\n");
315 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
316 call_func1(pexception_dtor, &e2);
319 pe = poperator_new(sizeof(exception));
320 ok(pe != NULL, "new() failed\n");
323 call_func2(pexception_ctor, pe, &e_name);
325 call_func2(pexception_scalar_dtor, pe, 0); /* Shouldn't delete pe */
328 call_func2(pexception_scalar_dtor, pe, 1); /* Should delete pe */
331 pe = poperator_new(sizeof(exception));
332 ok(pe != NULL, "new() failed\n");
335 /* vector dtor, single element */
336 call_func2(pexception_ctor, pe, &e_name);
337 call_func2(pexception_vector_dtor, pe, 1); /* Should delete pe as single element*/
340 pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
341 ok(pe != NULL, "new() failed\n");
344 /* vector dtor, multiple elements */
345 char name[] = "a constant";
347 pe = (exception*)((int*)pe + 1);
348 call_func2(pexception_ctor, &pe[0], &e_name);
349 call_func2(pexception_ctor, &pe[1], &e_name);
350 call_func2(pexception_ctor, &pe[2], &e_name);
352 pe[3].do_free = 1; /* Crash if we try to free this */
353 call_func2(pexception_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
356 /* test our exported vtable is kosher */
357 pe = (void*)pexception_vtable; /* Use the exception struct to get vtable ptrs */
358 pexception_vector_dtor = (void*)pe->vtable;
359 pexception_what = (void*)pe->name;
361 name = call_func1(pexception_what, &e);
362 ok(e.name == name, "Bad exception name from vtable e::what()\n");
364 if (p__RTtypeid && !bAncientVersion)
367 type_info *ti = p__RTtypeid(&e);
368 ok (ti && ti->mangled &&
369 !strcmp(ti->mangled, ".?AVexception@@"), "bad rtti for e\n");
373 /* Check the returned type_info has rtti too */
374 type_info *ti2 = p__RTtypeid(ti);
375 ok (ti2 != NULL && !strcmp(ti2->mangled, ".?AVtype_info@@"), "bad rtti for e's type_info\n");
379 call_func2(pexception_vector_dtor, &e, 0); /* Should delete e.name, but not e */
382 /* This test is basically a cut 'n' paste of the exception test. but it verifies that
383 * bad_typeid works the exact same way... */
384 static void test_bad_typeid(void)
386 static const char* e_name = "A bad_typeid name";
388 exception e, e2, e3, *pe;
390 if (!poperator_new || !poperator_delete ||
391 !pbad_typeid_ctor || !pbad_typeid_copy_ctor ||
392 !pbad_typeid_dtor || !pbad_typeid_opequals || !pbad_typeid_what ||
393 !pbad_typeid_vtable || !pbad_typeid_vector_dtor || !pbad_typeid_scalar_dtor)
396 /* 'const char*' ctor */
397 memset(&e, 0, sizeof(e));
398 call_func2(pbad_typeid_ctor, &e, e_name);
399 ok(e.vtable != NULL, "Null bad_typeid vtable for e\n");
400 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_typeid name"), "Bad name '%s' for e\n", e.name);
401 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
404 memset(&e2, 0, sizeof(e2));
405 call_func2(pbad_typeid_copy_ctor, &e2, &e);
406 ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
407 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad name '%s' for e2\n", e2.name);
408 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
411 if (pbad_typeid_ctor_closure)
413 memset(&e3, 1, sizeof(e3));
414 call_func1(pbad_typeid_ctor_closure, &e3);
415 ok(e3.vtable != NULL, "Null bad_typeid vtable for e3\n");
416 ok(e3.name && !strcmp(e3.name, "bad typeid"), "Bad bad_typeid name for e3\n");
417 ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
418 ok(e.vtable == e3.vtable, "bad_typeid closure vtables differ!\n");
419 call_func1(pbad_typeid_dtor, &e3);
421 ok(e.vtable == e2.vtable, "bad_typeid vtables differ!\n");
423 /* Test calling the dtors */
424 call_func1(pbad_typeid_dtor, &e2);
426 /* Operator equals */
427 memset(&e2, 1, sizeof(e2));
428 pe = call_func2(pbad_typeid_opequals, &e2, &e);
429 ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
430 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad bad_typeid name for e2\n");
431 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
432 ok(pe == &e2, "opequals didn't return e2\n");
435 name = call_func1(pbad_typeid_what, &e2);
436 ok(e2.name == name, "Bad bad_typeid name from e2::what()\n");
439 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
440 call_func1(pbad_typeid_dtor, &e2);
443 pe = poperator_new(sizeof(exception));
444 ok(pe != NULL, "new() failed\n");
447 call_func2(pbad_typeid_ctor, pe, e_name);
449 call_func2(pbad_typeid_scalar_dtor, pe, 0); /* Shouldn't delete pe */
452 call_func2(pbad_typeid_scalar_dtor, pe, 1); /* Should delete pe */
455 pe = poperator_new(sizeof(exception));
456 ok(pe != NULL, "new() failed\n");
459 /* vector dtor, single element */
460 call_func2(pbad_typeid_ctor, pe, e_name);
461 call_func2(pbad_typeid_vector_dtor, pe, 1); /* Should delete pe as single element*/
464 pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
465 ok(pe != NULL, "new() failed\n");
468 /* vector dtor, multiple elements */
470 pe = (exception*)((int*)pe + 1);
471 call_func2(pbad_typeid_ctor, &pe[0], e_name);
472 call_func2(pbad_typeid_ctor, &pe[1], e_name);
473 call_func2(pbad_typeid_ctor, &pe[2], e_name);
475 pe[3].do_free = 1; /* Crash if we try to free this element */
476 call_func2(pbad_typeid_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
479 /* test our exported vtable is kosher */
480 pe = (void*)pbad_typeid_vtable; /* Use the exception struct to get vtable ptrs */
481 pbad_typeid_vector_dtor = (void*)pe->vtable;
482 pbad_typeid_what = (void*)pe->name;
484 name = call_func1(pbad_typeid_what, &e);
485 ok(e.name == name, "Bad bad_typeid name from vtable e::what()\n");
487 if (p__RTtypeid && !bAncientVersion)
490 type_info *ti = p__RTtypeid(&e);
491 ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_typeid@@"), "bad rtti for e (%s)\n",
492 !ti ? "null" : ti->mangled);
495 call_func2(pbad_typeid_vector_dtor, &e, 0); /* Should delete e.name, but not e */
499 /* Ditto for this test... */
500 static void test_bad_cast(void)
502 static const char* e_name = "A bad_cast name";
504 exception e, e2, e3, *pe;
506 if (!poperator_new || !poperator_delete ||
507 !pbad_cast_ctor || !pbad_cast_copy_ctor ||
508 !pbad_cast_dtor || !pbad_cast_opequals || !pbad_cast_what ||
509 !pbad_cast_vtable || !pbad_cast_vector_dtor || !pbad_cast_scalar_dtor)
514 /* 'const char*' ctor */
515 memset(&e, 0, sizeof(e));
516 call_func2(pbad_cast_ctor2, &e, e_name);
517 ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
518 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
519 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
520 call_func1(pbad_cast_dtor, &e);
523 /* 'const char*&' ctor */
524 memset(&e, 0, sizeof(e));
525 call_func2(pbad_cast_ctor, &e, &e_name);
526 ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
527 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
528 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
531 memset(&e2, 0, sizeof(e2));
532 call_func2(pbad_cast_copy_ctor, &e2, &e);
533 ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
534 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad name '%s' for e2\n", e2.name);
535 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
538 if (pbad_cast_ctor_closure)
540 memset(&e3, 1, sizeof(e3));
541 call_func1(pbad_cast_ctor_closure, &e3);
542 ok(e3.vtable != NULL, "Null bad_cast vtable for e3\n");
543 ok(e3.name && !strcmp(e3.name, "bad cast"), "Bad bad_cast name for e3\n");
544 ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
545 ok(e.vtable == e3.vtable, "bad_cast closure vtables differ!\n");
546 call_func1(pbad_cast_dtor, &e3);
548 ok(e.vtable == e2.vtable, "bad_cast vtables differ!\n");
550 /* Test calling the dtors */
551 call_func1(pbad_cast_dtor, &e2);
553 /* Operator equals */
554 memset(&e2, 1, sizeof(e2));
555 pe = call_func2(pbad_cast_opequals, &e2, &e);
556 ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
557 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad bad_cast name for e2\n");
558 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
559 ok(pe == &e2, "opequals didn't return e2\n");
562 name = call_func1(pbad_cast_what, &e2);
563 ok(e2.name == name, "Bad bad_cast name from e2::what()\n");
566 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
567 call_func1(pbad_cast_dtor, &e2);
570 pe = poperator_new(sizeof(exception));
571 ok(pe != NULL, "new() failed\n");
574 call_func2(pbad_cast_ctor, pe, &e_name);
576 call_func2(pbad_cast_scalar_dtor, pe, 0); /* Shouldn't delete pe */
579 call_func2(pbad_cast_scalar_dtor, pe, 1); /* Should delete pe */
582 pe = poperator_new(sizeof(exception));
583 ok(pe != NULL, "new() failed\n");
586 /* vector dtor, single element */
587 call_func2(pbad_cast_ctor, pe, &e_name);
588 call_func2(pbad_cast_vector_dtor, pe, 1); /* Should delete pe as single element*/
591 pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
592 ok(pe != NULL, "new() failed\n");
595 /* vector dtor, multiple elements */
597 pe = (exception*)((int*)pe + 1);
598 call_func2(pbad_cast_ctor, &pe[0], &e_name);
599 call_func2(pbad_cast_ctor, &pe[1], &e_name);
600 call_func2(pbad_cast_ctor, &pe[2], &e_name);
602 pe[3].do_free = 1; /* Crash if we try to free this element */
603 call_func2(pbad_cast_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
606 /* test our exported vtable is kosher */
607 pe = (void*)pbad_cast_vtable; /* Use the exception struct to get vtable ptrs */
608 pbad_cast_vector_dtor = (void*)pe->vtable;
609 pbad_cast_what = (void*)pe->name;
611 name = call_func1(pbad_cast_what, &e);
612 ok(e.name == name, "Bad bad_cast name from vtable e::what()\n");
614 if (p__RTtypeid && !bAncientVersion)
617 type_info *ti = p__RTtypeid(&e);
618 ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_cast@@"), "bad rtti for e\n");
620 call_func2(pbad_cast_vector_dtor, &e, 0); /* Should delete e.name, but not e */
623 /* ... and this one */
624 static void test___non_rtti_object(void)
626 static const char* e_name = "A __non_rtti_object name";
628 exception e, e2, *pe;
630 if (!poperator_new || !poperator_delete ||
631 !p__non_rtti_object_ctor || !p__non_rtti_object_copy_ctor ||
632 !p__non_rtti_object_dtor || !p__non_rtti_object_opequals || !p__non_rtti_object_what ||
633 !p__non_rtti_object_vtable || !p__non_rtti_object_vector_dtor || !p__non_rtti_object_scalar_dtor)
636 /* 'const char*' ctor */
637 memset(&e, 0, sizeof(e));
638 call_func2(p__non_rtti_object_ctor, &e, e_name);
639 ok(e.vtable != NULL, "Null __non_rtti_object vtable for e\n");
640 ok(e.name && e.name != e_name && !strcmp(e.name, "A __non_rtti_object name"), "Bad name '%s' for e\n", e.name);
641 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
644 memset(&e2, 0, sizeof(e2));
645 call_func2(p__non_rtti_object_copy_ctor, &e2, &e);
646 ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
647 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad name '%s' for e2\n", e2.name);
648 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
649 ok(e.vtable == e2.vtable, "__non_rtti_object vtables differ!\n");
651 /* Test calling the dtors */
652 call_func1(p__non_rtti_object_dtor, &e2);
654 /* Operator equals */
655 memset(&e2, 1, sizeof(e2));
656 pe = call_func2(p__non_rtti_object_opequals, &e2, &e);
657 ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
658 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad __non_rtti_object name for e2\n");
659 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
660 ok(pe == &e2, "opequals didn't return e2\n");
663 name = call_func1(p__non_rtti_object_what, &e2);
664 ok(e2.name == name, "Bad __non_rtti_object name from e2::what()\n");
667 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
668 call_func1(p__non_rtti_object_dtor, &e2);
671 pe = poperator_new(sizeof(exception));
672 ok(pe != NULL, "new() failed\n");
675 call_func2(p__non_rtti_object_ctor, pe, e_name);
677 call_func2(p__non_rtti_object_scalar_dtor, pe, 0); /* Shouldn't delete pe */
680 call_func2(p__non_rtti_object_scalar_dtor, pe, 1); /* Should delete pe */
683 pe = poperator_new(sizeof(exception));
684 ok(pe != NULL, "new() failed\n");
687 /* vector dtor, single element */
688 call_func2(p__non_rtti_object_ctor, pe, e_name);
689 call_func2(p__non_rtti_object_vector_dtor, pe, 1); /* Should delete pe as single element*/
692 pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
693 ok(pe != NULL, "new() failed\n");
696 /* vector dtor, multiple elements */
698 pe = (exception*)((int*)pe + 1);
699 call_func2(p__non_rtti_object_ctor, &pe[0], e_name);
700 call_func2(p__non_rtti_object_ctor, &pe[1], e_name);
701 call_func2(p__non_rtti_object_ctor, &pe[2], e_name);
703 pe[3].do_free = 1; /* Crash if we try to free this element */
704 call_func2(p__non_rtti_object_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
707 /* test our exported vtable is kosher */
708 pe = (void*)p__non_rtti_object_vtable; /* Use the exception struct to get vtable ptrs */
709 p__non_rtti_object_vector_dtor = (void*)pe->vtable;
710 p__non_rtti_object_what = (void*)pe->name;
712 name = call_func1(p__non_rtti_object_what, &e);
713 ok(e.name == name, "Bad __non_rtti_object name from vtable e::what()\n");
715 if (p__RTtypeid && !bAncientVersion)
718 type_info *ti = p__RTtypeid(&e);
719 ok (ti != NULL && !strcmp(ti->mangled, ".?AV__non_rtti_object@@"), "bad rtti for e\n");
721 call_func2(p__non_rtti_object_vector_dtor, &e, 0); /* Should delete e.name, but not e */
725 static void test_type_info(void)
727 static type_info t1 = { NULL, NULL,{'.','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
728 static type_info t1_1 = { NULL, NULL,{'?','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
729 static type_info t2 = { NULL, NULL, {'.','?','A','V','t','e','s','t','2','@','@',0,0,0,0,0 } };
733 if (!pmalloc || !pfree || !ptype_info_dtor || !ptype_info_raw_name ||
734 !ptype_info_name || !ptype_info_before ||
735 !ptype_info_opequals_equals || !ptype_info_opnot_equals)
738 /* Test calling the dtors */
739 call_func1(ptype_info_dtor, &t1); /* No effect, since name is NULL */
740 t1.name = pmalloc(64);
741 strcpy(t1.name, "foo");
742 call_func1(ptype_info_dtor, &t1); /* Frees t1.name using 'free' */
746 name = call_func1(ptype_info_raw_name, &t1);
748 /* FIXME: This fails on native; it shouldn't though - native bug?
749 * ok(name && !strcmp(name, t1.mangled), "bad raw_name '%s' for t1 (expected '%s')\n", name, t1.mangled);
751 ok(t1.name == NULL, "raw_name() set name for t1\n");
755 name = call_func1(ptype_info_name, &t1);
756 ok(name && t1.name && !strcmp(name, t1.name), "bad name '%s' for t1\n", name);
758 ok(t1.name && !strcmp(t1.name, "class test1"), "demangled to '%s' for t1\n", t1.name);
759 call_func1(ptype_info_dtor, &t1);
763 res = (int)call_func2(ptype_info_before, &t1, &t1);
764 ok(res == 0, "expected 0, got %d\n", res);
765 res = (int)call_func2(ptype_info_before, &t2, &t1);
766 ok(res == 0, "expected 0, got %d\n", res);
767 res = (int)call_func2(ptype_info_before, &t1, &t2);
768 ok(res == 1, "expected 1, got %d\n", res);
769 /* Doesn't check first char */
770 res = (int)call_func2(ptype_info_before, &t1, &t1_1);
771 ok(res == 0, "expected 0, got %d\n", res);
773 /* opequals_equals */
775 res = (int)call_func2(ptype_info_opequals_equals, &t1, &t1);
776 ok(res == 1, "expected 1, got %d\n", res);
777 res = (int)call_func2(ptype_info_opequals_equals, &t1, &t2);
778 ok(res == 0, "expected 0, got %d\n", res);
779 res = (int)call_func2(ptype_info_opequals_equals, &t2, &t1);
780 ok(res == 0, "expected 0, got %d\n", res);
784 res = (int)call_func2(ptype_info_opnot_equals, &t1, &t1);
785 ok(res == 0, "expected 0, got %d\n", res);
786 res = (int)call_func2(ptype_info_opnot_equals, &t1, &t2);
787 ok(res == 1, "expected 1, got %d\n", res);
788 res = (int)call_func2(ptype_info_opnot_equals, &t2, &t1);
789 ok(res == 1, "expected 1, got %d\n", res);
792 /* Test RTTI functions */
793 static void test_rtti(void)
795 static const char* e_name = "name";
800 if (bAncientVersion ||
801 !p__RTCastToVoid || !p__RTtypeid || !pexception_ctor || !pbad_typeid_ctor || !p__RTDynamicCast)
804 call_func2(pexception_ctor, &e, &e_name);
805 call_func2(pbad_typeid_ctor, &b, e_name);
807 /* dynamic_cast to void* */
808 casted = p__RTCastToVoid(&e);
809 ok (casted == (void*)&e, "failed cast to void\n");
811 /* dynamic_cast up */
812 ti = p__RTtypeid(&e);
813 bti = p__RTtypeid(&b);
815 casted = p__RTDynamicCast(&b, 0, NULL, ti, 0);
816 ok (casted == (void*)&b, "failed cast from bad_cast to exception\n");
818 /* dynamic_cast down */
819 casted = p__RTDynamicCast(&e, 0, NULL, bti, 0);
820 ok (casted == NULL, "Cast succeeded\n");
829 static void test_demangle_datatype(void)
832 struct _demangle demangle[]={
833 /* { "BlaBla"," ?? ::Bla", FALSE}, */
834 { "ABVVec4@ref2@dice@@","class dice::ref2::Vec4 const &",TRUE},
835 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0H@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,7>", TRUE},
836 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HO@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,126>",TRUE},
837 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HOA@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,2016>",TRUE},
838 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HOAA@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,32256>",TRUE},
839 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", FALSE},
840 /* { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@",FALSE}, */
842 int i, num_test = (sizeof(demangle)/sizeof(struct _demangle));
844 for (i = 0; i < num_test; i++)
846 name = p__unDName(0, demangle[i].mangled, 0, pmalloc, pfree, 0x2800);
847 if (demangle[i].test_in_wine)
848 ok(name != NULL && !strcmp(name,demangle[i].result), "Got name \"%s\" for %d\n", name, i);
850 todo_wine ok(name != NULL && !strcmp(name,demangle[i].result), "Got name %s for %d\n", name, i);
855 /* Compare two strings treating multiple spaces (' ', ascii 0x20) in s2
856 as single space. Needed for test_demangle as __unDName() returns sometimes
857 two spaces instead of one in some older native msvcrt dlls. */
858 static int strcmp_space(const char *s1, const char *s2)
860 const char* s2start = s2;
862 while (*s1 == *s2 && *s1) {
866 if (*s2 == ' ' && s2 > s2start && *(s2 - 1) == ' ')
870 } while (*s1 && *s2);
874 static void test_demangle(void)
876 static struct {const char* in; const char* out;} test[] = {
877 {"??0bad_alloc@std@@QAE@ABV01@@Z", "public: __thiscall std::bad_alloc::bad_alloc(class std::bad_alloc const &)"},
878 {"??0bad_alloc@std@@QAE@PBD@Z", "public: __thiscall std::bad_alloc::bad_alloc(char const *)"},
879 {"??0bad_cast@@AAE@PBQBD@Z", "private: __thiscall bad_cast::bad_cast(char const * const *)"},
880 {"??0bad_cast@@QAE@ABQBD@Z", "public: __thiscall bad_cast::bad_cast(char const * const &)"},
881 {"??0bad_cast@@QAE@ABV0@@Z", "public: __thiscall bad_cast::bad_cast(class bad_cast const &)"},
882 {"??0bad_exception@std@@QAE@ABV01@@Z", "public: __thiscall std::bad_exception::bad_exception(class std::bad_exception const &)"},
883 {"??0bad_exception@std@@QAE@PBD@Z", "public: __thiscall std::bad_exception::bad_exception(char const *)"},
884 {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z", "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(class std::basic_filebuf<char,struct std::char_traits<char> > const &)"},
885 {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z", "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(struct _iobuf *)"},
886 {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z", "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(enum std::_Uninitialized)"},
887 {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z", "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(class std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> > const &)"},
888 {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z", "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(struct _iobuf *)"},
889 {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z", "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(enum std::_Uninitialized)"},
890 {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z", "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
891 {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z", "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)"},
892 {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z", "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(int)"},
893 {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV01@@Z", "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
894 {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z", "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,int)"},
895 {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z", "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(int)"},
896 {"??0?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@ABV_Locinfo@1@I@Z", "public: __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(class std::_Locinfo const &,unsigned int)"},
897 {"??0?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@I@Z", "public: __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(unsigned int)"},
898 {"??0?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@QAE@ABV_Locinfo@1@I@Z", "public: __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(class std::_Locinfo const &,unsigned int)"},
899 {"??0?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@QAE@I@Z", "public: __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(unsigned int)"},
900 {"??0streambuf@@QAE@ABV0@@Z", "public: __thiscall streambuf::streambuf(class streambuf const &)"},
901 {"??0strstreambuf@@QAE@ABV0@@Z", "public: __thiscall strstreambuf::strstreambuf(class strstreambuf const &)"},
902 {"??0strstreambuf@@QAE@H@Z", "public: __thiscall strstreambuf::strstreambuf(int)"},
903 {"??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z", "public: __thiscall strstreambuf::strstreambuf(void * (__cdecl*)(long),void (__cdecl*)(void *))"},
904 {"??0strstreambuf@@QAE@PADH0@Z", "public: __thiscall strstreambuf::strstreambuf(char *,int,char *)"},
905 {"??0strstreambuf@@QAE@PAEH0@Z", "public: __thiscall strstreambuf::strstreambuf(unsigned char *,int,unsigned char *)"},
906 {"??0strstreambuf@@QAE@XZ", "public: __thiscall strstreambuf::strstreambuf(void)"},
907 {"??1__non_rtti_object@std@@UAE@XZ", "public: virtual __thiscall std::__non_rtti_object::~__non_rtti_object(void)"},
908 {"??1__non_rtti_object@@UAE@XZ", "public: virtual __thiscall __non_rtti_object::~__non_rtti_object(void)"},
909 {"??1?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@UAE@XZ", "public: virtual __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::~num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(void)"},
910 {"??1?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@UAE@XZ", "public: virtual __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::~num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(void)"},
911 {"??4istream_withassign@@QAEAAV0@ABV0@@Z", "public: class istream_withassign & __thiscall istream_withassign::operator=(class istream_withassign const &)"},
912 {"??4istream_withassign@@QAEAAVistream@@ABV1@@Z", "public: class istream & __thiscall istream_withassign::operator=(class istream const &)"},
913 {"??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z", "public: class istream & __thiscall istream_withassign::operator=(class streambuf *)"},
914 {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,signed char &)"},
915 {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,char &)"},
916 {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,unsigned char &)"},
917 {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(class std::ios_base & (__cdecl*)(class std::ios_base &))"},
918 {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(class std::basic_streambuf<unsigned short,struct std::char_traits<unsigned short> > *)"},
919 {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(void const *)"},
920 {"??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@", "const std::basic_fstream<char,struct std::char_traits<char> >::`vbtable'{for `std::basic_ostream<char,struct std::char_traits<char> >'}"},
921 {"??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@", "const std::basic_fstream<unsigned short,struct std::char_traits<unsigned short> >::`vbtable'{for `std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >'}"},
922 {"??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@", "const std::basic_fstream<unsigned short,struct std::char_traits<unsigned short> >::`vbtable'{for `std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >'}"},
923 {"??9std@@YA_NPBDABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z", "bool __cdecl std::operator!=(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
924 {"??9std@@YA_NPBGABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z", "bool __cdecl std::operator!=(unsigned short const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
925 {"??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAADI@Z", "public: char & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)"},
926 {"??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDI@Z", "public: char const & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)const "},
927 {"??A?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEAAGI@Z", "public: unsigned short & __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::operator[](unsigned int)"},
928 {"??A?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEABGI@Z", "public: unsigned short const & __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::operator[](unsigned int)const "},
929 {"?abs@std@@YAMABV?$complex@M@1@@Z", "float __cdecl std::abs(class std::complex<float> const &)"},
930 {"?abs@std@@YANABV?$complex@N@1@@Z", "double __cdecl std::abs(class std::complex<double> const &)"},
931 {"?abs@std@@YAOABV?$complex@O@1@@Z", "long double __cdecl std::abs(class std::complex<long double> const &)"},
932 {"?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A", "class std::basic_istream<char,struct std::char_traits<char> > std::cin"},
933 {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAG@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned short &)const "},
934 {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAI@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned int &)const "},
935 {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAJ@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,long &)const "},
936 {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAK@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned long &)const "},
937 {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAM@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,float &)const "},
938 {"?_query_new_handler@@YAP6AHI@ZXZ", "int (__cdecl*__cdecl _query_new_handler(void))(unsigned int)"},
939 {"?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z", "public: void __thiscall std::ios_base::register_callback(void (__cdecl*)(enum std::ios_base::event,class std::ios_base &,int),int)"},
940 {"?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z", "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::seekg(long,enum std::ios_base::seekdir)"},
941 {"?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z", "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::seekg(class std::fpos<int>)"},
942 {"?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z", "public: class std::basic_istream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >::seekg(long,enum std::ios_base::seekdir)"},
943 {"?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z", "public: class std::basic_istream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >::seekg(class std::fpos<int>)"},
944 {"?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z", "protected: virtual class std::fpos<int> __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::seekoff(long,enum std::ios_base::seekdir,int)"},
945 {"?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z", "protected: virtual class std::fpos<int> __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::seekoff(long,enum std::ios_base::seekdir,int)"},
946 {"?set_new_handler@@YAP6AXXZP6AXXZ@Z", "void (__cdecl*__cdecl set_new_handler(void (__cdecl*)(void)))(void)"},
947 {"?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_istringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
948 {"?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_istringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
949 {"?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_istringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
950 {"?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_istringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
951 {"?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
952 {"?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
953 {"?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_ostringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
954 {"?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_ostringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
955 {"?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
956 {"?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
957 {"?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_stringbuf<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
958 {"?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_stringbuf<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
959 {"?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
960 {"?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
961 {"?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
962 {"?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
963 {"?_Sync@ios_base@std@@0_NA", "private: static bool std::ios_base::_Sync"},
964 {"??_U@YAPAXI@Z", "void * __cdecl operator new[](unsigned int)"},
965 {"??_V@YAXPAX@Z", "void __cdecl operator delete[](void *)"},
966 {"??X?$_Complex_base@M@std@@QAEAAV01@ABM@Z", "public: class std::_Complex_base<float> & __thiscall std::_Complex_base<float>::operator*=(float const &)"},
967 {"??Xstd@@YAAAV?$complex@M@0@AAV10@ABV10@@Z", "class std::complex<float> & __cdecl std::operator*=(class std::complex<float> &,class std::complex<float> const &)"},
968 {"?aaa@@YAHAAUbbb@@@Z", "int __cdecl aaa(struct bbb &)"},
969 {"?aaa@@YAHBAUbbb@@@Z", "int __cdecl aaa(struct bbb & volatile)"},
970 {"?aaa@@YAHPAUbbb@@@Z", "int __cdecl aaa(struct bbb *)"},
971 {"?aaa@@YAHQAUbbb@@@Z", "int __cdecl aaa(struct bbb * const)"},
972 {"?aaa@@YAHRAUbbb@@@Z", "int __cdecl aaa(struct bbb * volatile)"},
973 {"?aaa@@YAHSAUbbb@@@Z", "int __cdecl aaa(struct bbb * const volatile)"},
974 {"??0aa.a@@QAE@XZ", "??0aa.a@@QAE@XZ"},
975 {"??0aa$_3a@@QAE@XZ", "public: __thiscall aa$_3a::aa$_3a(void)"},
976 {"??2?$aaa@AAUbbb@@AAUccc@@AAU2@@ddd@1eee@2@QAEHXZ", "public: int __thiscall eee::eee::ddd::ddd::aaa<struct bbb &,struct ccc &,struct ccc &>::operator new(void)"},
977 {"?pSW@@3P6GHKPAX0PAU_tagSTACKFRAME@@0P6GH0K0KPAK@ZP6GPAX0K@ZP6GK0K@ZP6GK00PAU_tagADDRESS@@@Z@ZA", "int (__stdcall* pSW)(unsigned long,void *,void *,struct _tagSTACKFRAME *,void *,int (__stdcall*)(void *,unsigned long,void *,unsigned long,unsigned long *),void * (__stdcall*)(void *,unsigned long),unsigned long (__stdcall*)(void *,unsigned long),unsigned long (__stdcall*)(void *,void *,struct _tagADDRESS *))"},
978 {"?$_aaa@Vbbb@@", "_aaa<class bbb>"},
979 {"??$_aaa@Vbbb@@", "??$_aaa@Vbbb@@"},
980 {"?$aaa@Vbbb@ccc@@Vddd@2@", "aaa<class ccc::bbb,class ccc::ddd>"},
982 int i, num_test = (sizeof(test)/sizeof(test[0]));
985 for (i = 0; i < num_test; i++)
987 name = p__unDName(0, test[i].in, 0, pmalloc, pfree, 0);
988 ok(name != NULL && !strcmp_space(test[i].out, name),
989 "Got name \"%s\" for %d\n", name, i);
1001 test___non_rtti_object();
1004 test_demangle_datatype();
1008 FreeLibrary(hMsvcrt);
1010 #endif /* __i386__ */