From 51502ebc130ebef2a7febc060784c42ac120b754 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 15 Oct 2002 01:05:30 +0000 Subject: [PATCH] static_members.cc (test02): Less provincial. 2002-10-14 Benjamin Kosnik * testsuite/22_locale/static_members.cc (test02): Less provincial. From-SVN: r58144 --- libstdc++-v3/ChangeLog | 4 ++ libstdc++-v3/testsuite/22_locale/static_members.cc | 51 ++++++++++++---------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6c2f3f2..b4bf770 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2002-10-14 Benjamin Kosnik + * testsuite/22_locale/static_members.cc (test02): Less provincial. + +2002-10-14 Benjamin Kosnik + * testsuite/22_locale/static_members.cc (test02): Disable for systems without named locale support. * testsuite/22_locale/ctor_copy_dtor.cc (test04): Don't assume diff --git a/libstdc++-v3/testsuite/22_locale/static_members.cc b/libstdc++-v3/testsuite/22_locale/static_members.cc index 936e8b8..9811dd9 100644 --- a/libstdc++-v3/testsuite/22_locale/static_members.cc +++ b/libstdc++-v3/testsuite/22_locale/static_members.cc @@ -67,34 +67,39 @@ void test02() using namespace std; bool test = true; - // If the underlying locale doesn't support these names, setlocale - // won't be reset. Therefore, disable unless we know named locales work. -#if _GLIBCPP_C_LOCALE_GNU - const string ph("en_PH"); const string mx("es_MX"); + const char* orig = setlocale(LC_ALL, NULL); + const char* testph = setlocale(LC_ALL, ph.c_str()); + const char* testmx = setlocale(LC_ALL, mx.c_str()); + setlocale(LC_ALL, orig); - const locale loc_ph(ph.c_str()); - const locale loc_mx(mx.c_str()); - - // Use setlocale between two calls to locale("") - const locale loc_env_1(""); - setlocale(LC_ALL, ph.c_str()); - const locale loc_env_2(""); - VERIFY( loc_env_1 == loc_env_2 ); - - // Change global locale. - locale global_orig = locale::global(loc_mx); - const char* lc_all_mx = setlocale(LC_ALL, NULL); - if (lc_all_mx) + // If the underlying locale doesn't support these names, setlocale + // won't be reset. Therefore, disable unless we know these specific + // named locales work. + if (testph && testmx) { - cout << "lc_all_mx is " << lc_all_mx << endl; - VERIFY( mx == lc_all_mx ); + const locale loc_ph(ph.c_str()); + const locale loc_mx(mx.c_str()); + + // Use setlocale between two calls to locale("") + const locale loc_env_1(""); + setlocale(LC_ALL, ph.c_str()); + const locale loc_env_2(""); + VERIFY( loc_env_1 == loc_env_2 ); + + // Change global locale. + locale global_orig = locale::global(loc_mx); + const char* lc_all_mx = setlocale(LC_ALL, NULL); + if (lc_all_mx) + { + cout << "lc_all_mx is " << lc_all_mx << endl; + VERIFY( mx == lc_all_mx ); + } + + // Restore global settings. + locale::global(global_orig); } - - // Restore global settings. - locale::global(global_orig); -#endif } // Static counter for use in checking ctors/dtors. -- 2.7.4