30#if defined (__IBMCPP__) && !defined (_RWSTD_NO_IMPLICIT_INCLUSION)
34# define _RWSTD_NO_IMPLICIT_INCLUSION
55struct B {
virtual ~B () { } };
69 std::bad_typeid *bt = 0;
92 const char* (
std::type_info::*p_name)()
const = &std::type_info::name;
100#if defined (__IBMCPP__) && !defined (__RTTI_TYPE_INFO__)
103 "not testing type_info; rtti is disabled");
119 const char *D1_name = ti_D1.name () ? ti_D1.name () :
"(D1 null)";
120 const char *D2_name = ti_D2.name () ? ti_D2.name () :
"(D2 null)";
121 const char *d1_name = ti_d1.name () ? ti_d1.name () :
"(d1 null)";
122 const char *d2_name = ti_d2.name () ? ti_d2.name () :
"(d2 null)";
126 "std::type_info::operator==(): \"%s\" != \"%s\"",
129 "std::type_info::operator==(): \"%s\" != \"%s\"",
131 rw_assert (!(ti_D1 == ti_D2), 0, __LINE__,
132 "std::type_info::operator==(): \"%s\" == \"%s\"",
135 "std::type_info::operator==(): \"%s\" != \"%s\"",
138 "std::type_info::operator==(): \"%s\" != \"%s\"",
140 rw_assert (!(ti_d1 == ti_d2), 0, __LINE__,
141 "std::type_info::operator==(): \"%s\" == \"%s\"",
146 "std::type_info::operator!=(): \"%s\" == \"%s\"",
149 "std::type_info::operator!=(): \"%s\" == \"%s\"",
151 rw_assert (!(ti_D1 != ti_D1), 0, __LINE__,
152 "std::type_info::operator!=(): \"%s\" != \"%s\"",
155 "std::type_info::operator!=(): \"%s\" == \"%s\"",
158 "std::type_info::operator!=(): \"%s\" == \"%s\"",
160 rw_assert (!(ti_d1 != ti_d1), 0, __LINE__,
161 "std::type_info::operator!=(): \"%s\" != \"%s\"",
165 rw_assert (!ti_D1.before (ti_D1) && !ti_D2.before (ti_D2),
166 0, __LINE__,
"std::type_info::before ()");
167 rw_assert (ti_D1.before (ti_D2) || ti_D2.before (ti_D1),
168 0, __LINE__,
"std::type_info::before ()");
169 rw_assert (ti_d1.before (ti_d2) || ti_d2.before (ti_d1),
170 0, __LINE__,
"std::type_info::before ()");
171 rw_assert (!ti_d1.before (ti_d1) && !ti_d2.before (ti_d2),
172 0, __LINE__,
"std::type_info::before ()");
176 "std::type_info::name (): \"%s\" != \"%s\"",
179 "std::type_info::name (): \"%s\" == \"%s\"",
182 "std::type_info::name (): \"%s\" != \"%s\"",
185 "std::type_info::name (): \"%s\" == \"%s\"",
223#ifndef _RWSTD_NO_EXCEPTIONS
224# ifndef _RWSTD_NO_DYNAMIC_CAST
226 const char *
caught =
"no exception";
245 const char*
const bc_what = bc.what ();
246 const char* bc2_what = bc2.what ();
247 const char*
const bc3_what = bc3.what ();
250 rw_assert (
false, 0, __LINE__,
"bad_cast().what() != 0");
254 "bad_cast::what() != 0 failed "
255 "for a copy of a caught exception object");
257 if (bc2_what && bc3_what)
260 "bad_cast::bad_cast (const bad_cast&): "
261 "\"%s\" != \"%s\"", bc_what, bc3_what);
266 bc2_what = bc2.what ();
270 "bad_cast::what() != 0 failed "
271 "for a caught exception object");
275 "bad_cast::what() != 0 failed "
276 "for an assigned exception object");
278 if (bc_what && bc2_what)
281 "bad_cast::operator=(const bad_cast&): "
282 "\"%s\" != \"%s\"", bc_what, bc2_what);
288 "bad_cast::what() const: \"%s\" != \"%s\"",
289 bc.what (), bc.what ());
292 caught =
"std::exception";
295 caught =
"unknown exception";
298#if !defined (_RWSTD_NO_STD_BAD_CAST) \
299 || !defined (_RWSTD_NO_RUNTIME_IN_STD)
301 const char expect[] =
"std::bad_cast";
305 const char expect[] =
"std::bad_cast (alias for ::bad_cast)";
311 "dynamic_cast<>() threw %s, expected %s; this suggests "
312 "that bad_cast might be defined in the wrong namespace",
326 const std::bad_typeid *pbt = 0;
333 std::bad_typeid bt2 (bt);
336 std::bad_typeid& (std::bad_typeid::*p_op_assign)(
const std::bad_typeid&)
340 const char* (std::bad_typeid::*p_what)() const
_PTR_THROWS (()) =
354#ifndef _RWSTD_NO_EXCEPTIONS
356 const char *
caught =
"no exception";
360#if !defined (__GNUG__) || __GNUG__ > 2
373 caught =
"SIGSEGV (program dumps core)";
378 catch (
const std::bad_typeid &bt) {
379 caught =
"std::bad_typeid";
385 std::bad_typeid bt3 (bt);
391 "std::bad_typeid::bad_typeid (const bad_typeid&): "
392 "\"%s\" != \"%s\"", bt.what (), bt3.what ());
401 "std::bad_typeid::operator=(const bad_typeid&): "
402 "\"%s\" != \"%s\"", bt.what (), bt2.what ());
407 "std::bad_typeid::what() const: "
408 "\"%s\" != \"%s\"", bt.what (), bt.what ());
411 caught =
"std::exception";
414 caught =
"unknown exception";
417#if !defined (_RWSTD_NO_STD_BAD_TYPEID) \
418 || !defined (_RWSTD_NO_RUNTIME_IN_STD)
420 const char expect[] =
"std::bad_typeid";
424 const char expect[] =
"std::bad_typeid (alias for ::bad_typeid)";
431 "typeid ((T*)0) threw %s, expected %s; this suggests "
432 "that bad_typeid might be defined in the wrong namespace",
441int main (
int argc,
char* argv [])
443 return rw_test (argc, argv, __FILE__,
#define _PTR_THROWS(spec)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define _RWSTD_UNUSED(arg)
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_strncmp(const char *, const char *, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX, int=CMP_NULTERM)