diff options
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/manipulators')
14 files changed, 1008 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/1.cc new file mode 100644 index 000000000..eb3fa3576 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/1.cc @@ -0,0 +1,96 @@ +// 981027 ncm work with libstdc++v3 + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2009 +// 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 <iomanip> +#include <testsuite_hooks.h> + +struct MyNP : std::numpunct<char> +{ + std::string do_truename() const; + std::string do_falsename() const; +}; + +std::string +MyNP::do_truename() const +{ + std::string s("yea"); + return s; +} + +std::string +MyNP::do_falsename() const +{ + std::string s("nay"); + return s; +} + +void +test01() +{ + bool test __attribute__((unused)) = true; + const char lit[] = "1 0\n" + "true false\n" + ": true:\n" + ":true :\n" + ": false:\n" + ": 1:\n" + ":1 :\n" + ": 0:\n" + "yea nay\n" + ": yea:\n" + ":yea :\n" + ": nay:\n"; + + std::ostringstream oss; + oss << true << " " << false << std::endl; + oss << std::boolalpha; + oss << true << " " << false << std::endl; + + oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl; + oss << ":" << std::setw(6) << std::left << true << ":" << std::endl; + oss << ":" << std::setw(6) << std::right << false << ":" << std::endl; + oss << std::noboolalpha; + oss << ":" << std::setw(3) << std::internal << true << ":" << std::endl; + oss << ":" << std::setw(3) << std::left << true << ":" << std::endl; + oss << ":" << std::setw(3) << std::right << false << ":" << std::endl; + + std::locale loc = std::locale(std::locale::classic(), new MyNP); + oss.imbue(loc); + + oss << std::boolalpha; + oss << true << " " << false << std::endl; + + oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl; + oss << ":" << std::setw(6) << std::left << true << ":" << std::endl; + oss << ":" << std::setw(6) << std::right << false << ":" << std::endl; + + VERIFY( oss.good() ); + VERIFY( oss.str() == lit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/2.cc new file mode 100644 index 000000000..e533cebfe --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/2.cc @@ -0,0 +1,51 @@ +// Copyright (C) 1997, 1998, 1999, 2002, 2004, 2009 +// 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 <iomanip> +#include <testsuite_hooks.h> + +void test02() +{ + bool test __attribute__((unused)) = true; + const std::string str_blank; + std::string str_tmp; + std::stringbuf strbuf; + std::ostream o(&strbuf); + + o << std::setw(6) << std::right << "san"; + VERIFY( strbuf.str() == " san" ); + strbuf.str(str_blank); + + o << std::setw(6) << std::internal << "fran"; + VERIFY( strbuf.str() == " fran" ); + strbuf.str(str_blank); + + o << std::setw(6) << std::left << "cisco"; + VERIFY( strbuf.str() == "cisco " ); + strbuf.str(str_blank); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/1.cc new file mode 100644 index 000000000..7a0d0024d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/1.cc @@ -0,0 +1,93 @@ +// Copyright (C) 2004, 2009 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 <iomanip> +#include <testsuite_hooks.h> + +struct MyNP : std::numpunct<wchar_t> +{ + std::wstring do_truename() const; + std::wstring do_falsename() const; +}; + +std::wstring +MyNP::do_truename() const +{ + std::wstring s(L"yea"); + return s; +} + +std::wstring +MyNP::do_falsename() const +{ + std::wstring s(L"nay"); + return s; +} + +void +test01() +{ + bool test __attribute__((unused)) = true; + const wchar_t lit[] = L"1 0\n" + L"true false\n" + L": true:\n" + L":true :\n" + L": false:\n" + L": 1:\n" + L":1 :\n" + L": 0:\n" + L"yea nay\n" + L": yea:\n" + L":yea :\n" + L": nay:\n"; + + std::wostringstream oss; + oss << true << L" " << false << std::endl; + oss << std::boolalpha; + oss << true << L" " << false << std::endl; + + oss << L":" << std::setw(6) << std::internal << true << L":" << std::endl; + oss << L":" << std::setw(6) << std::left << true << L":" << std::endl; + oss << L":" << std::setw(6) << std::right << false << L":" << std::endl; + oss << std::noboolalpha; + oss << L":" << std::setw(3) << std::internal << true << L":" << std::endl; + oss << L":" << std::setw(3) << std::left << true << L":" << std::endl; + oss << L":" << std::setw(3) << std::right << false << L":" << std::endl; + + std::locale loc = std::locale(std::locale::classic(), new MyNP); + oss.imbue(loc); + + oss << std::boolalpha; + oss << true << L" " << false << std::endl; + + oss << L":" << std::setw(6) << std::internal << true << L":" << std::endl; + oss << L":" << std::setw(6) << std::left << true << L":" << std::endl; + oss << L":" << std::setw(6) << std::right << false << L":" << std::endl; + + VERIFY( oss.good() ); + VERIFY( oss.str() == lit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/2.cc new file mode 100644 index 000000000..49ca6e062 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/adjustfield/wchar_t/2.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2004, 2009 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 <iomanip> +#include <testsuite_hooks.h> + +void test02() +{ + bool test __attribute__((unused)) = true; + const std::wstring str_blank; + std::wstring str_tmp; + std::wstringbuf strbuf; + std::wostream o(&strbuf); + + o << std::setw(6) << std::right << L"san"; + VERIFY( strbuf.str() == L" san" ); + strbuf.str(str_blank); + + o << std::setw(6) << std::internal << L"fran"; + VERIFY( strbuf.str() == L" fran" ); + strbuf.str(str_blank); + + o << std::setw(6) << std::left << L"cisco"; + VERIFY( strbuf.str() == L"cisco " ); + strbuf.str(str_blank); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/basefield/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/basefield/char/1.cc new file mode 100644 index 000000000..a0c1bd24f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/basefield/char/1.cc @@ -0,0 +1,117 @@ +// 981027 ncm work with libstdc++v3 + +// Copyright (C) 1997, 1998, 1999, 2002, 2009 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 <iomanip> +#include <testsuite_hooks.h> + +struct MyNP : std::numpunct<char> +{ + std::string do_grouping() const; + char do_thousands_sep() const; +}; + +std::string +MyNP::do_grouping() const +{ + std::string s("\3"); + return s; +} + +char +MyNP::do_thousands_sep() const +{ return ' '; } + +void test01() +{ + bool test __attribute__((unused)) = true; + const char lit[] = "0123 456\n" + ": 01 234 567:\n" + ":0123 456 :\n" + ": 012 345:\n" + ": 01 234:\n" + ":0726 746 425:\n" + ":04 553 207 :\n" + ": 0361 100:\n" + ": 0173:\n" + "0x12 345 678\n" + "|0x000012 345 678|\n" + "|0x12 345 6780000|\n" + "|00000x12 345 678|\n" + "|0x000012 345 678|\n"; + + std::ostringstream oss; + oss.imbue(std::locale(std::locale(), new MyNP)); + + // Octals + oss << std::oct << std::showbase; + oss << 0123456l << std::endl; + + oss << ":" << std::setw(11); + oss << 01234567l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::left; + oss << 0123456l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::right; + oss << 012345l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::internal; + oss << 01234l << ":" << std::endl; + + oss << ":" << std::setw(11); + oss << 123456789l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::left; + oss << 1234567l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::right; + oss << 123456l << ":" << std::endl; + + oss << ":" << std::setw(11) << std::internal; + oss << 123l << ":" << std::endl; + + // Hexadecimals + oss << std::hex << std::setfill('0'); + oss << 0x12345678l << std::endl; + + oss << "|" << std::setw(16); + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::left; + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::right; + oss << 0x12345678l << "|" << std::endl; + + oss << "|" << std::setw(16) << std::internal; + oss << 0x12345678l << "|" << std::endl; + + VERIFY( oss.good() ); + VERIFY( oss.str() == lit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/basefield/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/basefield/wchar_t/1.cc new file mode 100644 index 000000000..03f67102d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/basefield/wchar_t/1.cc @@ -0,0 +1,115 @@ +// Copyright (C) 2004, 2009 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 <iomanip> +#include <testsuite_hooks.h> + +struct MyNP : std::numpunct<wchar_t> +{ + std::string do_grouping() const; + wchar_t do_thousands_sep() const; +}; + +std::string +MyNP::do_grouping() const +{ + std::string s("\3"); + return s; +} + +wchar_t +MyNP::do_thousands_sep() const +{ return L' '; } + +void test01() +{ + bool test __attribute__((unused)) = true; + const wchar_t lit[] = L"0123 456\n" + L": 01 234 567:\n" + L":0123 456 :\n" + L": 012 345:\n" + L": 01 234:\n" + L":0726 746 425:\n" + L":04 553 207 :\n" + L": 0361 100:\n" + L": 0173:\n" + L"0x12 345 678\n" + L"|0x000012 345 678|\n" + L"|0x12 345 6780000|\n" + L"|00000x12 345 678|\n" + L"|0x000012 345 678|\n"; + + std::wostringstream oss; + oss.imbue(std::locale(std::locale(), new MyNP)); + + // Octals + oss << std::oct << std::showbase; + oss << 0123456l << std::endl; + + oss << L":" << std::setw(11); + oss << 01234567l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::left; + oss << 0123456l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::right; + oss << 012345l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::internal; + oss << 01234l << L":" << std::endl; + + oss << L":" << std::setw(11); + oss << 123456789l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::left; + oss << 1234567l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::right; + oss << 123456l << L":" << std::endl; + + oss << L":" << std::setw(11) << std::internal; + oss << 123l << L":" << std::endl; + + // Hexadecimals + oss << std::hex << std::setfill(L'0'); + oss << 0x12345678l << std::endl; + + oss << L"|" << std::setw(16); + oss << 0x12345678l << L"|" << std::endl; + + oss << L"|" << std::setw(16) << std::left; + oss << 0x12345678l << L"|" << std::endl; + + oss << L"|" << std::setw(16) << std::right; + oss << 0x12345678l << L"|" << std::endl; + + oss << L"|" << std::setw(16) << std::internal; + oss << 0x12345678l << L"|" << std::endl; + + VERIFY( oss.good() ); + VERIFY( oss.str() == lit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/char/1.cc new file mode 100644 index 000000000..681bac56f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/char/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-namedlocale "de_DE@euro" } + +// 2010-03-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 <iomanip> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::locale loc_de = std::locale("de_DE@euro"); + + std::istringstream iss; + iss.imbue(loc_de); + + iss.str("7200000000,00 "); + + std::string str; + iss >> std::get_money(str); + + VERIFY( str == "720000000000" ); + VERIFY( iss.eof() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/wchar_t/1.cc new file mode 100644 index 000000000..a288f2e2b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_money/wchar_t/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-namedlocale "de_DE@euro" } + +// 2010-03-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 <iomanip> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::locale loc_de = std::locale("de_DE@euro"); + + std::wistringstream iss; + iss.imbue(loc_de); + + iss.str(L"7200000000,00 "); + + std::wstring str; + iss >> get_money(str); + + VERIFY( str == L"720000000000" ); + VERIFY( iss.eof() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/char/1.cc new file mode 100644 index 000000000..2e6775364 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/char/1.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-namedlocale "de_DE@euro" } + +// 2010-03-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 <iomanip> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::locale loc_de = std::locale("de_DE@euro"); + + std::ostringstream oss; + oss.imbue(loc_de); + + const std::string str("720000000000"); + oss << std::put_money(str); + + VERIFY( oss.str() == "7.200.000.000,00 " ); + VERIFY( oss.good() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/wchar_t/1.cc new file mode 100644 index 000000000..38348687a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_money/wchar_t/1.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-namedlocale "de_DE@euro" } + +// 2010-03-01 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 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 <iomanip> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::locale loc_de = std::locale("de_DE@euro"); + + std::wostringstream oss; + oss.imbue(loc_de); + + const std::wstring str(L"720000000000"); + oss << std::put_money(str); + + VERIFY( oss.str() == L"7.200.000.000,00 " ); + VERIFY( oss.good() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/standard/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/standard/char/1.cc new file mode 100644 index 000000000..ac7d9a0d8 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/standard/char/1.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2002, 2004, 2009 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/>. + +// 27.6.3 - Standard manipulators + +#include <sstream> +#include <iomanip> +#include <testsuite_hooks.h> + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + string s("john coltrane, a love supreme"); + istringstream iss(s); + ostringstream oss; + + // resetiosflags + resetiosflags(ios_base::boolalpha); + iss >> resetiosflags(ios_base::boolalpha); + VERIFY(iss.good()); + oss << resetiosflags(ios_base::boolalpha); + VERIFY(oss.good()); + + // setiosflags + setiosflags(ios_base::skipws); + iss >> setiosflags(ios_base::skipws); + VERIFY(iss.good()); + oss << setiosflags(ios_base::skipws); + VERIFY(oss.good()); + + // setbase + setbase(8); + iss >> setbase(8); + VERIFY(iss.good()); + oss << setbase(8); + VERIFY(oss.good()); + + // setfil + setfill('a'); + iss >> setfill('a'); + VERIFY(iss.good()); + oss << setfill('a'); + VERIFY(oss.good()); + + // setprecision + setprecision(4); + iss >> setprecision(4); + VERIFY(iss.good()); + oss << setprecision(4); + VERIFY(oss.good()); + + // setprecision + setw(7); + iss >> setw(7); + VERIFY(iss.good()); + oss << setw(7); + VERIFY(oss.good()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/standard/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/standard/char/2.cc new file mode 100644 index 000000000..8eb4bede1 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/standard/char/2.cc @@ -0,0 +1,65 @@ +// { dg-options "-fno-implicit-templates" } + +// Copyright (C) 2001, 2002, 2004, 2009 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/>. + +// Some members need to be explicitly instantiated, so that users can build +// their own code with -fno-implicit-templates and not suffer from a zillion +// link errors. + +#include <istream> +#include <ostream> +#include <sstream> +#include <iomanip> +#include <testsuite_hooks.h> + +// PR libstdc++/3829 +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + string x (" this is text"); + istringstream sin(x); + ostringstream sout; + + // same order as in bits/std_iomanip.h + sin >> resetiosflags(ios_base::dec) + >> setiosflags(ios_base::dec) + >> setbase(ios_base::dec) + >> setfill('c') + >> setprecision(5) + >> setw(20) + >> ws; + VERIFY(sin.good()); + + sout << resetiosflags(ios_base::dec) + << setiosflags(ios_base::dec) + << setbase(ios_base::dec) + << setfill('c') + << setprecision(5) + << setw(20) + << ends << flush << endl; + VERIFY(sout.good()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/1.cc new file mode 100644 index 000000000..d71b0cfe3 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/1.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2004, 2009 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/>. + +// 27.6.3 - Standard manipulators + +#include <sstream> +#include <iomanip> +#include <testsuite_hooks.h> + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstring s(L"john coltrane, a love supreme"); + wistringstream iss(s); + wostringstream oss; + + // resetiosflags + resetiosflags(ios_base::boolalpha); + iss >> resetiosflags(ios_base::boolalpha); + VERIFY(iss.good()); + oss << resetiosflags(ios_base::boolalpha); + VERIFY(oss.good()); + + // setiosflags + setiosflags(ios_base::skipws); + iss >> setiosflags(ios_base::skipws); + VERIFY(iss.good()); + oss << setiosflags(ios_base::skipws); + VERIFY(oss.good()); + + // setbase + setbase(8); + iss >> setbase(8); + VERIFY(iss.good()); + oss << setbase(8); + VERIFY(oss.good()); + + // setfil + setfill(L'a'); + iss >> setfill(L'a'); + VERIFY(iss.good()); + oss << setfill(L'a'); + VERIFY(oss.good()); + + // setprecision + setprecision(4); + iss >> setprecision(4); + VERIFY(iss.good()); + oss << setprecision(4); + VERIFY(oss.good()); + + // setprecision + setw(7); + iss >> setw(7); + VERIFY(iss.good()); + oss << setw(7); + VERIFY(oss.good()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/2.cc new file mode 100644 index 000000000..69f8e3ca9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/manipulators/standard/wchar_t/2.cc @@ -0,0 +1,65 @@ +// { dg-options "-fno-implicit-templates" } + +// Copyright (C) 2004, 2009 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/>. + +// Some members need to be explicitly instantiated, so that users can build +// their own code with -fno-implicit-templates and not suffer from a zillion +// link errors. + +#include <istream> +#include <ostream> +#include <sstream> +#include <iomanip> +#include <testsuite_hooks.h> + +// PR libstdc++/3829 +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + wstring x(L" this is text"); + wistringstream sin(x); + wostringstream sout; + + // same order as in bits/std_iomanip.h + sin >> resetiosflags(ios_base::dec) + >> setiosflags(ios_base::dec) + >> setbase(ios_base::dec) + >> setfill(L'c') + >> setprecision(5) + >> setw(20) + >> ws; + VERIFY(sin.good()); + + sout << resetiosflags(ios_base::dec) + << setiosflags(ios_base::dec) + << setbase(ios_base::dec) + << setfill(L'c') + << setprecision(5) + << setw(20) + << ends << flush << endl; + VERIFY(sout.good()); +} + +int +main() +{ + test01(); + return 0; +} |