From 04fc13943f17cca7158731e464da904577ff6163 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 20 Feb 2002 21:06:42 +0000 Subject: [PATCH] money_put_members_char.cc: Fix. 2002-02-20 Benjamin Kosnik * testsuite/22_locale/money_put_members_char.cc: Fix. * testsuite/22_locale/money_put_members_wchar_t.cc: Fix. * testsuite/27_io/standard_manipulators.cc: New file. * testsuite/27_io/ios_manip_basefield.cc: Check results, now failing. * testsuite/27_io/ios_manip_fmtflags.cc: Use locale::classic(). From-SVN: r49910 --- libstdc++-v3/ChangeLog | 10 +++ .../22_locale/money_put_members_char.cc | 2 +- .../22_locale/money_put_members_wchar_t.cc | 2 +- .../testsuite/27_io/ios_manip_basefield.cc | 66 ++++++++------- .../testsuite/27_io/ios_manip_fmtflags.cc | 5 +- .../testsuite/27_io/standard_manipulators.cc | 84 +++++++++++++++++++ 6 files changed, 134 insertions(+), 35 deletions(-) create mode 100644 libstdc++-v3/testsuite/27_io/standard_manipulators.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c024609de8a..2e92e2d764e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2002-02-20 Benjamin Kosnik + + * testsuite/22_locale/money_put_members_char.cc: Fix. + * testsuite/22_locale/money_put_members_wchar_t.cc: Fix. + + * testsuite/27_io/standard_manipulators.cc: New file. + + * testsuite/27_io/ios_manip_basefield.cc: Check results, now failing. + * testsuite/27_io/ios_manip_fmtflags.cc: Use locale::classic(). + 2002-02-20 Danny Smith * config/os/mingw32/bits/ctype_noninline.h diff --git a/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc b/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc index 72915dbc07d..c894b1851ac 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put_members_char.cc @@ -315,7 +315,7 @@ struct My_money_io : public std::moneypunct pattern do_neg_format() const { - static pattern pat = { { symbol, space, sign, value } }; + pattern pat = { { symbol, space, sign, value } }; return pat; } }; diff --git a/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc index 0688a65e8d0..09feadd7a9d 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put_members_wchar_t.cc @@ -315,7 +315,7 @@ struct My_money_io : public std::moneypunct pattern do_neg_format() const { - static pattern pat = { { symbol, space, sign, value } }; + pattern pat = { { symbol, space, sign, value } }; return pat; } }; diff --git a/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc b/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc index 013a0153c72..e84d2e6705c 100644 --- a/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc +++ b/libstdc++-v3/testsuite/27_io/ios_manip_basefield.cc @@ -1,6 +1,6 @@ // 981027 ncm work with libstdc++v3 -// Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2002 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 @@ -27,7 +27,6 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include #include #include #include @@ -45,31 +44,36 @@ char MyNP::do_thousands_sep() const { return ' '; } int test01() { - std::cout.imbue(std::locale(std::locale(), new MyNP)); - std::cout << std::oct << std::showbase; - std::cout << -0123456l << std::endl; - - std::cout << ":" << std::setw(11); - std::cout << -01234567l << ":" << std::endl; - - std::cout << ":" << std::setw(11) << std::left; - std::cout << -0123456l << ":" << std::endl; - - std::cout << ":" << std::setw(11) << std::right; - std::cout << -012345l << ":" << std::endl; - - std::cout << ":" << std::setw(11) << std::internal; - std::cout << -01234l << ":" << std::endl; - - std::cout << std::hex; - std::cout << std::setfill('0'); - std::cout << std::internal; - std::cout << std::showbase; - std::cout << std::setw(16); - std::cout << 0x12345678l << std::endl; -#ifdef DEBUG_ASSERT - assert (std::cout.good()); -#endif + bool test = true; + const char lit[] = "-0 123 456\n:-01 234 567:\n:-0 123 456 :" + "\n: -012 345:\n:- 01 234:\n0x000012 345 678"; + std::ostringstream oss; + oss.imbue(std::locale(std::locale(), new MyNP)); + 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::hex; + oss << std::setfill('0'); + oss << std::internal; + oss << std::showbase; + oss << std::setw(16); + oss << 0x12345678l << std::endl; + + VERIFY( oss.good() ); + VERIFY( oss.str() == lit ); + return 0; } @@ -94,14 +98,13 @@ test02() VERIFY( strbuf.str() == "cisco " ); strbuf.str(str_blank); -#ifdef DEBUG_ASSERT - assert (test); -#endif + VERIFY( test ); return 0; } int -main() { +main() +{ test01(); test02(); return 0; @@ -116,3 +119,4 @@ main() { :- 01 234: 0x000012 345 678 */ + diff --git a/libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc b/libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc index 3af4d11f48d..64b1b85f6d2 100644 --- a/libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc +++ b/libstdc++-v3/testsuite/27_io/ios_manip_fmtflags.cc @@ -1,6 +1,7 @@ // 981027 ncm work with libstdc++v3 -// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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 @@ -69,7 +70,7 @@ test01() 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(), new MyNP); + std::locale loc = std::locale (std::locale::classic(), new MyNP); oss.imbue(loc); oss << std::boolalpha; diff --git a/libstdc++-v3/testsuite/27_io/standard_manipulators.cc b/libstdc++-v3/testsuite/27_io/standard_manipulators.cc new file mode 100644 index 00000000000..71822372fc8 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/standard_manipulators.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2002 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.6.3 - Standard manipulators + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test = 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; +} -- 2.30.2