-// 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;
}