From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- .../testsuite/22_locale/num_put/put/wchar_t/1.cc | 163 +++++++++++++++++++++ .../testsuite/22_locale/num_put/put/wchar_t/10.cc | 67 +++++++++ .../testsuite/22_locale/num_put/put/wchar_t/11.cc | 70 +++++++++ .../testsuite/22_locale/num_put/put/wchar_t/12.cc | 63 ++++++++ .../22_locale/num_put/put/wchar_t/14220.cc | 54 +++++++ .../22_locale/num_put/put/wchar_t/15565.cc | 62 ++++++++ .../testsuite/22_locale/num_put/put/wchar_t/2.cc | 89 +++++++++++ .../22_locale/num_put/put/wchar_t/20909.cc | 80 ++++++++++ .../22_locale/num_put/put/wchar_t/20914.cc | 80 ++++++++++ .../22_locale/num_put/put/wchar_t/23953.cc | 75 ++++++++++ .../testsuite/22_locale/num_put/put/wchar_t/3.cc | 74 ++++++++++ .../22_locale/num_put/put/wchar_t/38196.cc | 80 ++++++++++ .../22_locale/num_put/put/wchar_t/38210.cc | 68 +++++++++ .../testsuite/22_locale/num_put/put/wchar_t/4.cc | 99 +++++++++++++ .../testsuite/22_locale/num_put/put/wchar_t/5.cc | 69 +++++++++ .../testsuite/22_locale/num_put/put/wchar_t/6.cc | 55 +++++++ .../testsuite/22_locale/num_put/put/wchar_t/7.cc | 44 ++++++ .../testsuite/22_locale/num_put/put/wchar_t/8.cc | 67 +++++++++ .../testsuite/22_locale/num_put/put/wchar_t/9.cc | 61 ++++++++ .../22_locale/num_put/put/wchar_t/wrapped_env.cc | 58 ++++++++ .../num_put/put/wchar_t/wrapped_locale.cc | 59 ++++++++ 21 files changed, 1537 insertions(+) create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/10.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/11.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/12.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/15565.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20914.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/23953.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38196.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/38210.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/6.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/7.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/8.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/9.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_env.cc create mode 100644 libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/wrapped_locale.cc (limited to 'libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t') 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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +void test01() +{ + using namespace std; + typedef ostreambuf_iterator 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& numpunct_de = use_facet >(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& np = use_facet >(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::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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +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& np = use_facet >(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(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(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +struct Punct1: std::numpunct +{ std::string do_grouping() const { return "\003\002\001"; } }; + +struct Punct2: std::numpunct +{ 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& ng1 = use_facet >(oss1.getloc()); + const num_put& ng2 = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np1 = use_facet >(oss1.getloc()); + const num_put& np2 = use_facet >(oss2.getloc()); + const num_put& np3 = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +void test02() +{ + using namespace std; + typedef ostreambuf_iterator 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +using namespace std; + +struct Punct1: numpunct +{ string do_grouping() const { return string(1, char(-1)); } }; + +struct Punct2: numpunct +{ string do_grouping() const { return string("\002") + char(-1); } }; + +struct Punct3: numpunct +{ 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& ng1 = use_facet >(oss1.getloc()); + const num_put& ng2 = use_facet >(oss2.getloc()); + const num_put& ng3 = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +void test03() +{ + using namespace std; + typedef ostreambuf_iterator 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& np = use_facet >(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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +class my_punct : public std::numpunct +{ +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& ng1 = use_facet >(oss1.getloc()); + const num_put& ng2 = use_facet >(oss2.getloc()); + const num_put& ng3 = use_facet >(oss3.getloc()); + const num_put& ng4 = use_facet >(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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& ng1 = use_facet >(oss1.getloc()); + const num_put& ng2 = use_facet >(oss2.getloc()); + const num_put& ng3 = use_facet >(oss3.getloc()); + const num_put& ng4 = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +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 traits; + typedef num_put 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(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// libstdc++/9548 and DR 231 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wostringstream woss1, woss2; + const num_put& np1 = use_facet >(woss1.getloc()); + const num_put& np2 = use_facet >(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 +// . + +#include +#include +#include +#include + +// libstdc++/9828 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef num_put npw_t; + + wostringstream stream; + const npw_t& npw = use_facet(stream.getloc()); + + npw.put(stream, cout, L' ', static_cast(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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +struct Ctype: std::ctype +{ + 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.2.2.1 num_put members + +#include +#include +#include + +// 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& np = use_facet >(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 + +// 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 +// . + +// 22.2.4.1.1 collate members + +#include + +#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 + +// 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 +// . + +// 22.2.4.1.1 collate members + +#include + +#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; +} -- cgit v1.2.3