#include <stdexcept>
#include <clocale>
#include <locale>
+#include <cxxabi.h>
namespace __gnu_cxx_test
{
set_memory_limits(float) { }
#endif
+
+ void
+ verify_demangle(const char* mangled, const char* wanted)
+ {
+ int status = 0;
+ const char* s = abi::__cxa_demangle(mangled, 0, 0, &status);
+ if (!s)
+ {
+ switch (status)
+ {
+ case 0:
+ s = "error code = 0: success";
+ break;
+ case -1:
+ s = "error code = -1: memory allocation failure";
+ break;
+ case -2:
+ s = "error code = -2: invalid mangled name";
+ break;
+ case -3:
+ s = "error code = -3: invalid arguments";
+ break;
+ default:
+ s = "error code unknown - who knows what happened";
+ }
+ }
+
+ std::string w(wanted);
+ if (w != s)
+ throw std::runtime_error(s);
+ }
+
+
// Useful exceptions.
class locale_data : public std::runtime_error
{
bool test = true;
// Set the global locale.
- locale loc_name(name);
- locale orig = locale::global(loc_name);
-
+ try
+ {
+ locale loc_name(name);
+ locale orig = locale::global(loc_name);
+ }
+ catch (std::runtime_error& ex)
+ {
+ if (std::strstr (ex.what(), "unhandled name in generic implementation"))
+ return;
+ else if (std::strstr (ex.what(), "unknown name"))
+ return;
+ else
+ throw;
+ }
+
const char* res = setlocale(LC_ALL, name);
if (res != NULL)
{
#ifdef _GLIBCPP_HAVE_SETENV
// Set the global locale.
- locale loc_name(name);
- locale orig = locale::global(loc_name);
-
+ try
+ {
+ locale loc_name(name);
+ locale orig = locale::global(loc_name);
+ }
+ catch (std::runtime_error& ex)
+ {
+ if (std::strstr (ex.what(), "unhandled name in generic implementation"))
+ return;
+ else if (std::strstr (ex.what(), "unknown name"))
+ return;
+ else
+ throw;
+ }
// Set environment variable env to value in name.
const char* oldENV = getenv(env);
if (!setenv(env, name, 1))
}
else
throw environment_variable(string(env) + string(" to ") + string(name));
-#else
- throw not_found("setenv");
#endif
}
+ void
+ run_test_wrapped_generic_locale_exception_catcher(const test_func f)
+ {
+ try
+ {
+ f();
+ }
+ catch (std::runtime_error& ex)
+ {
+ if (std::strstr (ex.what(), "unhandled name in generic implementation"))
+ return;
+ else if (std::strstr (ex.what(), "unknown name"))
+ return;
+ else
+ throw;
+ }
+ }
+
counter::size_type counter::count = 0;
unsigned int copy_constructor::count_ = 0;
unsigned int copy_constructor::throw_on_ = 0;