]> gcc.gnu.org Git - gcc.git/commitdiff
locale_facets.h: Correct byname facets for "C" locale.
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 22 Oct 2003 18:58:35 +0000 (18:58 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 22 Oct 2003 18:58:35 +0000 (18:58 +0000)
2003-10-22  Benjamin Kosnik  <bkoz@redhat.com>

* 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

24 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/locale/generic/ctype_members.cc
libstdc++-v3/config/locale/generic/messages_members.h
libstdc++-v3/config/locale/gnu/ctype_members.cc
libstdc++-v3/config/locale/gnu/messages_members.h
libstdc++-v3/include/bits/codecvt.h
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/src/ctype.cc
libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/collate/1.cc
libstdc++-v3/testsuite/22_locale/collate_byname/1.cc
libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/ctype/1.cc
libstdc++-v3/testsuite/22_locale/ctype_base/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/ctype_base/11844.cc [moved from libstdc++-v3/testsuite/22_locale/ctype/11844.cc with 100% similarity]
libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/messages_byname/1.cc
libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc
libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/numpunct/1.cc
libstdc++-v3/testsuite/22_locale/numpunct/members/char/3.cc [moved from libstdc++-v3/testsuite/22_locale/numpunct_byname/2.cc with 100% similarity]
libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc
libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc [new file with mode: 0644]

index 76d345e19a4b02239a37b1065beade11524e2af1..9100bb19a60e742a583ff994c26fadf72c0c33a0 100644 (file)
@@ -1,3 +1,32 @@
+2003-10-22  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * 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  <pcarlini@suse.de>
 
        PR libstdc++/8610
index 9b3bddb6bef42291943e53d761b813aef02603e5..71175f145595c008aa7a2730cce7bfb6bc60fa16 100644 (file)
@@ -43,8 +43,11 @@ namespace std
     ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
     : ctype<char>(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  
index 3e9122e880fc3696676263ebf4188446b9a7b5f2..cecc6446c7120632caf8839480b9401368f13d8e 100644 (file)
@@ -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); 
+         }
      }
index 79a14f57a4829e6919fb2472975c890b2102ab55..a5394b53828b487bbee191ca75e83e4e38b2b0aa 100644 (file)
@@ -43,12 +43,15 @@ namespace std
   template<>
     ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
     : ctype<char>(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  
index 9bb8e50c43800a50ed866498dd8a0f4b10a8b220..ed95dfb4c43cbfd85269fbeabe899a25c05ca69b 100644 (file)
        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); 
+         }
      }
index 1d123a93c6491c04c7404ee5383abd0665c51c74..80f9cba0b3589a1d65f35e19856b0b2e046bf05e 100644 (file)
       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:
index 13383d8d36f4af805e4e3f16a8fd4b483a7b9161..abb9d143c61e9bb60f569b05b3358faa841ff8d4 100644 (file)
@@ -795,9 +795,6 @@ namespace std
   template<typename _CharT>
     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<typename _CharT, typename _InIter>
@@ -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<typename _CharT, bool _Intl>
     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<typename _CharT, bool _Intl>
