From bf5fe4734cb6840be45d8812bb529f9557bb870a Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 22 Oct 2003 18:58:35 +0000 Subject: [PATCH] locale_facets.h: Correct byname facets for "C" locale. 2003-10-22 Benjamin Kosnik * include/bits/locale_facets.h: Correct byname facets for "C" locale. * config/locale/generic/ctype_members.cc: Same. * config/locale/generic/messages_members.h: Same. * config/locale/gnu/ctype_members.cc: Same. * config/locale/gnu/messages_members.h: Same. * include/bits/codecvt.h: Same. * src/ctype.cc: Same. * testsuite/22_locale/codecvt_byname/1.cc: New. * testsuite/22_locale/collate/1.cc: Edit. * testsuite/22_locale/collate_byname/1.cc: Derivation tests, move to... * testsuite/22_locale/collate_byname/named_equivalence.cc: ...here. * testsuite/22_locale/ctype/1.cc: Derivation tests. * testsuite/22_locale/ctype/11844.cc: Move... * testsuite/22_locale/ctype_base/11844.cc: ...here. * testsuite/22_locale/ctype_base/1.cc: Move mask bits here. * testsuite/22_locale/ctype_byname/1.cc: Name. * testsuite/22_locale/messages_byname/1.cc: New. * testsuite/22_locale/messages_byname/named_equivalence.cc: New. * testsuite/22_locale/moneypunct_byname/1.cc: Derivation test. * testsuite/22_locale/moneypunct_byname/named_equivalence.cc: New. * testsuite/22_locale/numpunct/1.cc: Edit. * testsuite/22_locale/numpunct_byname/2.cc: Move... * testsuite/22_locale/numpunct/members/char/3.cc: ...here. * testsuite/22_locale/numpunct_byname/1.cc: Derivation tests. * testsuite/22_locale/numpunct_byname/named_equivalence.cc: New. From-SVN: r72814 --- libstdc++-v3/ChangeLog | 29 ++++ .../config/locale/generic/ctype_members.cc | 7 +- .../config/locale/generic/messages_members.h | 7 +- .../config/locale/gnu/ctype_members.cc | 15 +- .../config/locale/gnu/messages_members.h | 7 +- libstdc++-v3/include/bits/codecvt.h | 7 +- libstdc++-v3/include/bits/locale_facets.h | 38 +++-- libstdc++-v3/src/ctype.cc | 9 +- .../testsuite/22_locale/codecvt_byname/1.cc | 44 ++++++ libstdc++-v3/testsuite/22_locale/collate/1.cc | 2 +- .../testsuite/22_locale/collate_byname/1.cc | 116 ++------------ .../collate_byname/named_equivalence.cc | 135 ++++++++++++++++ libstdc++-v3/testsuite/22_locale/ctype/1.cc | 148 ++---------------- .../testsuite/22_locale/ctype_base/1.cc | 56 +++++++ .../22_locale/{ctype => ctype_base}/11844.cc | 0 .../testsuite/22_locale/ctype_byname/1.cc | 42 +++++ .../testsuite/22_locale/messages_byname/1.cc | 57 ++----- .../messages_byname/named_equivalence.cc | 78 +++++++++ .../22_locale/moneypunct_byname/1.cc | 78 ++------- .../moneypunct_byname/named_equivalence.cc | 98 ++++++++++++ .../testsuite/22_locale/numpunct/1.cc | 4 + .../2.cc => numpunct/members/char/3.cc} | 0 .../testsuite/22_locale/numpunct_byname/1.cc | 57 ++----- .../numpunct_byname/named_equivalence.cc | 76 +++++++++ 24 files changed, 682 insertions(+), 428 deletions(-) create mode 100644 libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc create mode 100644 libstdc++-v3/testsuite/22_locale/ctype_base/1.cc rename libstdc++-v3/testsuite/22_locale/{ctype => ctype_base}/11844.cc (100%) create mode 100644 libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc create mode 100644 libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc rename libstdc++-v3/testsuite/22_locale/{numpunct_byname/2.cc => numpunct/members/char/3.cc} (100%) create mode 100644 libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 76d345e19a4..9100bb19a60 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2003-10-22 Benjamin Kosnik + + * include/bits/locale_facets.h: Correct byname facets for "C" + locale. + * config/locale/generic/ctype_members.cc: Same. + * config/locale/generic/messages_members.h: Same. + * config/locale/gnu/ctype_members.cc: Same. + * config/locale/gnu/messages_members.h: Same. + * include/bits/codecvt.h: Same. + * src/ctype.cc: Same. + * testsuite/22_locale/codecvt_byname/1.cc: New. + * testsuite/22_locale/collate/1.cc: Edit. + * testsuite/22_locale/collate_byname/1.cc: Derivation tests, move to... + * testsuite/22_locale/collate_byname/named_equivalence.cc: ...here. + * testsuite/22_locale/ctype/1.cc: Derivation tests. + * testsuite/22_locale/ctype/11844.cc: Move... + * testsuite/22_locale/ctype_base/11844.cc: ...here. + * testsuite/22_locale/ctype_base/1.cc: Move mask bits here. + * testsuite/22_locale/ctype_byname/1.cc: Name. + * testsuite/22_locale/messages_byname/1.cc: New. + * testsuite/22_locale/messages_byname/named_equivalence.cc: New. + * testsuite/22_locale/moneypunct_byname/1.cc: Derivation test. + * testsuite/22_locale/moneypunct_byname/named_equivalence.cc: New. + * testsuite/22_locale/numpunct/1.cc: Edit. + * testsuite/22_locale/numpunct_byname/2.cc: Move... + * testsuite/22_locale/numpunct/members/char/3.cc: ...here. + * testsuite/22_locale/numpunct_byname/1.cc: Derivation tests. + * testsuite/22_locale/numpunct_byname/named_equivalence.cc: New. + 2003-10-22 Paolo Carlini PR libstdc++/8610 diff --git a/libstdc++-v3/config/locale/generic/ctype_members.cc b/libstdc++-v3/config/locale/generic/ctype_members.cc index 9b3bddb6bef..71175f14559 100644 --- a/libstdc++-v3/config/locale/generic/ctype_members.cc +++ b/libstdc++-v3/config/locale/generic/ctype_members.cc @@ -43,8 +43,11 @@ namespace std ctype_byname::ctype_byname(const char* __s, size_t __refs) : ctype(0, false, __refs) { - _S_destroy_c_locale(_M_c_locale_ctype); - _S_create_c_locale(_M_c_locale_ctype, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(_M_c_locale_ctype); + _S_create_c_locale(_M_c_locale_ctype, __s); + } } #ifdef _GLIBCXX_USE_WCHAR_T diff --git a/libstdc++-v3/config/locale/generic/messages_members.h b/libstdc++-v3/config/locale/generic/messages_members.h index 3e9122e880f..cecc6446c71 100644 --- a/libstdc++-v3/config/locale/generic/messages_members.h +++ b/libstdc++-v3/config/locale/generic/messages_members.h @@ -76,6 +76,9 @@ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { - _S_destroy_c_locale(this->_M_c_locale_messages); - _S_create_c_locale(this->_M_c_locale_messages, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(this->_M_c_locale_messages); + _S_create_c_locale(this->_M_c_locale_messages, __s); + } } diff --git a/libstdc++-v3/config/locale/gnu/ctype_members.cc b/libstdc++-v3/config/locale/gnu/ctype_members.cc index 79a14f57a48..a5394b53828 100644 --- a/libstdc++-v3/config/locale/gnu/ctype_members.cc +++ b/libstdc++-v3/config/locale/gnu/ctype_members.cc @@ -43,12 +43,15 @@ namespace std template<> ctype_byname::ctype_byname(const char* __s, size_t __refs) : ctype(0, false, __refs) - { - _S_destroy_c_locale(_M_c_locale_ctype); - _S_create_c_locale(_M_c_locale_ctype, __s); - _M_toupper = _M_c_locale_ctype->__ctype_toupper; - _M_tolower = _M_c_locale_ctype->__ctype_tolower; - _M_table = _M_c_locale_ctype->__ctype_b; + { + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(_M_c_locale_ctype); + _S_create_c_locale(_M_c_locale_ctype, __s); + _M_toupper = _M_c_locale_ctype->__ctype_toupper; + _M_tolower = _M_c_locale_ctype->__ctype_tolower; + _M_table = _M_c_locale_ctype->__ctype_b; + } } #ifdef _GLIBCXX_USE_WCHAR_T diff --git a/libstdc++-v3/config/locale/gnu/messages_members.h b/libstdc++-v3/config/locale/gnu/messages_members.h index 9bb8e50c438..ed95dfb4c43 100644 --- a/libstdc++-v3/config/locale/gnu/messages_members.h +++ b/libstdc++-v3/config/locale/gnu/messages_members.h @@ -106,6 +106,9 @@ std::strcpy(__tmp, __s); this->_M_name_messages = __tmp; #endif - _S_destroy_c_locale(this->_M_c_locale_messages); - _S_create_c_locale(this->_M_c_locale_messages, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(this->_M_c_locale_messages); + _S_create_c_locale(this->_M_c_locale_messages, __s); + } } diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index 1d123a93c64..80f9cba0b35 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -341,8 +341,11 @@ codecvt_byname(const char* __s, size_t __refs = 0) : codecvt<_InternT, _ExternT, _StateT>(__refs) { - _S_destroy_c_locale(this->_M_c_locale_codecvt); - _S_create_c_locale(this->_M_c_locale_codecvt, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(this->_M_c_locale_codecvt); + _S_create_c_locale(this->_M_c_locale_codecvt, __s); + } } protected: diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 13383d8d36f..abb9d143c61 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -795,9 +795,6 @@ namespace std template class numpunct_byname : public numpunct<_CharT> { - // Data Member. - __c_locale _M_c_locale_numpunct; - public: typedef _CharT char_type; typedef basic_string<_CharT> string_type; @@ -806,14 +803,18 @@ namespace std numpunct_byname(const char* __s, size_t __refs = 0) : numpunct<_CharT>(__refs) { - this->_S_create_c_locale(_M_c_locale_numpunct, __s); - this->_M_initialize_numpunct(_M_c_locale_numpunct); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_numpunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } } protected: virtual - ~numpunct_byname() - { this->_S_destroy_c_locale(_M_c_locale_numpunct); } + ~numpunct_byname() { } }; template @@ -1151,8 +1152,11 @@ namespace std collate_byname(const char* __s, size_t __refs = 0) : collate<_CharT>(__refs) { - this->_S_destroy_c_locale(this->_M_c_locale_collate); - this->_S_create_c_locale(this->_M_c_locale_collate, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_collate); + this->_S_create_c_locale(this->_M_c_locale_collate, __s); + } } protected: @@ -1589,7 +1593,7 @@ namespace std typedef _OutIter iter_type; explicit - time_put_byname(const char* /*__s*/, size_t __refs = 0) + time_put_byname(const char*, size_t __refs = 0) : time_put<_CharT, _OutIter>(__refs) { }; @@ -1805,8 +1809,6 @@ namespace std template class moneypunct_byname : public moneypunct<_CharT, _Intl> { - __c_locale _M_c_locale_moneypunct; - public: typedef _CharT char_type; typedef basic_string<_CharT> string_type; @@ -1817,14 +1819,18 @@ namespace std moneypunct_byname(const char* __s, size_t __refs = 0) : moneypunct<_CharT, _Intl>(__refs) { - this->_S_create_c_locale(_M_c_locale_moneypunct, __s); - this->_M_initialize_moneypunct(_M_c_locale_moneypunct); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_moneypunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } } protected: virtual - ~moneypunct_byname() - { this->_S_destroy_c_locale(_M_c_locale_moneypunct); } + ~moneypunct_byname() { } }; template diff --git a/libstdc++-v3/src/ctype.cc b/libstdc++-v3/src/ctype.cc index e97d39dfe1c..7fb5c2da81f 100644 --- a/libstdc++-v3/src/ctype.cc +++ b/libstdc++-v3/src/ctype.cc @@ -99,9 +99,12 @@ namespace std template<> ctype_byname::ctype_byname(const char* __s, size_t __refs) : ctype(__refs) - { - _S_destroy_c_locale(_M_c_locale_ctype); - _S_create_c_locale(_M_c_locale_ctype, __s); + { + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + _S_destroy_c_locale(_M_c_locale_ctype); + _S_create_c_locale(_M_c_locale_ctype, __s); + } } #endif } // namespace std diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc new file mode 100644 index 00000000000..a17c841466b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc @@ -0,0 +1,44 @@ +// { dg-do compile } +// 2001-08-27 Benjamin Kosnik + +// Copyright (C) 2001, 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.1.5 Template class codecvt + +#include + +void test01() +{ + // Check for required base class. + typedef std::codecvt_byname test_type; + typedef std::codecvt base_type; + const test_type& obj = std::use_facet(std::locale::classic()); + const base_type* base __attribute__((unused)) = &obj; + + // Check for required typedefs + typedef test_type::intern_type intern_type; + typedef test_type::extern_type extern_type; + typedef test_type::state_type state_type; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/collate/1.cc b/libstdc++-v3/testsuite/22_locale/collate/1.cc index 2f6415fcd67..41f615e3dde 100644 --- a/libstdc++-v3/testsuite/22_locale/collate/1.cc +++ b/libstdc++-v3/testsuite/22_locale/collate/1.cc @@ -26,7 +26,7 @@ void test01() { // Check for required base class. - typedef std::messages test_type; + typedef std::collate test_type; typedef std::locale::facet base_type; const test_type& obj = std::use_facet(std::locale()); const base_type* base __attribute__((unused)) = &obj; diff --git a/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc index be4524f9ca6..6f1f6432ae6 100644 --- a/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc +++ b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc @@ -1,6 +1,7 @@ -// 2001-08-15 Benjamin Kosnik +// { dg-do compile } +// 2001-08-15 Benjamin Kosnik -// Copyright (C) 2001, 2002 Free Software Foundation +// Copyright (C) 2001 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -18,114 +19,21 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 22.2.4.2 Template class collate_byname +// 22.2.4 The collate category #include -#include void test01() { - using namespace std; - typedef std::collate::string_type string_type; + // Check for required base class. + typedef std::collate_byname test_type; + typedef std::collate base_type; + const test_type& obj = std::use_facet(std::locale::classic()); + const base_type* base __attribute__((unused)) = &obj; - bool test __attribute__((unused)) = true; - string str; - locale loc_c = locale::classic(); - - locale loc_de = __gnu_test::try_named_locale("de_DE"); - str = loc_de.name(); - - locale loc_byname(locale::classic(), new collate_byname("de_DE")); - str = loc_byname.name(); - - VERIFY( loc_de != loc_byname ); - - // cache the collate facets - const collate& coll_de = use_facet >(loc_de); - - // Check German "de_DE" locale. - int i1; - int i2; - long l1; - long l2; - const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein" - const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast" - - int size3 = strlen(strlit3) - 1; - i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7); - VERIFY ( i1 == 1 ); - i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3); - VERIFY ( i1 == -1 ); - i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7); - VERIFY ( i1 == 0 ); - - i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14); - VERIFY ( i1 == -1 ); - - int size4 = strlen(strlit4) - 1; - i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13); - VERIFY ( i2 == 1 ); - i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4); - VERIFY ( i2 == -1 ); - i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4); - VERIFY ( i2 == 0 ); - - l1 = coll_de.hash(strlit3, strlit3 + size3); - l2 = coll_de.hash(strlit3, strlit3 + size3 - 1); - VERIFY ( l1 != l2 ); - l1 = coll_de.hash(strlit3, strlit3 + size3); - l2 = coll_de.hash(strlit4, strlit4 + size4); - VERIFY ( l1 != l2 ); - - string str3 = coll_de.transform(strlit3, strlit3 + size3); - string str4 = coll_de.transform(strlit4, strlit4 + size4); - i1 = str3.compare(str4); - i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4); - VERIFY ( i2 == -1 ); - VERIFY ( i1 * i2 > 0 ); - - - // Check byname locale - int i3; - int i4; - long l3; - long l4; - size4 = strlen(strlit3) - 1; - i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7); - VERIFY ( i3 == 1 ); - i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4); - VERIFY ( i3 == -1 ); - i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7); - VERIFY ( i3 == 0 ); - - i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14); - VERIFY ( i3 == -1 ); - - size4 = strlen(strlit4) - 1; - i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13); - VERIFY ( i4 == 1 ); - i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4); - VERIFY ( i4 == -1 ); - i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4); - VERIFY ( i4 == 0 ); - - l3 = coll_de.hash(strlit3, strlit3 + size4); - l4 = coll_de.hash(strlit3, strlit3 + size4 - 1); - VERIFY ( l3 != l4 ); - l3 = coll_de.hash(strlit3, strlit3 + size4); - l4 = coll_de.hash(strlit4, strlit4 + size4); - VERIFY ( l3 != l4 ); - - string str5 = coll_de.transform(strlit3, strlit3 + size3); - string str6 = coll_de.transform(strlit4, strlit4 + size4); - i3 = str5.compare(str6); - i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4); - VERIFY ( i4 == -1 ); - VERIFY ( i3 * i4 > 0 ); - - // Verify byname == de - VERIFY ( str5 == str3 ); - VERIFY ( str6 == str4 ); + // Check for required typedefs + typedef test_type::char_type char_type; + typedef test_type::string_type string_type; } int main() diff --git a/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc new file mode 100644 index 00000000000..be4524f9ca6 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc @@ -0,0 +1,135 @@ +// 2001-08-15 Benjamin Kosnik + +// Copyright (C) 2001, 2002 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.4.2 Template class collate_byname + +#include +#include + +void test01() +{ + using namespace std; + typedef std::collate::string_type string_type; + + bool test __attribute__((unused)) = true; + string str; + locale loc_c = locale::classic(); + + locale loc_de = __gnu_test::try_named_locale("de_DE"); + str = loc_de.name(); + + locale loc_byname(locale::classic(), new collate_byname("de_DE")); + str = loc_byname.name(); + + VERIFY( loc_de != loc_byname ); + + // cache the collate facets + const collate& coll_de = use_facet >(loc_de); + + // Check German "de_DE" locale. + int i1; + int i2; + long l1; + long l2; + const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein" + const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast" + + int size3 = strlen(strlit3) - 1; + i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7); + VERIFY ( i1 == 1 ); + i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3); + VERIFY ( i1 == -1 ); + i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7); + VERIFY ( i1 == 0 ); + + i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14); + VERIFY ( i1 == -1 ); + + int size4 = strlen(strlit4) - 1; + i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13); + VERIFY ( i2 == 1 ); + i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4); + VERIFY ( i2 == -1 ); + i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4); + VERIFY ( i2 == 0 ); + + l1 = coll_de.hash(strlit3, strlit3 + size3); + l2 = coll_de.hash(strlit3, strlit3 + size3 - 1); + VERIFY ( l1 != l2 ); + l1 = coll_de.hash(strlit3, strlit3 + size3); + l2 = coll_de.hash(strlit4, strlit4 + size4); + VERIFY ( l1 != l2 ); + + string str3 = coll_de.transform(strlit3, strlit3 + size3); + string str4 = coll_de.transform(strlit4, strlit4 + size4); + i1 = str3.compare(str4); + i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4); + VERIFY ( i2 == -1 ); + VERIFY ( i1 * i2 > 0 ); + + + // Check byname locale + int i3; + int i4; + long l3; + long l4; + size4 = strlen(strlit3) - 1; + i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7); + VERIFY ( i3 == 1 ); + i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4); + VERIFY ( i3 == -1 ); + i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7); + VERIFY ( i3 == 0 ); + + i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14); + VERIFY ( i3 == -1 ); + + size4 = strlen(strlit4) - 1; + i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13); + VERIFY ( i4 == 1 ); + i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4); + VERIFY ( i4 == -1 ); + i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4); + VERIFY ( i4 == 0 ); + + l3 = coll_de.hash(strlit3, strlit3 + size4); + l4 = coll_de.hash(strlit3, strlit3 + size4 - 1); + VERIFY ( l3 != l4 ); + l3 = coll_de.hash(strlit3, strlit3 + size4); + l4 = coll_de.hash(strlit4, strlit4 + size4); + VERIFY ( l3 != l4 ); + + string str5 = coll_de.transform(strlit3, strlit3 + size3); + string str6 = coll_de.transform(strlit4, strlit4 + size4); + i3 = str5.compare(str6); + i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4); + VERIFY ( i4 == -1 ); + VERIFY ( i3 * i4 > 0 ); + + // Verify byname == de + VERIFY ( str5 == str3 ); + VERIFY ( str6 == str4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/ctype/1.cc b/libstdc++-v3/testsuite/22_locale/ctype/1.cc index adda6fd548d..ed8122121da 100644 --- a/libstdc++-v3/testsuite/22_locale/ctype/1.cc +++ b/libstdc++-v3/testsuite/22_locale/ctype/1.cc @@ -1,7 +1,7 @@ // { dg-do compile } -// 1999-08-24 bkoz +// 2001-08-15 Benjamin Kosnik -// Copyright (C) 1999, 2000, 2003 Free Software Foundation +// Copyright (C) 2003 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -19,144 +19,26 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 22.2.1 The ctype category - -// 1: Test that the locale headers are picking up the correct declaration -// of the internal type `ctype_base::mask'. -int mask (); +// 22.2.1.1 - Template class ctype #include -// 2: Should be able to instantiate this for other types besides char, wchar_t -typedef std::ctype cctype; - -class gnu_ctype: public std::ctype -{ -private: - const cctype& _M_cctype; - -public: - explicit - gnu_ctype(size_t __refs = 0) - : std::ctype(__refs), - _M_cctype(std::use_facet(std::locale::classic())) - { } - - ~gnu_ctype(); - -protected: - virtual bool - do_is(mask __m, char_type __c) const - { return _M_cctype.is(__m, __c); } - - virtual const char_type* - do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const - { - const char* __c = _M_cctype.is(reinterpret_cast(__lo), - reinterpret_cast(__hi), __vec); - return reinterpret_cast(__c); - } - - virtual const char_type* - do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const - { - const char* __c = _M_cctype.scan_is(__m, - reinterpret_cast(__lo), - reinterpret_cast(__hi)); - return reinterpret_cast(__c); - } - - virtual const char_type* - do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const - { - const char* __c = _M_cctype.scan_is(__m, - reinterpret_cast(__lo), - reinterpret_cast(__hi)); - return reinterpret_cast(__c); - } - - virtual char_type - do_toupper(char_type __c) const - { return _M_cctype.toupper(__c); } - - virtual const char_type* - do_toupper(char_type* __lo, const char_type* __hi) const - { - const char* __c = _M_cctype.toupper(reinterpret_cast(__lo), - reinterpret_cast(__hi)); - return reinterpret_cast(__c); - } - - virtual char_type - do_tolower(char_type __c) const - { return _M_cctype.tolower(__c); } - - virtual const char_type* - do_tolower(char_type* __lo, const char_type* __hi) const - { - const char* __c = _M_cctype.toupper(reinterpret_cast(__lo), - reinterpret_cast(__hi)); - return reinterpret_cast(__c); - } - - virtual char_type - do_widen(char __c) const - { return _M_cctype.widen(__c); } - - virtual const char* - do_widen(const char* __lo, const char* __hi, char_type* __dest) const - { - const char* __c = _M_cctype.widen(reinterpret_cast(__lo), - reinterpret_cast(__hi), - reinterpret_cast(__dest)); - return __c; - } - - virtual char - do_narrow(char_type __c, char __dfault) const - { return _M_cctype.narrow(__c, __dfault); } - - virtual const char_type* - do_narrow(const char_type* __lo, const char_type* __hi, char __dfault, - char* __dest) const - { - const char* __c = _M_cctype.narrow(reinterpret_cast(__lo), - reinterpret_cast(__hi), - __dfault, - reinterpret_cast(__dest)); - return reinterpret_cast(__c); - } - -}; - -gnu_ctype::~gnu_ctype() { } - -gnu_ctype facet01; - -// 3: Sanity check ctype_base::mask bitmask requirements -void -test01() +void test01() { - using namespace std; + // Check for required base class. + typedef std::ctype test_type; + typedef std::locale::facet base_type1; + typedef std::ctype_base base_type2; + const test_type& obj = std::use_facet(std::locale::classic()); + const base_type1* base1 __attribute__((unused)) = &obj; + const base_type2* base2 __attribute__((unused)) = &obj; - ctype_base::mask m01; - ctype_base::mask m02; - ctype_base::mask res; - - m01 = ctype_base::space; - m02 = ctype_base::xdigit; - - res = m01 & m02; - res = m01 | m02; - res = m01 ^ m02; - res = ~m01; - m01 &= m02; - m01 |= m02; - m01 ^= m02; + // Check for required typedefs + typedef test_type::char_type char_type; } -int main() -{ +int main() +{ test01(); return 0; } diff --git a/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc b/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc new file mode 100644 index 00000000000..76de5008884 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc @@ -0,0 +1,56 @@ +// { dg-do compile } +// 1999-08-24 bkoz + +// Copyright (C) 1999, 2000, 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.1 The ctype category + +// 1: Test that the locale headers are picking up the correct declaration +// of the internal type `ctype_base::mask'. +int mask (); + +#include + +// 2: Sanity check ctype_base::mask bitmask requirements +void +test01() +{ + using namespace std; + + ctype_base::mask m01; + ctype_base::mask m02; + ctype_base::mask res; + + m01 = ctype_base::space; + m02 = ctype_base::xdigit; + + res = m01 & m02; + res = m01 | m02; + res = m01 ^ m02; + res = ~m01; + m01 &= m02; + m01 |= m02; + m01 ^= m02; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/ctype/11844.cc b/libstdc++-v3/testsuite/22_locale/ctype_base/11844.cc similarity index 100% rename from libstdc++-v3/testsuite/22_locale/ctype/11844.cc rename to libstdc++-v3/testsuite/22_locale/ctype_base/11844.cc diff --git a/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc b/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc new file mode 100644 index 00000000000..61fa30d250f --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// 2001-08-15 Benjamin Kosnik + +// Copyright (C) 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.1.1 - Template class ctype + +#include + +void test01() +{ + // Check for required base class. + typedef std::ctype_byname test_type; + typedef std::ctype base_type; + const test_type& obj = std::use_facet(std::locale::classic()); + const base_type* base __attribute__((unused)) = &obj; + + // Check for required typedefs + typedef test_type::char_type char_type; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc index 3072383a988..5b9b5d7324c 100644 --- a/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc +++ b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc @@ -1,4 +1,5 @@ -// 2001-07-17 Benjamin Kosnik +// { dg-do compile } +// 2001-07-17 Benjamin Kosnik // Copyright (C) 2001, 2003 Free Software Foundation // @@ -18,57 +19,21 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 22.2.7.2 Template class messages_byname +// 22.2.7 The message retrieval category #include -#include void test01() { - using namespace std; - typedef std::messages::catalog catalog; - typedef std::messages::string_type string_type; + // Check for required base class. + typedef std::messages_byname test_type; + typedef std::messages base_type; + const test_type& obj = std::use_facet(std::locale::classic()); + const base_type* base __attribute__((unused)) = &obj; - bool test __attribute__((unused)) = true; - string str; - // This is defined through CXXFLAGS in scripts/testsuite_flags[.in]. - const char* dir = LOCALEDIR; - locale loc_c = locale::classic(); - - locale loc_de = __gnu_test::try_named_locale("de_DE"); - str = loc_de.name(); - - locale loc_byname(locale::classic(), new messages_byname("de_DE")); - str = loc_byname.name(); - - VERIFY( loc_de != loc_byname ); - - // cache the messages facets - const messages& mssg_byname = use_facet >(loc_byname); - const messages& mssg_de = use_facet >(loc_de); - - // catalog open(const string&, const locale&) const; - // string_type get(catalog, int, int, const string_type& ) const; - // void close(catalog) const; - - // Check German (de_DE) locale. - catalog cat_de = mssg_de.open("libstdc++", loc_c, dir); - string s01 = mssg_de.get(cat_de, 0, 0, "please"); - string s02 = mssg_de.get(cat_de, 0, 0, "thank you"); - VERIFY ( s01 == "bitte" ); - VERIFY ( s02 == "danke" ); - mssg_de.close(cat_de); - - // Check byname locale. - catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir); - string s03 = mssg_byname.get(cat_de, 0, 0, "please"); - string s04 = mssg_byname.get(cat_de, 0, 0, "thank you"); - VERIFY ( s03 == "bitte" ); - VERIFY ( s04 == "danke" ); - mssg_byname.close(cat_byname); - - VERIFY ( s01 == s03 ); - VERIFY ( s02 == s04 ); + // Check for required typedefs + typedef test_type::char_type char_type; + typedef test_type::string_type string_type; } int main() diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc new file mode 100644 index 00000000000..3072383a988 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc @@ -0,0 +1,78 @@ +// 2001-07-17 Benjamin Kosnik + +// Copyright (C) 2001, 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.7.2 Template class messages_byname + +#include +#include + +void test01() +{ + using namespace std; + typedef std::messages::catalog catalog; + typedef std::messages::string_type string_type; + + bool test __attribute__((unused)) = true; + string str; + // This is defined through CXXFLAGS in scripts/testsuite_flags[.in]. + const char* dir = LOCALEDIR; + locale loc_c = locale::classic(); + + locale loc_de = __gnu_test::try_named_locale("de_DE"); + str = loc_de.name(); + + locale loc_byname(locale::classic(), new messages_byname("de_DE")); + str = loc_byname.name(); + + VERIFY( loc_de != loc_byname ); + + // cache the messages facets + const messages& mssg_byname = use_facet >(loc_byname); + const messages& mssg_de = use_facet >(loc_de); + + // catalog open(const string&, const locale&) const; + // string_type get(catalog, int, int, const string_type& ) const; + // void close(catalog) const; + + // Check German (de_DE) locale. + catalog cat_de = mssg_de.open("libstdc++", loc_c, dir); + string s01 = mssg_de.get(cat_de, 0, 0, "please"); + string s02 = mssg_de.get(cat_de, 0, 0, "thank you"); + VERIFY ( s01 == "bitte" ); + VERIFY ( s02 == "danke" ); + mssg_de.close(cat_de); + + // Check byname locale. + catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir); + string s03 = mssg_byname.get(cat_de, 0, 0, "please"); + string s04 = mssg_byname.get(cat_de, 0, 0, "thank you"); + VERIFY ( s03 == "bitte" ); + VERIFY ( s04 == "danke" ); + mssg_byname.close(cat_byname); + + VERIFY ( s01 == s03 ); + VERIFY ( s02 == s04 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc index 2cdef4b1abc..e85bf230a8d 100644 --- a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc +++ b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc @@ -1,4 +1,5 @@ -// 2001-08-24 Benjamin Kosnik +// { dg-do compile } +// 2001-08-23 Benjamin Kosnik // Copyright (C) 2001, 2003 Free Software Foundation // @@ -18,77 +19,22 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 22.2.6.4 Template class moneypunct_byname +// 22.2.6.3 Template class moneypunct #include #include void test01() { - using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; - - bool test __attribute__((unused)) = true; - string str; - - locale loc_de = __gnu_test::try_named_locale("de_DE"); - str = loc_de.name(); - - locale loc_byname(locale::classic(), new moneypunct_byname("de_DE")); - str = loc_byname.name(); - - locale loc_c = locale::classic(); - - VERIFY( loc_de != loc_byname ); - - // cache the moneypunct facets - const moneypunct& monp_c = use_facet >(loc_c); - const moneypunct& monp_byname = - use_facet >(loc_byname); - const moneypunct& monp_de = use_facet >(loc_de); - - // sanity check that the data match - char dp1 = monp_de.decimal_point(); - char th1 = monp_de.thousands_sep(); - string g1 = monp_de.grouping(); - string cs1 = monp_de.curr_symbol(); - string ps1 = monp_de.positive_sign(); - string ns1 = monp_de.negative_sign(); - int fd1 = monp_de.frac_digits(); - pattern pos1 = monp_de.pos_format(); - pattern neg1 = monp_de.neg_format(); - - char dp2 = monp_byname.decimal_point(); - char th2 = monp_byname.thousands_sep(); - string g2 = monp_byname.grouping(); - string cs2 = monp_byname.curr_symbol(); - string ps2 = monp_byname.positive_sign(); - string ns2 = monp_byname.negative_sign(); - int fd2 = monp_byname.frac_digits(); - pattern pos2 = monp_byname.pos_format(); - pattern neg2 = monp_byname.neg_format(); - - VERIFY( dp1 == dp2 ); - VERIFY( th1 == th2 ); - VERIFY( g1 == g2 ); - VERIFY( cs1 == cs2 ); - VERIFY( ps1 == ps2 ); - VERIFY( ns1 == ns2 ); - VERIFY( fd1 == fd2 ); - VERIFY(static_cast(pos1.field[0]) == static_cast(pos2.field[0])); - VERIFY(static_cast(pos1.field[1]) == static_cast(pos2.field[1])); - VERIFY(static_cast(pos1.field[2]) == static_cast(pos2.field[2])); - VERIFY(static_cast(pos1.field[3]) == static_cast(pos2.field[3])); - - VERIFY(static_cast(neg1.field[0]) == static_cast(neg2.field[0])); - VERIFY(static_cast(neg1.field[1]) == static_cast(neg2.field[1])); - VERIFY(static_cast(neg1.field[2]) == static_cast(neg2.field[2])); - VERIFY(static_cast(neg1.field[3]) == static_cast(neg2.field[3])); - - // ...and don't match "C" - char dp3 = monp_c.decimal_point(); - VERIFY( dp1 != dp3 ); + // Check for required base class. + typedef std::moneypunct_byname test_type; + typedef std::moneypunct base_type; + const test_type& obj = std::use_facet(std::locale()); + const base_type* base __attribute__((unused)) = &obj; + + // Check for required typedefs + typedef test_type::char_type char_type; + typedef test_type::string_type string_type; } int main() diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc new file mode 100644 index 00000000000..2cdef4b1abc --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc @@ -0,0 +1,98 @@ +// 2001-08-24 Benjamin Kosnik + +// Copyright (C) 2001, 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.6.4 Template class moneypunct_byname + +#include +#include + +void test01() +{ + using namespace std; + typedef money_base::part part; + typedef money_base::pattern pattern; + + bool test __attribute__((unused)) = true; + string str; + + locale loc_de = __gnu_test::try_named_locale("de_DE"); + str = loc_de.name(); + + locale loc_byname(locale::classic(), new moneypunct_byname("de_DE")); + str = loc_byname.name(); + + locale loc_c = locale::classic(); + + VERIFY( loc_de != loc_byname ); + + // cache the moneypunct facets + const moneypunct& monp_c = use_facet >(loc_c); + const moneypunct& monp_byname = + use_facet >(loc_byname); + const moneypunct& monp_de = use_facet >(loc_de); + + // sanity check that the data match + char dp1 = monp_de.decimal_point(); + char th1 = monp_de.thousands_sep(); + string g1 = monp_de.grouping(); + string cs1 = monp_de.curr_symbol(); + string ps1 = monp_de.positive_sign(); + string ns1 = monp_de.negative_sign(); + int fd1 = monp_de.frac_digits(); + pattern pos1 = monp_de.pos_format(); + pattern neg1 = monp_de.neg_format(); + + char dp2 = monp_byname.decimal_point(); + char th2 = monp_byname.thousands_sep(); + string g2 = monp_byname.grouping(); + string cs2 = monp_byname.curr_symbol(); + string ps2 = monp_byname.positive_sign(); + string ns2 = monp_byname.negative_sign(); + int fd2 = monp_byname.frac_digits(); + pattern pos2 = monp_byname.pos_format(); + pattern neg2 = monp_byname.neg_format(); + + VERIFY( dp1 == dp2 ); + VERIFY( th1 == th2 ); + VERIFY( g1 == g2 ); + VERIFY( cs1 == cs2 ); + VERIFY( ps1 == ps2 ); + VERIFY( ns1 == ns2 ); + VERIFY( fd1 == fd2 ); + VERIFY(static_cast(pos1.field[0]) == static_cast(pos2.field[0])); + VERIFY(static_cast(pos1.field[1]) == static_cast(pos2.field[1])); + VERIFY(static_cast(pos1.field[2]) == static_cast(pos2.field[2])); + VERIFY(static_cast(pos1.field[3]) == static_cast(pos2.field[3])); + + VERIFY(static_cast(neg1.field[0]) == static_cast(neg2.field[0])); + VERIFY(static_cast(neg1.field[1]) == static_cast(neg2.field[1])); + VERIFY(static_cast(neg1.field[2]) == static_cast(neg2.field[2])); + VERIFY(static_cast(neg1.field[3]) == static_cast(neg2.field[3])); + + // ...and don't match "C" + char dp3 = monp_c.decimal_point(); + VERIFY( dp1 != dp3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/1.cc index 955eaef45f1..9c2b6925bcc 100644 --- a/libstdc++-v3/testsuite/22_locale/numpunct/1.cc +++ b/libstdc++-v3/testsuite/22_locale/numpunct/1.cc @@ -30,6 +30,10 @@ void test01() typedef std::locale::facet base_type; const test_type& obj = std::use_facet(std::locale()); const base_type* base __attribute__((unused)) = &obj; + + // Check for required typedefs + typedef test_type::char_type char_type; + typedef test_type::string_type string_type; } int main() diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/3.cc similarity index 100% rename from libstdc++-v3/testsuite/22_locale/numpunct_byname/2.cc rename to libstdc++-v3/testsuite/22_locale/numpunct/members/char/3.cc diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc index 171149ec767..8167788cdd5 100644 --- a/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc +++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc @@ -1,6 +1,7 @@ -// 2001-01-24 Benjamin Kosnik +// { dg-do compile } +// 2001-01-23 Benjamin Kosnik -// Copyright (C) 2001, 2003 Free Software Foundation +// Copyright (C) 2001, 2003 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -18,55 +19,21 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 22.2.3.2 Template class numpunct_byname +// 22.2.3 The numeric punctuation facet #include -#include void test01() { - using namespace std; - - bool test __attribute__((unused)) = true; - string str; + // Check for required base class. + typedef std::numpunct_byname test_type; + typedef std::numpunct base_type; + const test_type& obj = std::use_facet(std::locale()); + const base_type* base __attribute__((unused)) = &obj; - locale loc_de = __gnu_test::try_named_locale("de_DE"); - str = loc_de.name(); - - locale loc_byname(locale::classic(), new numpunct_byname("de_DE")); - str = loc_byname.name(); - - locale loc_c = locale::classic(); - - VERIFY( loc_de != loc_byname ); - - // cache the numpunct facets - const numpunct& nump_c = use_facet >(loc_c); - const numpunct& nump_byname = use_facet >(loc_byname); - const numpunct& nump_de = use_facet >(loc_de); - - // sanity check that the data match - char dp1 = nump_byname.decimal_point(); - char th1 = nump_byname.thousands_sep(); - string g1 = nump_byname.grouping(); - string t1 = nump_byname.truename(); - string f1 = nump_byname.falsename(); - - char dp2 = nump_de.decimal_point(); - char th2 = nump_de.thousands_sep(); - string g2 = nump_de.grouping(); - string t2 = nump_de.truename(); - string f2 = nump_de.falsename(); - - VERIFY( dp1 == dp2 ); - VERIFY( th1 == th2 ); - VERIFY( g1 == g2 ); - VERIFY( t1 == t2 ); - VERIFY( f1 == f2 ); - - // ...and don't match "C" - char dp3 = nump_c.decimal_point(); - VERIFY( dp1 != dp3 ); + // Check for required typedefs + typedef test_type::char_type char_type; + typedef test_type::string_type string_type; } int main() diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc new file mode 100644 index 00000000000..171149ec767 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc @@ -0,0 +1,76 @@ +// 2001-01-24 Benjamin Kosnik + +// Copyright (C) 2001, 2003 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.3.2 Template class numpunct_byname + +#include +#include + +void test01() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + string str; + + locale loc_de = __gnu_test::try_named_locale("de_DE"); + str = loc_de.name(); + + locale loc_byname(locale::classic(), new numpunct_byname("de_DE")); + str = loc_byname.name(); + + locale loc_c = locale::classic(); + + VERIFY( loc_de != loc_byname ); + + // cache the numpunct facets + const numpunct& nump_c = use_facet >(loc_c); + const numpunct& nump_byname = use_facet >(loc_byname); + const numpunct& nump_de = use_facet >(loc_de); + + // sanity check that the data match + char dp1 = nump_byname.decimal_point(); + char th1 = nump_byname.thousands_sep(); + string g1 = nump_byname.grouping(); + string t1 = nump_byname.truename(); + string f1 = nump_byname.falsename(); + + char dp2 = nump_de.decimal_point(); + char th2 = nump_de.thousands_sep(); + string g2 = nump_de.grouping(); + string t2 = nump_de.truename(); + string f2 = nump_de.falsename(); + + VERIFY( dp1 == dp2 ); + VERIFY( th1 == th2 ); + VERIFY( g1 == g2 ); + VERIFY( t1 == t2 ); + VERIFY( f1 == f2 ); + + // ...and don't match "C" + char dp3 = nump_c.decimal_point(); + VERIFY( dp1 != dp3 ); +} + +int main() +{ + test01(); + return 0; +}