summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/22_locale/num_put/put
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/22_locale/num_put/put
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/num_put/put')
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/1.cc165
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc67
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/11.cc70
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/12.cc63
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc55
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/15565.cc62
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/2.cc91
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/20914.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/23953.cc75
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/3.cc76
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/38196.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/38210.cc68
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/4.cc102
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/5.cc71
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/6.cc55
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/7.cc48
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/8.cc67
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/9.cc61
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/9780-2.cc81
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_env.cc59
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_locale.cc60
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc163
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc67
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/11.cc70
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/12.cc63
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc54
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/15565.cc62
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/2.cc89
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20914.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/23953.cc75
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/3.cc74
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38196.cc80
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38210.cc68
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/4.cc99
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/5.cc69
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/6.cc55
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/7.cc44
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/8.cc67
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/9.cc61
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_env.cc58
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_locale.cc59
43 files changed, 3173 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/1.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/1.cc
new file mode 100644
index 000000000..602baf5d7
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/1.cc
@@ -0,0 +1,165 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_de = locale("de_DE");
+ VERIFY( loc_c != loc_de );
+
+ // cache the numpunct facets
+ const numpunct<char>& numpunct_de = use_facet<numpunct<char> >(loc_de);
+
+ // sanity check the data is correct.
+ const string empty;
+ string result1;
+ string result2;
+
+ bool b1 = true;
+ bool b0 = false;
+ unsigned long ul1 = 1294967294;
+ double d1 = 1.7976931348623157e+308;
+ double d2 = 2.2250738585072014e-308;
+ long double ld1 = 1.7976931348623157e+308;
+ long double ld2 = 2.2250738585072014e-308;
+ const void* cv = &ld1;
+
+ // cache the num_put facet
+ ostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ // bool, simple
+ iterator_type os_it00 = oss.rdbuf();
+ np.put(os_it00, oss, '+', b1);
+ result1 = oss.str();
+ VERIFY( result1 == "1" );
+
+ oss.str(empty);
+ np.put(oss.rdbuf(), oss, '+', b0);
+ result2 = oss.str();
+ VERIFY( result2 == "0" );
+
+ // ... and one that does
+ oss.imbue(loc_de);
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', ul1);
+ result1 = oss.str();
+ VERIFY( result1 == "1.294.967.294+++++++" );
+
+ // double
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', d1);
+ result1 = oss.str();
+ VERIFY( result1 == "1,79769e+308++++++++" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', d2);
+ result1 = oss.str();
+ VERIFY( result1 == "++++++++2,22507e-308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ oss.setf(ios_base::scientific, ios_base::floatfield);
+ np.put(oss.rdbuf(), oss, '+', d2);
+ result2 = oss.str();
+ VERIFY( result2 == "+++++++2,225074e-308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.precision(10);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ oss.setf(ios_base::scientific, ios_base::floatfield);
+ oss.setf(ios_base::uppercase);
+ np.put(oss.rdbuf(), oss, '+', d2);
+ result1 = oss.str();
+ VERIFY( result1 == "+++2,2250738585E-308" );
+
+ // long double
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '+', ld1);
+ result1 = oss.str();
+ VERIFY( result1 == "1,7976931349E+308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.precision(0);
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ np.put(oss.rdbuf(), oss, '+', ld2);
+ result1 = oss.str();
+ VERIFY( result1 == "0" );
+
+ // const void*
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '+', cv);
+ result1 = oss.str();
+ // No grouping characters.
+ VERIFY( !char_traits<char>::find(result1.c_str(),
+ result1.size(),
+ numpunct_de.decimal_point()) );
+ // Should contain an 'x'.
+ VERIFY( result1.find('x') == 1 );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ long long ll1 = 9223372036854775807LL;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '+', ll1);
+ result1 = oss.str();
+ VERIFY( result1 == "9.223.372.036.854.775.807" );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc
new file mode 100644
index 000000000..abaac89bb
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/10.cc
@@ -0,0 +1,67 @@
+// 2005-07-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc_c = locale::classic();
+
+ const string empty;
+
+ stringstream ss;
+ ss.imbue(loc_c);
+ const num_put<char>& np = use_facet<num_put<char> >(ss.getloc());
+
+ long l = -1;
+ unsigned long ul = 0;
+
+ ss.setf(ios::hex, ios::basefield);
+ np.put(ss.rdbuf(), ss, '+', l);
+ VERIFY( ss.str() != "1" );
+ ss >> ul;
+ VERIFY( ul == static_cast<unsigned long>(l) );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ long long ll = -1LL;
+ unsigned long long ull = 0ULL;
+
+ ss.str(empty);
+ ss.clear();
+ np.put(ss.rdbuf(), ss, '+', ll);
+ VERIFY( ss.str() != "1" );
+ ss >> ull;
+ VERIFY( ull == static_cast<unsigned long long>(ll) );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/11.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/11.cc
new file mode 100644
index 000000000..1aa7ed736
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/11.cc
@@ -0,0 +1,70 @@
+// 2006-10-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct Punct1: std::numpunct<char>
+{ std::string do_grouping() const { return "\003\002\001"; } };
+
+struct Punct2: std::numpunct<char>
+{ std::string do_grouping() const { return "\001\003"; } };
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss1, oss2;
+ string result1, result2, result3;
+ const string empty;
+
+ oss1.imbue(locale(oss1.getloc(), new Punct1));
+ oss2.imbue(locale(oss2.getloc(), new Punct2));
+ const num_put<char>& ng1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& ng2 = use_facet<num_put<char> >(oss2.getloc());
+
+ long l1 = 12345678l;
+ double d1 = 1234567.0;
+ double d2 = 123456.0;
+
+ ng1.put(oss1.rdbuf(), oss1, '+', l1);
+ result1 = oss1.str();
+ VERIFY( result1 == "1,2,3,45,678" );
+
+ oss2.precision(1);
+ oss2.setf(ios_base::fixed, ios_base::floatfield);
+ ng2.put(oss2.rdbuf(), oss2, '+', d1);
+ result2 = oss2.str();
+ VERIFY( result2 == "123,456,7.0" );
+
+ oss2.str(empty);
+ ng2.put(oss2.rdbuf(), oss2, '+', d2);
+ result3 = oss2.str();
+ VERIFY( result3 == "12,345,6.0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/12.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/12.cc
new file mode 100644
index 000000000..971af5ab1
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/12.cc
@@ -0,0 +1,63 @@
+// 2007-11-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00074.html
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss1, oss2, oss3;
+ const num_put<char>& np1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& np2 = use_facet<num_put<char> >(oss2.getloc());
+ const num_put<char>& np3 = use_facet<num_put<char> >(oss3.getloc());
+
+ string result1, result2, result3;
+
+ long int li1 = 0;
+ long int li2 = 5;
+ double d1 = 0.0;
+
+ oss1.setf(ios_base::showpos);
+ np1.put(oss1.rdbuf(), oss1, '*', li1);
+ result1 = oss1.str();
+ VERIFY( result1 == "+0" );
+
+ oss2.setf(ios_base::showpos);
+ np2.put(oss2.rdbuf(), oss2, '*', li2);
+ result2 = oss2.str();
+ VERIFY( result2 == "+5" );
+
+ oss3.setf(ios_base::showpos);
+ np3.put(oss3.rdbuf(), oss3, '*', d1);
+ result3 = oss3.str();
+ VERIFY( result3 == "+0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc
new file mode 100644
index 000000000..f1fe57c30
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc
@@ -0,0 +1,55 @@
+// 2004-04-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009, 2010, 2011 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+// On Solaris 9/x86 and 32-bit Solaris 10/x86, this test crashes in libc.
+// Inside libstdc++, we call sprintf like so:
+// sprintf (buffer, "%.*f", 1000, 1.0)
+// which crashes.
+// { dg-xfail-run-if "" i?86-*-solaris2.9 }
+// { dg-xfail-run-if "" { i?86-*-solaris2.10 && ilp32 } }
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/14220
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss;
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ const int precision = 1000;
+
+ oss.precision(precision);
+ oss.setf(ios_base::fixed);
+ np.put(oss.rdbuf(), oss, '+', 1.0);
+ const string result = oss.str();
+ VERIFY( result.size() == precision + 2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/15565.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/15565.cc
new file mode 100644
index 000000000..33614b416
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/15565.cc
@@ -0,0 +1,62 @@
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/15565
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const string empty;
+
+ // cache the num_put facet
+ ostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ unsigned long ul1 = 42UL;
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, ' ', ul1);
+ VERIFY( oss.str() == "42" );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ unsigned long long ull1 = 31ULL;
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, ' ', ull1);
+ VERIFY( oss.str() == "31" );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/2.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/2.cc
new file mode 100644
index 000000000..c006b73cf
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/2.cc
@@ -0,0 +1,91 @@
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const string empty;
+ string result1;
+ string result2;
+
+ bool b1 = true;
+ bool b0 = false;
+ unsigned long ul1 = 1294967294;
+ unsigned long ul2 = 0;
+
+ // cache the num_put facet
+ ostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ // C
+ // bool, more twisted examples
+ oss.str(empty);
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', b0);
+ result1 = oss.str();
+ VERIFY( result1 == "+++++++++++++++++++0" );
+
+ oss.str(empty);
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ oss.setf(ios_base::boolalpha);
+ np.put(oss.rdbuf(), oss, '+', b1);
+ result2 = oss.str();
+ VERIFY( result2 == "true++++++++++++++++" );
+
+ // unsigned long, in a locale that does not group
+ oss.imbue(loc_c);
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '+', ul1);
+ result1 = oss.str();
+ VERIFY( result1 == "1294967294" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', ul2);
+ result1 = oss.str();
+ VERIFY( result1 == "0+++++++++++++++++++" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc
new file mode 100644
index 000000000..e00655bfc
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc
@@ -0,0 +1,80 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2005-04-08 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/20909
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const string empty;
+ string result;
+
+ ostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ double d0 = 2e20;
+ double d1 = -2e20;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '*', d0);
+ result = oss.str();
+ VERIFY( result == "2e+20" );
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '*', d1);
+ result = oss.str();
+ VERIFY( result == "-2e+20" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::uppercase);
+ np.put(oss.rdbuf(), oss, '*', d0);
+ result = oss.str();
+ VERIFY( result == "2E+20" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, '*', d0);
+ result = oss.str();
+ VERIFY( result == "+2E+20" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/20914.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/20914.cc
new file mode 100644
index 000000000..667ff1a48
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/20914.cc
@@ -0,0 +1,80 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2005-04-17 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/20914
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const string empty;
+ string result;
+
+ ostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ long l0 = -300000;
+ long l1 = 300;
+ double d0 = -300000;
+ double d1 = 300;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '*', l0);
+ result = oss.str();
+ VERIFY( result == "-300.000" );
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '*', d0);
+ result = oss.str();
+ VERIFY( result == "-300.000" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, '*', l1);
+ result = oss.str();
+ VERIFY( result == "+300" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, '*', d1);
+ result = oss.str();
+ VERIFY( result == "+300" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/23953.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/23953.cc
new file mode 100644
index 000000000..9ab0f51bf
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/23953.cc
@@ -0,0 +1,75 @@
+// 2005-09-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+struct Punct1: numpunct<char>
+{ string do_grouping() const { return string(1, char(-1)); } };
+
+struct Punct2: numpunct<char>
+{ string do_grouping() const { return string("\002") + char(-1); } };
+
+struct Punct3: numpunct<char>
+{ string do_grouping() const { return string("\001\002") + char(-1); } };
+
+// libstdc++/23953
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss1, oss2, oss3;
+ string result1, result2, result3;
+
+ oss1.imbue(locale(oss1.getloc(), new Punct1));
+ oss2.imbue(locale(oss2.getloc(), new Punct2));
+ oss3.imbue(locale(oss3.getloc(), new Punct3));
+ const num_put<char>& ng1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& ng2 = use_facet<num_put<char> >(oss2.getloc());
+ const num_put<char>& ng3 = use_facet<num_put<char> >(oss3.getloc());
+
+ long l1 = 12345l;
+ long l2 = 12345678l;
+ double d1 = 1234567.0;
+
+ ng1.put(oss1.rdbuf(), oss1, '+', l1);
+ result1 = oss1.str();
+ VERIFY( result1 == "12345" );
+
+ ng2.put(oss2.rdbuf(), oss2, '+', l2);
+ result2 = oss2.str();
+ VERIFY( result2 == "123456,78" );
+
+ oss3.precision(1);
+ oss3.setf(ios_base::fixed, ios_base::floatfield);
+ ng3.put(oss3.rdbuf(), oss3, '+', d1);
+ result3 = oss3.str();
+ VERIFY( result3 == "1234,56,7.0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/3.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/3.cc
new file mode 100644
index 000000000..d8973fe85
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/3.cc
@@ -0,0 +1,76 @@
+// { dg-require-namedlocale "en_HK" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_hk = locale("en_HK");
+ VERIFY( loc_c != loc_hk );
+
+ // sanity check the data is correct.
+ const string empty;
+ string result1;
+ string result2;
+
+ long l1 = 2147483647;
+ long l2 = -2147483647;
+
+ // cache the num_put facet
+ ostringstream oss;
+ oss.imbue(loc_hk);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ // HK
+ // long, in a locale that expects grouping
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, '+', l1);
+ result1 = oss.str();
+ VERIFY( result1 == "2,147,483,647" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, '+', l2);
+ result1 = oss.str();
+ VERIFY( result1 == "-2,147,483,647++++++" );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/38196.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/38196.cc
new file mode 100644
index 000000000..eb0ea840a
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/38196.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+class my_punct : public std::numpunct<char>
+{
+protected:
+ std::string do_falsename() const { return "-no-"; }
+};
+
+// libstdc++/38196
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ ostringstream oss1, oss2, oss3, oss4;
+ string result1, result2, result3, result4;
+
+ oss1.imbue(locale(oss1.getloc(), new my_punct));
+ oss2.imbue(locale(oss2.getloc(), new my_punct));
+ oss3.imbue(locale(oss3.getloc(), new my_punct));
+ oss4.imbue(locale(oss4.getloc(), new my_punct));
+ const num_put<char>& ng1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& ng2 = use_facet<num_put<char> >(oss2.getloc());
+ const num_put<char>& ng3 = use_facet<num_put<char> >(oss3.getloc());
+ const num_put<char>& ng4 = use_facet<num_put<char> >(oss4.getloc());
+
+ oss1.width(6);
+ oss1.setf(ios_base::boolalpha);
+ ng1.put(oss1.rdbuf(), oss1, '*', false);
+ result1 = oss1.str();
+ VERIFY( result1 == "**-no-" );
+
+ oss2.width(6);
+ oss2.setf(ios_base::right, ios_base::adjustfield);
+ oss2.setf(ios_base::boolalpha);
+ ng2.put(oss2.rdbuf(), oss2, '*', false);
+ result2 = oss2.str();
+ VERIFY( result2 == "**-no-" );
+
+ oss3.width(6);
+ oss3.setf(ios_base::internal, ios_base::adjustfield);
+ oss3.setf(ios_base::boolalpha);
+ ng3.put(oss3.rdbuf(), oss3, '*', false);
+ result3 = oss3.str();
+ VERIFY( result3 == "**-no-" );
+
+ oss4.width(6);
+ oss4.setf(ios_base::left, ios_base::adjustfield);
+ oss4.setf(ios_base::boolalpha);
+ ng4.put(oss4.rdbuf(), oss4, '*', false);
+ result4 = oss4.str();
+ VERIFY( result4 == "-no-**" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/38210.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/38210.cc
new file mode 100644
index 000000000..d97126a6d
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/38210.cc
@@ -0,0 +1,68 @@
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/38210
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ ostringstream oss1, oss2, oss3, oss4;
+ string result1, result2, result3, result4;
+
+ const num_put<char>& ng1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& ng2 = use_facet<num_put<char> >(oss2.getloc());
+ const num_put<char>& ng3 = use_facet<num_put<char> >(oss3.getloc());
+ const num_put<char>& ng4 = use_facet<num_put<char> >(oss4.getloc());
+
+ void* p = (void*)0x1;
+
+ oss1.width(5);
+ ng1.put(oss1.rdbuf(), oss1, '*', p);
+ result1 = oss1.str();
+ VERIFY( result1 == "**0x1" );
+
+ oss2.width(5);
+ oss2.setf(ios_base::right, ios_base::adjustfield);
+ ng2.put(oss2.rdbuf(), oss2, '*', p);
+ result2 = oss2.str();
+ VERIFY( result2 == "**0x1" );
+
+ oss3.width(5);
+ oss3.setf(ios_base::internal, ios_base::adjustfield);
+ ng3.put(oss3.rdbuf(), oss3, '*', p);
+ result3 = oss3.str();
+ VERIFY( result3 == "0x**1" );
+
+ oss4.width(5);
+ oss4.setf(ios_base::left, ios_base::adjustfield);
+ ng4.put(oss4.rdbuf(), oss4, '*', p);
+ result4 = oss4.str();
+ VERIFY( result4 == "0x1**" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/4.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/4.cc
new file mode 100644
index 000000000..652dde931
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/4.cc
@@ -0,0 +1,102 @@
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test04()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // Check num_put works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
+ typedef string::iterator iter_type;
+ typedef char_traits<char> traits;
+ typedef num_put<char, iter_type> num_put_type;
+ const locale loc_c = locale::classic();
+ const string str("1798 Lady Elgin");
+ const string x(18, 'x'); // have to have allocated string!
+ // allow for "0x" + 16 hex digits (64-bit pointer)
+ string res;
+
+ ostringstream oss;
+ oss.imbue(locale(loc_c, new num_put_type));
+
+ // Iterator advanced, state, output.
+ const num_put_type& tp = use_facet<num_put_type>(oss.getloc());
+
+ // 01 put(long)
+ // 02 put(long double)
+ // 03 put(bool)
+ // 04 put(void*)
+
+ // 01 put(long)
+ const long l = 1798;
+ res = x;
+ iter_type ret1 = tp.put(res.begin(), oss, ' ', l);
+ string sanity1(res.begin(), ret1);
+ VERIFY( res == "1798xxxxxxxxxxxxxx" );
+ VERIFY( sanity1 == "1798" );
+
+ // 02 put(long double)
+ const long double ld = 1798.0;
+ res = x;
+ iter_type ret2 = tp.put(res.begin(), oss, ' ', ld);
+ string sanity2(res.begin(), ret2);
+ VERIFY( res == "1798xxxxxxxxxxxxxx" );
+ VERIFY( sanity2 == "1798" );
+
+ // 03 put(bool)
+ bool b = 1;
+ res = x;
+ iter_type ret3 = tp.put(res.begin(), oss, ' ', b);
+ string sanity3(res.begin(), ret3);
+ VERIFY( res == "1xxxxxxxxxxxxxxxxx" );
+ VERIFY( sanity3 == "1" );
+
+ b = 0;
+ res = x;
+ oss.setf(ios_base::boolalpha);
+ iter_type ret4 = tp.put(res.begin(), oss, ' ', b);
+ string sanity4(res.begin(), ret4);
+ VERIFY( res == "falsexxxxxxxxxxxxx" );
+ VERIFY( sanity4 == "false" );
+
+ // 04 put(void*)
+ oss.clear();
+ const void* cv = &ld;
+ res = x;
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type ret5 = tp.put(res.begin(), oss, ' ', cv);
+ string sanity5(res.begin(), ret5);
+ VERIFY( sanity5.size() );
+ VERIFY( sanity5[1] == 'x' );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/5.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/5.cc
new file mode 100644
index 000000000..d75a5edfb
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/5.cc
@@ -0,0 +1,71 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Make sure that, in a locale that expects grouping, when showbase
+// is true, an hexadecimal or octal zero is correctly output (the case
+// of zero is special since there is no 0x, 0 respectively, prefix)
+void test05()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const string empty;
+ string result;
+
+ ostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ long l = 0;
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showbase);
+ oss.setf(ios::hex, ios::basefield);
+ np.put(oss.rdbuf(), oss, '+', l);
+ result = oss.str();
+ VERIFY( result == "0" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showbase);
+ oss.setf(ios::oct, ios::basefield);
+ np.put(oss.rdbuf(), oss, '+', l);
+ result = oss.str();
+ VERIFY( result == "0" );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/6.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/6.cc
new file mode 100644
index 000000000..484d2906b
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/6.cc
@@ -0,0 +1,55 @@
+// 2003-02-05 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9548 and DR 231
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss1, oss2;
+ const num_put<char>& np1 = use_facet<num_put<char> >(oss1.getloc());
+ const num_put<char>& np2 = use_facet<num_put<char> >(oss2.getloc());
+
+ string result1, result2;
+
+ oss1.precision(-1);
+ oss1.setf(ios_base::fixed, ios_base::floatfield);
+ np1.put(oss1.rdbuf(), oss1, '+', 30.5);
+ result1 = oss1.str();
+ VERIFY( result1 == "30.500000" );
+
+ oss2.precision(0);
+ oss2.setf(ios_base::scientific, ios_base::floatfield);
+ np2.put(oss2.rdbuf(), oss2, '+', 1.0);
+ result2 = oss2.str();
+ VERIFY( result2 == "1e+00" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/7.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/7.cc
new file mode 100644
index 000000000..03163e1dd
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/7.cc
@@ -0,0 +1,48 @@
+// 2003-06-30 peturr02@ru.is
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <iostream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+// libstdc++/9828
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef num_put<char> np_t;
+
+ ostringstream stream;
+ const np_t& np = use_facet<np_t>(stream.getloc());
+
+ np.put(stream, wcout, ' ', static_cast<long>(10));
+ VERIFY( stream.str() == "10" );
+}
+#endif
+
+int main()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+ test01();
+#endif
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/8.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/8.cc
new file mode 100644
index 000000000..499bee44c
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/8.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct Ctype: std::ctype<char>
+{
+ char
+ do_widen(char c) const
+ { return 'A' + c % 26; }
+
+ const char*
+ do_widen(const char* lo, const char* hi, char* to) const
+ {
+ for (; lo != hi; *to++ = Ctype::do_widen(*lo++));
+ return hi;
+ }
+};
+
+// See http://gcc.gnu.org/ml/libstdc++/2003-11/msg00154.html
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss;
+ oss.imbue(locale(locale::classic(), new Ctype));
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ const string empty;
+ string result;
+ long inum = 123;
+ double fnum = 123.456;
+
+ np.put(oss.rdbuf(), oss, '+', inum);
+ result = oss.str();
+ VERIFY( result == "XYZ" );
+
+ oss.clear();
+ oss.str(empty);
+ np.put(oss.rdbuf(), oss, '+', fnum);
+ result = oss.str();
+ VERIFY( result == "XYZ.ABC" );
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/9.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/9.cc
new file mode 100644
index 000000000..2875c1f18
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/9.cc
@@ -0,0 +1,61 @@
+// 2004-08-22 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// According to 22.2.2.2.2, p23 and the resolution of DR 359
+// val must be casted to a signed type: this can be revealed
+// by ios_base::showpos, which is effective only for signed
+// types (also see libstdc++/15565 about this).
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const string empty;
+
+ // cache the num_put facet
+ ostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
+
+ bool b = true;
+ np.put(oss.rdbuf(), oss, ' ', b);
+ VERIFY( oss.str() == "1" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, ' ', b);
+ VERIFY( oss.str() == "+1" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/9780-2.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/9780-2.cc
new file mode 100644
index 000000000..a667c6b54
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/9780-2.cc
@@ -0,0 +1,81 @@
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "es_ES" }
+
+// Copyright (C) 2004-2012 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// Make sure that formatted output uses the locale in the output stream.
+using namespace std;
+locale l1 = locale("de_DE");
+const num_put<char>& np = use_facet<num_put<char> >(l1);
+const numpunct<char>& npunct = use_facet<numpunct<char> >(l1);
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ locale l2 = locale("C");
+ const numpunct<char>& npunct2 = use_facet<numpunct<char> >(l2);
+ char c = npunct2.thousands_sep();
+ string s = npunct2.grouping();
+
+ ostringstream oss;
+ oss.imbue(l2);
+
+ long l = 1234567890;
+ np.put(oss.rdbuf(), oss, ' ', l);
+ string res = oss.str();
+
+ VERIFY( res == "1234567890" );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ locale l2 = locale("es_ES");
+ const numpunct<char>& npunct3 = use_facet<numpunct<char> >(l2);
+ char c = npunct3.thousands_sep();
+ string s = npunct3.grouping();
+
+ ostringstream oss;
+ oss.imbue(l2);
+
+ long l = 1234567890;
+ np.put(oss.rdbuf(), oss, ' ', l);
+ string res = oss.str();
+
+ if (!s.empty())
+ VERIFY( res == "1.234.567.890" );
+ else
+ VERIFY( res == "1234567890" );
+}
+
+int main()
+{
+ // Sanity check.
+ char c = npunct.thousands_sep();
+ string s = npunct.grouping();
+
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_env.cc
new file mode 100644
index 000000000..8ed81754e
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_env.cc
@@ -0,0 +1,59 @@
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_HK" }
+// { dg-require-namedlocale "es_ES" }
+
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.4.1.1 collate members
+
+#include <testsuite_hooks.h>
+
+#define main discard_main_1
+#include "1.cc"
+#undef main
+
+#define main discard_main_2
+#include "2.cc"
+#undef main
+
+#define main discard_main_3
+#include "3.cc"
+#undef main
+
+#define main discard_main_4
+#include "4.cc"
+#undef main
+
+#define main discard_main_5
+#include "5.cc"
+#undef main
+
+int main()
+{
+ using namespace __gnu_test;
+ func_callback two;
+ two.push_back(&test01);
+ two.push_back(&test02);
+ two.push_back(&test03);
+ two.push_back(&test04);
+ two.push_back(&test05);
+ run_tests_wrapped_env("de_DE", "LANG", two);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_locale.cc
new file mode 100644
index 000000000..867992f79
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/wrapped_locale.cc
@@ -0,0 +1,60 @@
+// { dg-require-namedlocale "ja_JP.eucjp" }
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_HK" }
+// { dg-require-namedlocale "es_ES" }
+
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.4.1.1 collate members
+
+#include <testsuite_hooks.h>
+
+#define main discard_main_1
+#include "1.cc"
+#undef main
+
+#define main discard_main_2
+#include "2.cc"
+#undef main
+
+#define main discard_main_3
+#include "3.cc"
+#undef main
+
+#define main discard_main_4
+#include "4.cc"
+#undef main
+
+#define main discard_main_5
+#include "5.cc"
+#undef main
+
+int main()
+{
+ using namespace __gnu_test;
+ func_callback two;
+ two.push_back(&test01);
+ two.push_back(&test02);
+ two.push_back(&test03);
+ two.push_back(&test04);
+ two.push_back(&test05);
+ run_tests_wrapped_locale("ja_JP.eucjp", two);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc
new file mode 100644
index 000000000..4b596d5b9
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc
@@ -0,0 +1,163 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_de = locale("de_DE");
+ VERIFY( loc_c != loc_de );
+
+ // cache the numpunct facets
+ const numpunct<wchar_t>& numpunct_de = use_facet<numpunct<wchar_t> >(loc_de);
+
+ // sanity check the data is correct.
+ const wstring empty;
+ wstring result1;
+ wstring result2;
+
+ bool b1 = true;
+ bool b0 = false;
+ unsigned long ul1 = 1294967294;
+ double d1 = 1.7976931348623157e+308;
+ double d2 = 2.2250738585072014e-308;
+ long double ld1 = 1.7976931348623157e+308;
+ long double ld2 = 2.2250738585072014e-308;
+ const void* cv = &ld1;
+
+ // cache the num_put facet
+ wostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ // bool, simple
+ iterator_type os_it00 = oss.rdbuf();
+ np.put(os_it00, oss, L'+', b1);
+ result1 = oss.str();
+ VERIFY( result1 == L"1" );
+
+ oss.str(empty);
+ np.put(oss.rdbuf(), oss, L'+', b0);
+ result2 = oss.str();
+ VERIFY( result2 == L"0" );
+
+ // ... and one that does
+ oss.imbue(loc_de);
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', ul1);
+ result1 = oss.str();
+ VERIFY( result1 == L"1.294.967.294+++++++" );
+
+ // double
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', d1);
+ result1 = oss.str();
+ VERIFY( result1 == L"1,79769e+308++++++++" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', d2);
+ result1 = oss.str();
+ VERIFY( result1 == L"++++++++2,22507e-308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ oss.setf(ios_base::scientific, ios_base::floatfield);
+ np.put(oss.rdbuf(), oss, L'+', d2);
+ result2 = oss.str();
+ VERIFY( result2 == L"+++++++2,225074e-308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.precision(10);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ oss.setf(ios_base::scientific, ios_base::floatfield);
+ oss.setf(ios_base::uppercase);
+ np.put(oss.rdbuf(), oss, L'+', d2);
+ result1 = oss.str();
+ VERIFY( result1 == L"+++2,2250738585E-308" );
+
+ // long double
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'+', ld1);
+ result1 = oss.str();
+ VERIFY( result1 == L"1,7976931349E+308" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.precision(0);
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ np.put(oss.rdbuf(), oss, L'+', ld2);
+ result1 = oss.str();
+ VERIFY( result1 == L"0" );
+
+ // const void*
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'+', cv);
+ result1 = oss.str();
+ // No grouping characters.
+ VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
+ result1.size(),
+ numpunct_de.decimal_point()) );
+ // Should contain an 'x'.
+ VERIFY( result1.find(L'x') == 1 );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ long long ll1 = 9223372036854775807LL;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'+', ll1);
+ result1 = oss.str();
+ VERIFY( result1 == L"9.223.372.036.854.775.807" );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc
new file mode 100644
index 000000000..59d5033bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc
@@ -0,0 +1,67 @@
+// 2005-07-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc_c = locale::classic();
+
+ const wstring empty;
+
+ wstringstream ss;
+ ss.imbue(loc_c);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(ss.getloc());
+
+ long l = -1;
+ unsigned long ul = 0;
+
+ ss.setf(ios::hex, ios::basefield);
+ np.put(ss.rdbuf(), ss, L'+', l);
+ VERIFY( ss.str() != L"1" );
+ ss >> ul;
+ VERIFY( ul == static_cast<unsigned long>(l) );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ long long ll = -1LL;
+ unsigned long long ull = 0ULL;
+
+ ss.str(empty);
+ ss.clear();
+ np.put(ss.rdbuf(), ss, L'+', ll);
+ VERIFY( ss.str() != L"1" );
+ ss >> ull;
+ VERIFY( ull == static_cast<unsigned long long>(ll) );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/11.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/11.cc
new file mode 100644
index 000000000..91103dcb1
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/11.cc
@@ -0,0 +1,70 @@
+// 2006-10-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct Punct1: std::numpunct<wchar_t>
+{ std::string do_grouping() const { return "\003\002\001"; } };
+
+struct Punct2: std::numpunct<wchar_t>
+{ std::string do_grouping() const { return "\001\003"; } };
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss1, oss2;
+ wstring result1, result2, result3;
+ const wstring empty;
+
+ oss1.imbue(locale(oss1.getloc(), new Punct1));
+ oss2.imbue(locale(oss2.getloc(), new Punct2));
+ const num_put<wchar_t>& ng1 = use_facet<num_put<wchar_t> >(oss1.getloc());
+ const num_put<wchar_t>& ng2 = use_facet<num_put<wchar_t> >(oss2.getloc());
+
+ long l1 = 12345678l;
+ double d1 = 1234567.0;
+ double d2 = 123456.0;
+
+ ng1.put(oss1.rdbuf(), oss1, L'+', l1);
+ result1 = oss1.str();
+ VERIFY( result1 == L"1,2,3,45,678" );
+
+ oss2.precision(1);
+ oss2.setf(ios_base::fixed, ios_base::floatfield);
+ ng2.put(oss2.rdbuf(), oss2, L'+', d1);
+ result2 = oss2.str();
+ VERIFY( result2 == L"123,456,7.0" );
+
+ oss2.str(empty);
+ ng2.put(oss2.rdbuf(), oss2, L'+', d2);
+ result3 = oss2.str();
+ VERIFY( result3 == L"12,345,6.0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/12.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/12.cc
new file mode 100644
index 000000000..0f16eac4a
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/12.cc
@@ -0,0 +1,63 @@
+// 2007-11-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00074.html
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss1, oss2, oss3;
+ const num_put<wchar_t>& np1 = use_facet<num_put<wchar_t> >(oss1.getloc());
+ const num_put<wchar_t>& np2 = use_facet<num_put<wchar_t> >(oss2.getloc());
+ const num_put<wchar_t>& np3 = use_facet<num_put<wchar_t> >(oss3.getloc());
+
+ wstring result1, result2, result3;
+
+ long int li1 = 0;
+ long int li2 = 5;
+ double d1 = 0.0;
+
+ oss1.setf(ios_base::showpos);
+ np1.put(oss1.rdbuf(), oss1, L'*', li1);
+ result1 = oss1.str();
+ VERIFY( result1 == L"+0" );
+
+ oss2.setf(ios_base::showpos);
+ np2.put(oss2.rdbuf(), oss2, L'*', li2);
+ result2 = oss2.str();
+ VERIFY( result2 == L"+5" );
+
+ oss3.setf(ios_base::showpos);
+ np3.put(oss3.rdbuf(), oss3, L'*', d1);
+ result3 = oss3.str();
+ VERIFY( result3 == L"+0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc
new file mode 100644
index 000000000..5b8301540
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc
@@ -0,0 +1,54 @@
+// 2004-04-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// On Solaris 9 and 32-bit Solaris 10/x86, this test crashes in libc. Inside
+// libstdc++, we call sprintf like so:
+// sprintf (buffer, "%.*f", 1000, 1.0)
+// which crashes.
+// { dg-do run { xfail { i?86-*-solaris2.9 || { i?86-*-solaris2.10 && ilp32 } } } }
+
+// libstdc++/14220
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss;
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ const int precision = 1000;
+
+ oss.precision(precision);
+ oss.setf(ios_base::fixed);
+ np.put(oss.rdbuf(), oss, L'+', 1.0);
+ const wstring result = oss.str();
+ VERIFY( result.size() == precision + 2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/15565.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/15565.cc
new file mode 100644
index 000000000..68ea2b782
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/15565.cc
@@ -0,0 +1,62 @@
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/15565
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const wstring empty;
+
+ // cache the num_put facet
+ wostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ unsigned long ul1 = 42UL;
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, L' ', ul1);
+ VERIFY( oss.str() == L"42" );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ unsigned long long ull1 = 31ULL;
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, L' ', ull1);
+ VERIFY( oss.str() == L"31" );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/2.cc
new file mode 100644
index 000000000..a535046b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/2.cc
@@ -0,0 +1,89 @@
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const wstring empty;
+ wstring result1;
+ wstring result2;
+
+ bool b1 = true;
+ bool b0 = false;
+ unsigned long ul1 = 1294967294;
+ unsigned long ul2 = 0;
+
+ // cache the num_put facet
+ wostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ // C
+ // bool, more twisted examples
+ oss.str(empty);
+ oss.width(20);
+ oss.setf(ios_base::right, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', b0);
+ result1 = oss.str();
+ VERIFY( result1 == L"+++++++++++++++++++0" );
+
+ oss.str(empty);
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ oss.setf(ios_base::boolalpha);
+ np.put(oss.rdbuf(), oss, L'+', b1);
+ result2 = oss.str();
+ VERIFY( result2 == L"true++++++++++++++++" );
+
+ // unsigned long, in a locale that does not group
+ oss.imbue(loc_c);
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'+', ul1);
+ result1 = oss.str();
+ VERIFY( result1 == L"1294967294" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', ul2);
+ result1 = oss.str();
+ VERIFY( result1 == L"0+++++++++++++++++++" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc
new file mode 100644
index 000000000..61ac1a164
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc
@@ -0,0 +1,80 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2005-04-08 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/20909
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const wstring empty;
+ wstring result;
+
+ wostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ double d0 = 2e20;
+ double d1 = -2e20;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'*', d0);
+ result = oss.str();
+ VERIFY( result == L"2e+20" );
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'*', d1);
+ result = oss.str();
+ VERIFY( result == L"-2e+20" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::uppercase);
+ np.put(oss.rdbuf(), oss, L'*', d0);
+ result = oss.str();
+ VERIFY( result == L"2E+20" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, L'*', d0);
+ result = oss.str();
+ VERIFY( result == L"+2E+20" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20914.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20914.cc
new file mode 100644
index 000000000..2013986c8
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20914.cc
@@ -0,0 +1,80 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2005-04-17 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/20914
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const wstring empty;
+ wstring result;
+
+ wostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ long l0 = -300000;
+ long l1 = 300;
+ double d0 = -300000;
+ double d1 = 300;
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'*', l0);
+ result = oss.str();
+ VERIFY( result == L"-300.000" );
+
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'*', d0);
+ result = oss.str();
+ VERIFY( result == L"-300.000" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, L'*', l1);
+ result = oss.str();
+ VERIFY( result == L"+300" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showpos);
+ np.put(oss.rdbuf(), oss, L'*', d1);
+ result = oss.str();
+ VERIFY( result == L"+300" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/23953.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/23953.cc
new file mode 100644
index 000000000..eed47ebe5
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/23953.cc
@@ -0,0 +1,75 @@
+// 2005-09-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+struct Punct1: numpunct<wchar_t>
+{ string do_grouping() const { return string(1, char(-1)); } };
+
+struct Punct2: numpunct<wchar_t>
+{ string do_grouping() const { return string("\002") + char(-1); } };
+
+struct Punct3: numpunct<wchar_t>
+{ string do_grouping() const { return string("\001\002") + char(-1); } };
+
+// libstdc++/23953
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss1, oss2, oss3;
+ wstring result1, result2, result3;
+
+ oss1.imbue(locale(oss1.getloc(), new Punct1));
+ oss2.imbue(locale(oss2.getloc(), new Punct2));
+ oss3.imbue(locale(oss3.getloc(), new Punct3));
+ const num_put<wchar_t>& ng1 = use_facet<num_put<wchar_t> >(oss1.getloc());
+ const num_put<wchar_t>& ng2 = use_facet<num_put<wchar_t> >(oss2.getloc());
+ const num_put<wchar_t>& ng3 = use_facet<num_put<wchar_t> >(oss3.getloc());
+
+ long l1 = 12345l;
+ long l2 = 12345678l;
+ double d1 = 1234567.0;
+
+ ng1.put(oss1.rdbuf(), oss1, L'+', l1);
+ result1 = oss1.str();
+ VERIFY( result1 == L"12345" );
+
+ ng2.put(oss2.rdbuf(), oss2, L'+', l2);
+ result2 = oss2.str();
+ VERIFY( result2 == L"123456,78" );
+
+ oss3.precision(1);
+ oss3.setf(ios_base::fixed, ios_base::floatfield);
+ ng3.put(oss3.rdbuf(), oss3, L'+', d1);
+ result3 = oss3.str();
+ VERIFY( result3 == L"1234,56,7.0" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/3.cc
new file mode 100644
index 000000000..47ed26cd2
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/3.cc
@@ -0,0 +1,74 @@
+// { dg-require-namedlocale "en_HK" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+ locale loc_hk = locale("en_HK");
+ VERIFY( loc_c != loc_hk );
+
+ // sanity check the data is correct.
+ const wstring empty;
+ wstring result1;
+ wstring result2;
+
+ long l1 = 2147483647;
+ long l2 = -2147483647;
+
+ // cache the num_put facet
+ wostringstream oss;
+ oss.imbue(loc_hk);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ // HK
+ // long, in a locale that expects grouping
+ oss.str(empty);
+ oss.clear();
+ np.put(oss.rdbuf(), oss, L'+', l1);
+ result1 = oss.str();
+ VERIFY( result1 == L"2,147,483,647" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.width(20);
+ oss.setf(ios_base::left, ios_base::adjustfield);
+ np.put(oss.rdbuf(), oss, L'+', l2);
+ result1 = oss.str();
+ VERIFY( result1 == L"-2,147,483,647++++++" );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38196.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38196.cc
new file mode 100644
index 000000000..76cb5e028
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38196.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+class my_punct : public std::numpunct<wchar_t>
+{
+protected:
+ std::wstring do_falsename() const { return L"-no-"; }
+};
+
+// libstdc++/38196
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ wostringstream oss1, oss2, oss3, oss4;
+ wstring result1, result2, result3, result4;
+
+ oss1.imbue(locale(oss1.getloc(), new my_punct));
+ oss2.imbue(locale(oss2.getloc(), new my_punct));
+ oss3.imbue(locale(oss3.getloc(), new my_punct));
+ oss4.imbue(locale(oss4.getloc(), new my_punct));
+ const num_put<wchar_t>& ng1 = use_facet<num_put<wchar_t> >(oss1.getloc());
+ const num_put<wchar_t>& ng2 = use_facet<num_put<wchar_t> >(oss2.getloc());
+ const num_put<wchar_t>& ng3 = use_facet<num_put<wchar_t> >(oss3.getloc());
+ const num_put<wchar_t>& ng4 = use_facet<num_put<wchar_t> >(oss4.getloc());
+
+ oss1.width(6);
+ oss1.setf(ios_base::boolalpha);
+ ng1.put(oss1.rdbuf(), oss1, L'*', false);
+ result1 = oss1.str();
+ VERIFY( result1 == L"**-no-" );
+
+ oss2.width(6);
+ oss2.setf(ios_base::right, ios_base::adjustfield);
+ oss2.setf(ios_base::boolalpha);
+ ng2.put(oss2.rdbuf(), oss2, L'*', false);
+ result2 = oss2.str();
+ VERIFY( result2 == L"**-no-" );
+
+ oss3.width(6);
+ oss3.setf(ios_base::internal, ios_base::adjustfield);
+ oss3.setf(ios_base::boolalpha);
+ ng3.put(oss3.rdbuf(), oss3, L'*', false);
+ result3 = oss3.str();
+ VERIFY( result3 == L"**-no-" );
+
+ oss4.width(6);
+ oss4.setf(ios_base::left, ios_base::adjustfield);
+ oss4.setf(ios_base::boolalpha);
+ ng4.put(oss4.rdbuf(), oss4, L'*', false);
+ result4 = oss4.str();
+ VERIFY( result4 == L"-no-**" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38210.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38210.cc
new file mode 100644
index 000000000..5b456d1fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38210.cc
@@ -0,0 +1,68 @@
+// Copyright (C) 2008, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/38210
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ wostringstream oss1, oss2, oss3, oss4;
+ wstring result1, result2, result3, result4;
+
+ const num_put<wchar_t>& ng1 = use_facet<num_put<wchar_t> >(oss1.getloc());
+ const num_put<wchar_t>& ng2 = use_facet<num_put<wchar_t> >(oss2.getloc());
+ const num_put<wchar_t>& ng3 = use_facet<num_put<wchar_t> >(oss3.getloc());
+ const num_put<wchar_t>& ng4 = use_facet<num_put<wchar_t> >(oss4.getloc());
+
+ void* p = (void*)0x1;
+
+ oss1.width(5);
+ ng1.put(oss1.rdbuf(), oss1, L'*', p);
+ result1 = oss1.str();
+ VERIFY( result1 == L"**0x1" );
+
+ oss2.width(5);
+ oss2.setf(ios_base::right, ios_base::adjustfield);
+ ng2.put(oss2.rdbuf(), oss2, L'*', p);
+ result2 = oss2.str();
+ VERIFY( result2 == L"**0x1" );
+
+ oss3.width(5);
+ oss3.setf(ios_base::internal, ios_base::adjustfield);
+ ng3.put(oss3.rdbuf(), oss3, L'*', p);
+ result3 = oss3.str();
+ VERIFY( result3 == L"0x**1" );
+
+ oss4.width(5);
+ oss4.setf(ios_base::left, ios_base::adjustfield);
+ ng4.put(oss4.rdbuf(), oss4, L'*', p);
+ result4 = oss4.str();
+ VERIFY( result4 == L"0x1**" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/4.cc
new file mode 100644
index 000000000..e276873c0
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/4.cc
@@ -0,0 +1,99 @@
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test04()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // Check num_put works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
+ typedef wstring::iterator iter_type;
+ typedef char_traits<wchar_t> traits;
+ typedef num_put<wchar_t, iter_type> num_put_type;
+ const locale loc_c = locale::classic();
+ const wstring str(L"1798 Lady Elgin");
+ const wstring x(18, L'x'); // have to have allocated wstring!
+ wstring res; // allow for "0x" + 16 hex digits (64-bit pointer)
+
+ wostringstream oss;
+ oss.imbue(locale(loc_c, new num_put_type));
+
+ // Iterator advanced, state, output.
+ const num_put_type& tp = use_facet<num_put_type>(oss.getloc());
+
+ // 01 put(long)
+ // 02 put(long double)
+ // 03 put(bool)
+ // 04 put(void*)
+
+ // 01 put(long)
+ const long l = 1798;
+ res = x;
+ iter_type ret1 = tp.put(res.begin(), oss, L' ', l);
+ wstring sanity1(res.begin(), ret1);
+ VERIFY( res == L"1798xxxxxxxxxxxxxx" );
+ VERIFY( sanity1 == L"1798" );
+
+ // 02 put(long double)
+ const long double ld = 1798.0;
+ res = x;
+ iter_type ret2 = tp.put(res.begin(), oss, L' ', ld);
+ wstring sanity2(res.begin(), ret2);
+ VERIFY( res == L"1798xxxxxxxxxxxxxx" );
+ VERIFY( sanity2 == L"1798" );
+
+ // 03 put(bool)
+ bool b = 1;
+ res = x;
+ iter_type ret3 = tp.put(res.begin(), oss, L' ', b);
+ wstring sanity3(res.begin(), ret3);
+ VERIFY( res == L"1xxxxxxxxxxxxxxxxx" );
+ VERIFY( sanity3 == L"1" );
+
+ b = 0;
+ res = x;
+ oss.setf(ios_base::boolalpha);
+ iter_type ret4 = tp.put(res.begin(), oss, L' ', b);
+ wstring sanity4(res.begin(), ret4);
+ VERIFY( res == L"falsexxxxxxxxxxxxx" );
+ VERIFY( sanity4 == L"false" );
+
+ // 04 put(void*)
+ oss.clear();
+ const void* cv = &ld;
+ res = x;
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type ret5 = tp.put(res.begin(), oss, L' ', cv);
+ wstring sanity5(res.begin(), ret5);
+ VERIFY( sanity5.size() );
+ VERIFY( sanity5[1] == L'x' );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/5.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/5.cc
new file mode 100644
index 000000000..42fee14ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/5.cc
@@ -0,0 +1,69 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Make sure that, in a locale that expects grouping, when showbase
+// is true, an hexadecimal or octal zero is correctly output (the case
+// of zero is special since there is no 0x, 0 respectively, prefix)
+void test05()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // A locale that expects grouping.
+ locale loc_de = locale("de_DE");
+
+ const wstring empty;
+ wstring result;
+
+ wostringstream oss;
+ oss.imbue(loc_de);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ long l = 0;
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showbase);
+ oss.setf(ios::hex, ios::basefield);
+ np.put(oss.rdbuf(), oss, L'+', l);
+ result = oss.str();
+ VERIFY( result == L"0" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios::showbase);
+ oss.setf(ios::oct, ios::basefield);
+ np.put(oss.rdbuf(), oss, L'+', l);
+ result = oss.str();
+ VERIFY( result == L"0" );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/6.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/6.cc
new file mode 100644
index 000000000..da811c65d
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/6.cc
@@ -0,0 +1,55 @@
+// 2003-02-05 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9548 and DR 231
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream woss1, woss2;
+ const num_put<wchar_t>& np1 = use_facet<num_put<wchar_t> >(woss1.getloc());
+ const num_put<wchar_t>& np2 = use_facet<num_put<wchar_t> >(woss2.getloc());
+
+ wstring result1, result2;
+
+ woss1.precision(-1);
+ woss1.setf(ios_base::fixed, ios_base::floatfield);
+ np1.put(woss1.rdbuf(), woss1, L'+', 30.5);
+ result1 = woss1.str();
+ VERIFY( result1 == L"30.500000" );
+
+ woss2.precision(0);
+ woss2.setf(ios_base::scientific, ios_base::floatfield);
+ np2.put(woss2.rdbuf(), woss2, L'+', 1.0);
+ result2 = woss2.str();
+ VERIFY( result2 == L"1e+00" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/7.cc
new file mode 100644
index 000000000..2d98af1eb
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/7.cc
@@ -0,0 +1,44 @@
+// 2003-06-30 peturr02@ru.is
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <iostream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// libstdc++/9828
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef num_put<wchar_t> npw_t;
+
+ wostringstream stream;
+ const npw_t& npw = use_facet<npw_t>(stream.getloc());
+
+ npw.put(stream, cout, L' ', static_cast<long>(10));
+ VERIFY( stream.str() == L"10" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/8.cc
new file mode 100644
index 000000000..f9fde15cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/8.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct Ctype: std::ctype<wchar_t>
+{
+ wchar_t
+ do_widen(char c) const
+ { return L'A' + c % 26; }
+
+ const char*
+ do_widen(const char* lo, const char* hi, wchar_t* to) const
+ {
+ for (; lo != hi; *to++ = Ctype::do_widen(*lo++));
+ return hi;
+ }
+};
+
+// See http://gcc.gnu.org/ml/libstdc++/2003-11/msg00154.html
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss;
+ oss.imbue(locale(locale::classic(), new Ctype));
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ const wstring empty;
+ wstring result;
+ long inum = 123;
+ double fnum = 123.456;
+
+ np.put(oss.rdbuf(), oss, L'+', inum);
+ result = oss.str();
+ VERIFY( result == L"XYZ" );
+
+ oss.clear();
+ oss.str(empty);
+ np.put(oss.rdbuf(), oss, L'+', fnum);
+ result = oss.str();
+ VERIFY( result == L"XYZ.ABC" );
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/9.cc
new file mode 100644
index 000000000..a7b70377a
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/9.cc
@@ -0,0 +1,61 @@
+// 2004-08-22 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.2.2.1 num_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// According to 22.2.2.2.2, p23 and the resolution of DR 359
+// val must be casted to a signed type: this can be revealed
+// by ios_base::showpos, which is effective only for signed
+// types (also see libstdc++/15565 about this).
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // basic construction
+ locale loc_c = locale::classic();
+
+ // sanity check the data is correct.
+ const wstring empty;
+
+ // cache the num_put facet
+ wostringstream oss;
+ oss.imbue(loc_c);
+ const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
+
+ bool b = true;
+ np.put(oss.rdbuf(), oss, L' ', b);
+ VERIFY( oss.str() == L"1" );
+
+ oss.str(empty);
+ oss.clear();
+ oss.setf(ios_base::showpos);
+ np.put(oss.rdbuf(), oss, L' ', b);
+ VERIFY( oss.str() == L"+1" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_env.cc
new file mode 100644
index 000000000..bb6bec858
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_env.cc
@@ -0,0 +1,58 @@
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_HK" }
+
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.4.1.1 collate members
+
+#include <testsuite_hooks.h>
+
+#define main discard_main_1
+#include "1.cc"
+#undef main
+
+#define main discard_main_2
+#include "2.cc"
+#undef main
+
+#define main discard_main_3
+#include "3.cc"
+#undef main
+
+#define main discard_main_4
+#include "4.cc"
+#undef main
+
+#define main discard_main_5
+#include "5.cc"
+#undef main
+
+int main()
+{
+ using namespace __gnu_test;
+ func_callback two;
+ two.push_back(&test01);
+ two.push_back(&test02);
+ two.push_back(&test03);
+ two.push_back(&test04);
+ two.push_back(&test05);
+ run_tests_wrapped_env("de_DE", "LANG", two);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_locale.cc
new file mode 100644
index 000000000..d85c72a97
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_locale.cc
@@ -0,0 +1,59 @@
+// { dg-require-namedlocale "ja_JP.eucjp" }
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_HK" }
+
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2005, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 22.2.4.1.1 collate members
+
+#include <testsuite_hooks.h>
+
+#define main discard_main_1
+#include "1.cc"
+#undef main
+
+#define main discard_main_2
+#include "2.cc"
+#undef main
+
+#define main discard_main_3
+#include "3.cc"
+#undef main
+
+#define main discard_main_4
+#include "4.cc"
+#undef main
+
+#define main discard_main_5
+#include "5.cc"
+#undef main
+
+int main()
+{
+ using namespace __gnu_test;
+ func_callback two;
+ two.push_back(&test01);
+ two.push_back(&test02);
+ two.push_back(&test03);
+ two.push_back(&test04);
+ two.push_back(&test05);
+ run_tests_wrapped_locale("ja_JP.eucjp", two);
+ return 0;
+}