index e97d39dfe1cbaac44df5fb2f771866a5b2dc926a..7fb5c2da81fc3119609b8f8d7d554453e3d50527 100644 (file)
@@ -99,9 +99,12 @@ namespace std
   template<>
     ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
     : ctype<wchar_t>(__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 (file)
index 0000000..a17c841
--- /dev/null
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// 2001-08-27  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+
+void test01()
+{
+  // Check for required base class.
+  typedef std::codecvt_byname<char, char, mbstate_t> test_type;
+  typedef std::codecvt<char, char, mbstate_t> base_type;
+  const test_type& obj = std::use_facet<test_type>(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;
+}
index 2f6415fcd67dd7c7344eb8f1884db12cea50de40..41f615e3dde058bc52380d5a12ce7d6012b70bbf 100644 (file)
@@ -26,7 +26,7 @@
 void test01()
 {
   // Check for required base class.
-  typedef std::messages<char> test_type;
+  typedef std::collate<char> test_type;
   typedef std::locale::facet base_type;
   const test_type& obj = std::use_facet<test_type>(std::locale()); 
   const base_type* base __attribute__((unused)) = &obj;
index be4524f9ca6532f060a81472ee1a3d5bf1bd242b..6f1f6432ae62539af33aa8677abace452a005e0f 100644 (file)
@@ -1,6 +1,7 @@
-// 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
 
-// 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
 // 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 <locale>
-#include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  typedef std::collate<char>::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<char>("de_DE"));
-  str = loc_byname.name();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the collate facets
-  const collate<char>& coll_de = use_facet<collate<char> >(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 base class.
+  typedef std::collate_byname<char> test_type;
+  typedef std::collate<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  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/collate_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc
new file mode 100644 (file)
index 0000000..be4524f
--- /dev/null
@@ -0,0 +1,135 @@
+// 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  typedef std::collate<char>::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<char>("de_DE"));
+  str = loc_byname.name();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the collate facets
+  const collate<char>& coll_de = use_facet<collate<char> >(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;
+}
index adda6fd548d90d7042d183de2b389e062d3c29c2..ed8122121da4ebb04cb2a70c9d25039fa59b2d4b 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do compile }
-// 1999-08-24 bkoz
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
 
-// 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
 // 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 <locale>
 
-// 2: Should be able to instantiate this for other types besides char, wchar_t
-typedef std::ctype<char> cctype;
-
-class gnu_ctype: public std::ctype<unsigned char> 
-{ 
-private:
-  const cctype& _M_cctype;
-
-public:
-  explicit 
-  gnu_ctype(size_t __refs = 0) 
-  : std::ctype<unsigned char>(__refs), 
-    _M_cctype(std::use_facet<cctype>(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<const char*>(__lo), 
-                                  reinterpret_cast<const char*>(__hi), __vec);
-    return reinterpret_cast<const char_type*>(__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<const char*>(__lo), 
-                                       reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__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<const char*>(__lo), 
-                                       reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__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<char*>(__lo), 
-                                       reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__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<char*>(__lo), 
-                                       reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__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<const char*>(__lo), 
-                                     reinterpret_cast<const char*>(__hi),
-                                     reinterpret_cast<char*>(__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<const char*>(__lo), 
-                                      reinterpret_cast<const char*>(__hi),
-                                      __dfault,
-                                      reinterpret_cast<char*>(__dest));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-};
-
-gnu_ctype::~gnu_ctype() { }
-
-gnu_ctype facet01;
-
-// 3: Sanity check ctype_base::mask bitmask requirements
-void
-test01()
+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;
+  // Check for required base class.
+  typedef std::ctype<char> test_type;
+  typedef std::locale::facet base_type1;
+  typedef std::ctype_base base_type2;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type1* base1 __attribute__((unused)) = &obj;
+  const base_type2* base2 __attribute__((unused)) = &obj;
+
+  // 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 (file)
index 0000000..76de500
--- /dev/null
@@ -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 <locale>
+
+// 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_byname/1.cc b/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc
new file mode 100644 (file)
index 0000000..61fa30d
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+
+void test01()
+{
+  // Check for required base class.
+  typedef std::ctype_byname<char> test_type;
+  typedef std::ctype<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(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;
+}
index 3072383a9883b5013d3c248d2feee6650bf2011e..5b9b5d7324cf4df1b52626f825e5f1585ea5028e 100644 (file)
@@ -1,4 +1,5 @@
-// 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-07-17  Benjamin Kosnik  <bkoz@redhat.com>
 
 // Copyright (C) 2001, 2003 Free Software Foundation
 //
 // 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 <locale>
-#include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  typedef std::messages<char>::catalog catalog;
-  typedef std::messages<char>::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<char>("de_DE"));
-  str = loc_byname.name();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the messages facets
-  const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname); 
-  const messages<char>& mssg_de = use_facet<messages<char> >(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 base class.
+  typedef std::messages_byname<char> test_type;
+  typedef std::messages<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  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/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
new file mode 100644 (file)
index 0000000..3072383
--- /dev/null
@@ -0,0 +1,78 @@
+// 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  typedef std::messages<char>::catalog catalog;
+  typedef std::messages<char>::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<char>("de_DE"));
+  str = loc_byname.name();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the messages facets
+  const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname); 
+  const messages<char>& mssg_de = use_facet<messages<char> >(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;
+}
index 2cdef4b1abc1385ebf6a8b82c72333d7ded7a706..e85bf230a8d63c04f8d1dd041593c0a1381774e2 100644 (file)
@@ -1,4 +1,5 @@
-// 2001-08-24 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-23  Benjamin Kosnik  <bkoz@redhat.com>
 
 // Copyright (C) 2001, 2003 Free Software Foundation
 //
 // 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 <locale>
 #include <testsuite_hooks.h>
 
 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<char>("de_DE"));
-  str = loc_byname.name();
-
-  locale loc_c = locale::classic();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the moneypunct facets
-  const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 
-  const moneypunct<char>& monp_byname = 
-                                    use_facet<moneypunct<char> >(loc_byname); 
-  const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(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<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
-  VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
-  VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
-  VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
-
-  VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
-  VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
-  VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
-  VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(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<char, true> test_type;
+  typedef std::moneypunct<char, true> base_type;
+  const test_type& obj = std::use_facet<test_type>(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 (file)
index 0000000..2cdef4b
--- /dev/null
@@ -0,0 +1,98 @@
+// 2001-08-24 Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+#include <testsuite_hooks.h>
+
+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<char>("de_DE"));
+  str = loc_byname.name();
+
+  locale loc_c = locale::classic();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the moneypunct facets
+  const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 
+  const moneypunct<char>& monp_byname = 
+                                    use_facet<moneypunct<char> >(loc_byname); 
+  const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(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<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
+  VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
+  VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
+  VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
+
+  VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
+  VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
+  VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
+  VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3]));
+
+  // ...and don't match "C"
+  char dp3 = monp_c.decimal_point();
+  VERIFY( dp1 != dp3 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 955eaef45f1cba5f8bfe3b23e8461b0dd47a3c1e..9c2b6925bcc65ce61d711d1f9a2f78735ad5799a 100644 (file)
@@ -30,6 +30,10 @@ void test01()
   typedef std::locale::facet base_type;
   const test_type& obj = std::use_facet<test_type>(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()
index 171149ec76750ba49d11bfc00363d9f44d42ce8e..8167788cdd5918e867084bca13790fb16200eda1 100644 (file)
@@ -1,6 +1,7 @@
-// 2001-01-24 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-01-23  Benjamin Kosnik  <bkoz@redhat.com>
 
-// 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
 // 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 <locale>
-#include <testsuite_hooks.h>
 
 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<char>("de_DE"));
-  str = loc_byname.name();
-
-  locale loc_c = locale::classic();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the numpunct facets
-  const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); 
-  const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname); 
-  const numpunct<char>& nump_de = use_facet<numpunct<char> >(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 base class.
+  typedef std::numpunct_byname<char> test_type;
+  typedef std::numpunct<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(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/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc
new file mode 100644 (file)
index 0000000..171149e
--- /dev/null
@@ -0,0 +1,76 @@
+// 2001-01-24 Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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 <locale>
+#include <testsuite_hooks.h>
+
+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<char>("de_DE"));
+  str = loc_byname.name();
+
+  locale loc_c = locale::classic();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the numpunct facets
+  const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); 
+  const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname); 
+  const numpunct<char>& nump_de = use_facet<numpunct<char> >(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;
+}
This page took 0.1065 seconds and 5 git commands to generate.