]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/22_locale/ctype/narrow/char/1.cc
Reshuffle 22_locale testsuite.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / narrow / char / 1.cc
similarity index 61%
rename from libstdc++-v3/testsuite/22_locale/ctype_members_wchar_t.cc
rename to libstdc++-v3/testsuite/22_locale/ctype/narrow/char/1.cc
index 31b1bcbf1608b8c4a28d68bacf8ab31c323bdc64..b349a38aedd927f244b9f2eabd11f3e91d79ae36 100644 (file)
@@ -1,6 +1,6 @@
-// 2000-09-01 Benjamin Kosnik <bkoz@redhat.com>
+// 2002-05-24 bkoz
 
-// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 //
 // 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
 // 22.2.1.3.2 ctype<char> members
 
 #include <locale>
+#include <vector>
 #include <testsuite_hooks.h>
 
-#if _GLIBCPP_USE_WCHAR_T
+// libstdc++/6701
 void test01()
 {
-  // Nothing, right now.  
+  using namespace std;
+  typedef char         wide_type;
+
+  bool test = true;
+  const char dfault = '?';
+  const locale loc_c = locale::classic();
+  const ctype<wide_type>& ctype_c = use_facet<ctype<wide_type> >(loc_c); 
+
+  basic_string<wide_type>      wide("wibble");
+  basic_string<char>           narrow("wibble");
+  vector<char>                         narrow_chars(wide.length() + 1);
+  
+  // narrow(charT c, char dfault) const
+  for (int i = 0; i < wide.length(); ++i)
+    {
+      char c = ctype_c.narrow(wide[i], dfault);
+      VERIFY( c == narrow[i] );
+    }
+
+  // narrow(const charT* low, const charT* high, char dfault, char* dest) const
+  ctype_c.narrow(&wide[0], &wide[wide.length()], dfault, &narrow_chars[0]);  
+  VERIFY( narrow_chars[0] != dfault );
+  for (int i = 0; i < wide.length(); ++i)
+    VERIFY( narrow_chars[i] == narrow[i] );
 }
-#endif /* !defined(_GLIBCPP_USE_WCHAR_T) */
 
 int main() 
 {
-#if _GLIBCPP_USE_WCHAR_T
   test01();
-#endif 
-
   return 0;
 }