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. --- .../inserters_arithmetic/wchar_t/1.cc | 185 +++++++++++++++++++++ .../inserters_arithmetic/wchar_t/2.cc | 54 ++++++ .../inserters_arithmetic/wchar_t/3.cc | 65 ++++++++ .../inserters_arithmetic/wchar_t/31031.cc | 51 ++++++ .../inserters_arithmetic/wchar_t/4.cc | 47 ++++++ .../inserters_arithmetic/wchar_t/4402.cc | 72 ++++++++ .../inserters_arithmetic/wchar_t/5.cc | 46 +++++ .../inserters_arithmetic/wchar_t/6.cc | 51 ++++++ .../inserters_arithmetic/wchar_t/7.cc | 67 ++++++++ .../inserters_arithmetic/wchar_t/9555-oa.cc | 77 +++++++++ .../wchar_t/exceptions_badbit_throw.cc | 71 ++++++++ .../wchar_t/exceptions_failbit_throw.cc | 66 ++++++++ 12 files changed, 852 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/31031.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/6.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/9555-oa.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_badbit_throw.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_failbit_throw.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t') diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc new file mode 100644 index 000000000..0108fd067 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc @@ -0,0 +1,185 @@ +// 1999-11-15 Kevin Ediger +// test the floating point inserters (facet num_put) + +// Copyright (C) 1999, 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 +// . + +#include +#include +#include +#include +#include + +using namespace std; + +#ifndef _GLIBCXX_ASSERT +# define TEST_NUMPUT_VERBOSE 1 +#endif + +struct _TestCase +{ + double val; + + int precision; + int width; + char decimal; + char fill; + + bool fixed; + bool scientific; + bool showpos; + bool showpoint; + bool uppercase; + bool internal; + bool left; + bool right; + + const char* result; + const wchar_t* wresult; +}; + +static bool T=true; +static bool F=false; + +static _TestCase testcases[] = +{ + // standard output (no formatting applied) 1-4 + { 1.2, 6,0,'.',' ', F,F,F,F,F,F,F,F, "1.2",L"1.2" }, + { 54, 6,0,'.',' ', F,F,F,F,F,F,F,F, "54",L"54" }, + { -.012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-0.012",L"-0.012" }, + { -.00000012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-1.2e-07",L"-1.2e-07" }, + + // fixed formatting 5-11 + { 10.2345, 0,0,'.',' ', T,F,F,F,F,F,F,F, "10",L"10" }, + { 10.2345, 0,0,'.',' ', T,F,F,T,F,F,F,F, "10.",L"10." }, + { 10.2345, 1,0,'.',' ', T,F,F,F,F,F,F,F, "10.2",L"10.2" }, + { 10.2345, 4,0,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, + { 10.2345, 6,0,'.',' ', T,F,T,F,F,F,F,F, "+10.234500",L"+10.234500" }, + { -10.2345, 6,0,'.',' ', T,F,F,F,F,F,F,F, "-10.234500",L"-10.234500" }, + { -10.2345, 6,0,',',' ', T,F,F,F,F,F,F,F, "-10,234500",L"-10,234500" }, + + // fixed formatting with width 12-22 + { 10.2345, 4,5,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, + { 10.2345, 4,6,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, + { 10.2345, 4,7,'.',' ', T,F,F,F,F,F,F,F, "10.2345",L"10.2345" }, + { 10.2345, 4,8,'.',' ', T,F,F,F,F,F,F,F, " 10.2345",L" 10.2345" }, + { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,F,F, " 10.2345",L" 10.2345" }, + { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,T,F, "10.2345 ",L"10.2345 " }, + { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,F,T, " 10.2345",L" 10.2345" }, + { 10.2345, 4,10,'.',' ', T,F,F,F,F,T,F,F, " 10.2345",L" 10.2345" }, + { -10.2345, 4,10,'.',' ', T,F,F,F,F,T,F,F, "- 10.2345",L"- 10.2345" }, + { -10.2345, 4,10,'.','A', T,F,F,F,F,T,F,F, "-AA10.2345",L"-AA10.2345" }, + { 10.2345, 4,10,'.','#', T,F,T,F,F,T,F,F, "+##10.2345",L"+##10.2345" }, + + // scientific formatting 23-29 + { 1.23e+12, 1,0,'.',' ', F,T,F,F,F,F,F,F, "1.2e+12",L"1.2e+12" }, + { 1.23e+12, 1,0,'.',' ', F,T,F,F,T,F,F,F, "1.2E+12",L"1.2E+12" }, + { 1.23e+12, 2,0,'.',' ', F,T,F,F,F,F,F,F, "1.23e+12",L"1.23e+12" }, + { 1.23e+12, 3,0,'.',' ', F,T,F,F,F,F,F,F, "1.230e+12",L"1.230e+12" }, + { 1.23e+12, 3,0,'.',' ', F,T,T,F,F,F,F,F, "+1.230e+12",L"+1.230e+12" }, + { -1.23e-12, 3,0,'.',' ', F,T,F,F,F,F,F,F, "-1.230e-12",L"-1.230e-12" }, + { 1.23e+12, 3,0,',',' ', F,T,F,F,F,F,F,F, "1,230e+12",L"1,230e+12" }, +}; + +template +class testpunct : public numpunct<_CharT> +{ +public: + typedef _CharT char_type; + const char_type dchar; + + explicit + testpunct(char_type decimal_char) : numpunct<_CharT>(), dchar(decimal_char) + { } + +protected: + char_type + do_decimal_point() const + { return dchar; } + + char_type + do_thousands_sep() const + { return ','; } + + string + do_grouping() const + { return string(); } +}; + +template +void apply_formatting(const _TestCase & tc, basic_ostream<_CharT> & os) +{ + os.precision(tc.precision); + os.width(tc.width); + os.fill(static_cast<_CharT>(tc.fill)); + if (tc.fixed) + os.setf(ios::fixed); + if (tc.scientific) + os.setf(ios::scientific); + if (tc.showpos) + os.setf(ios::showpos); + if (tc.showpoint) + os.setf(ios::showpoint); + if (tc.uppercase) + os.setf(ios::uppercase); + if (tc.internal) + os.setf(ios::internal); + if (tc.left) + os.setf(ios::left); + if (tc.right) + os.setf(ios::right); +} + +void +test01() +{ + bool test __attribute__((unused)) = true; + for (std::size_t j = 0; j* __tp = new testpunct(tc.decimal); + wostringstream os; + locale __loc(os.getloc(), __tp); + os.imbue(__loc); + apply_formatting(tc, os); + os << tc.val; + VERIFY( os && os.str() == tc.wresult ); + } + // test long double with wchar_t type + { + testpunct* __tp = new testpunct(tc.decimal); + wostringstream os; + locale __loc(os.getloc(), __tp); + os.imbue(__loc); + apply_formatting(tc, os); + os << (long double)tc.val; + VERIFY( os && os.str() == tc.wresult ); + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/2.cc new file mode 100644 index 000000000..e786f7589 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/2.cc @@ -0,0 +1,54 @@ +// { dg-require-namedlocale "de_DE" } + +// Copyright (C) 2005, 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 +// . + +#include +#include +#include +#include +#include +#include + +void +test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Make sure we can output a long float in fixed format + // without seg-faulting (libstdc++/4402) + double val2 = 3.5e230; + + wostringstream os2; + os2.precision(3); + os2.setf(wios::fixed); + + // Check it can be done in a locale with grouping on. + locale loc2 = locale("de_DE"); + os2.imbue(loc2); + os2 << fixed << setprecision(3) << val2 << endl; + os2 << endl; + os2 << fixed << setprecision(1) << val2 << endl; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/3.cc new file mode 100644 index 000000000..436fae353 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/3.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 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 +// . + +#include +#include +#include + +template +bool +test03_check(T n) +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstringbuf strbuf; + wostream o(&strbuf); + const wchar_t *expect; + + if (numeric_limits::digits + 1 == 16) + expect = L"177777 ffff"; + else if (numeric_limits::digits + 1 == 32) + expect = L"37777777777 ffffffff"; + else if (numeric_limits::digits + 1 == 64) + expect = L"1777777777777777777777 ffffffffffffffff"; + else + expect = L"wow, you've got some big numbers here"; + + o << oct << n << L' ' << hex << n; + VERIFY ( strbuf.str() == expect ); + + return test; +} + +void +test03() +{ + short s = -1; + int i = -1; + long l = -1; + + test03_check(s); + test03_check(i); + test03_check(l); +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/31031.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/31031.cc new file mode 100644 index 000000000..bb5aedadd --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/31031.cc @@ -0,0 +1,51 @@ +// { dg-do compile } + +// 2007-03-03 Paolo Carlini +// +// Copyright (C) 2007, 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 +// . + +#include + +class MyClass +{ + double x; + +public: + MyClass(double X) : x(X) {} + friend bool operator&&(int i, const MyClass& Z); +}; + +inline bool +operator&&(int i, const MyClass& Z) +{ return int(Z.x) == i; } + +// libstdc++/31031 +void test01() +{ + int k =3; + MyClass X(3.1); + std::wostringstream oss; + + oss << (k && X); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4.cc new file mode 100644 index 000000000..9592d9482 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005, 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 +// . + +#include +#include +#include + +// libstdc++/3655 +int +test04() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstringbuf strbuf1, strbuf2; + wostream o1(&strbuf1), o2(&strbuf2); + + o1 << hex << showbase << setw(6) << internal << 0xff; + VERIFY( strbuf1.str() == L"0x ff" ); + + // ... vs internal-adjusted const char*-type objects + o2 << hex << showbase << setw(6) << internal << L"0xff"; + VERIFY( strbuf2.str() == L" 0xff" ); + + return 0; +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc new file mode 100644 index 000000000..54b339e99 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc @@ -0,0 +1,72 @@ +// { dg-require-swprintf "" } + +// Copyright (C) 2005, 2006, 2007, 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 +// . + +#include // for swprintf +#include +#include +#include +#include +#include + +void +test02() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // make sure we can output a very long float + long double val = numeric_limits::max(); + int prec = numeric_limits::digits10; + + wostringstream os; + os.precision(prec); + os.setf(wios::scientific); + os << val; + + wchar_t largebuf[512]; + swprintf(largebuf, 512, L"%.*Le", prec, val); +#ifdef TEST_NUMPUT_VERBOSE + cout << "expect: " << largebuf << endl; + cout << "result: " << os.str() << endl; +#endif + VERIFY( os && os.str() == largebuf ); + + // Make sure we can output a long float in fixed format + // without seg-faulting (libstdc++/4402) + double val2 = numeric_limits::max(); + + wostringstream os2; + os2.precision(3); + os2.setf(wios::fixed); + os2 << val2; + + swprintf(largebuf, 512, L"%.*f", 3, val2); +#ifdef TEST_NUMPUT_VERBOSE + cout << "expect: " << largebuf << endl; + cout << "result: " << os2.str() << endl; +#endif + VERIFY( os2 && os2.str() == largebuf ); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/5.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/5.cc new file mode 100644 index 000000000..d48fee3b9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/5.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005, 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 +// . + +#include // for abs +#include // for DBL_EPSILON +#include +#include +#include + +void +test05() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + double pi = 3.14159265358979323846; + wostringstream ostr; + ostr.precision(20); + ostr << pi; + wstring sval = ostr.str(); + wistringstream istr(sval); + double d; + istr >> d; + VERIFY( abs(pi-d)/pi < DBL_EPSILON ); +} + +int +main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/6.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/6.cc new file mode 100644 index 000000000..96f34ccb5 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/6.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005, 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 +// . + +// { dg-do run { xfail lax_strtofp } } + +#include // for abs +#include // for DBL_EPSILON +#include +#include +#include + +// libstdc++/9151 +void +test06() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + int prec = numeric_limits::digits10 + 2; + double oval = numeric_limits::min(); + + wstringstream ostr; + ostr.precision(prec); + ostr << oval; + wstring sval = ostr.str(); + wistringstream istr(sval); + double ival; + istr >> ival; + VERIFY( abs(oval-ival)/oval < DBL_EPSILON ); +} + +int +main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.cc new file mode 100644 index 000000000..41e230ca7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/7.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 +// . + +// 27.6.2.5.2 Arithmetic inserters + +#include +#include + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstringstream ostr1, ostr2, ostr3, ostr4; + + ostr1.setf(ios_base::oct); + ostr1.setf(ios_base::hex); + + short s = -1; + ostr1 << s; + VERIFY( ostr1.str() == L"-1" ); + + ostr2.setf(ios_base::oct); + ostr2.setf(ios_base::hex); + + int i = -1; + ostr2 << i; + VERIFY( ostr2.str() == L"-1" ); + + ostr3.setf(ios_base::oct); + ostr3.setf(ios_base::hex); + + long l = -1; + ostr3 << l; + VERIFY( ostr3.str() == L"-1" ); + +#ifdef _GLIBCXX_USE_LONG_LONG + ostr4.setf(ios_base::oct); + ostr4.setf(ios_base::hex); + + long long ll = -1LL; + ostr4 << ll; + VERIFY( ostr4.str() == L"-1" ); +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/9555-oa.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/9555-oa.cc new file mode 100644 index 000000000..0acd426a2 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/9555-oa.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2005, 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 +// . + + +#include +#include +#include + +struct buf: std::wstreambuf +{ + virtual int_type overflow(int_type) + { throw 0; } +}; + +template +void testthrow(T arg) +{ + bool test __attribute__((unused)) = true; + buf b; + std::wostream os(&b); + os.exceptions(std::wios::badbit); + + try + { + os << arg; + } + catch(int) + { + // Expected return is zero. + VERIFY( os.bad() ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + bool b = true; + short s = -4; + unsigned short us = 4; + int i = -45; + unsigned int ui = 45; + long l = -456; + unsigned long ul = 456; + float f = 3.4; + double d = 3.45; + long double ld = 3.456; + + testthrow(b); + testthrow(s); + testthrow(us); + testthrow(i); + testthrow(ui); + testthrow(l); + testthrow(ul); + testthrow(f); + testthrow(d); + testthrow(ld); + + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_badbit_throw.cc new file mode 100644 index 000000000..86b0884da --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_badbit_throw.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005, 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 +// . + +#include +#include +#include +#include + +// libstdc++/9561 +template +void test_badbit() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale loc(locale::classic(), new __gnu_test::fail_num_put_wchar_t); + wostringstream stream(L"jaylib - champion sound"); + stream.imbue(loc); + + stream.exceptions(ios_base::badbit); + VERIFY( stream.rdstate() == ios_base::goodbit ); + + try + { + T i = T(); + stream << i; + VERIFY( false ); + } + catch (const __gnu_test::facet_error&) + { + // stream should set badbit and rethrow facet_error. + VERIFY( stream.bad() ); + VERIFY( (stream.rdstate() & ios_base::failbit) == 0 ); + VERIFY( !stream.eof() ); + } + catch (...) + { + VERIFY( false ); + } +} + + +int main() +{ + test_badbit(); + test_badbit(); + test_badbit(); + test_badbit(); + test_badbit(); + test_badbit(); + test_badbit(); + + test_badbit(); + test_badbit(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_failbit_throw.cc new file mode 100644 index 000000000..1cf29cba4 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/exceptions_failbit_throw.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005, 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 +// . + + +#include +#include +#include + +// libstdc++/10093 +template +void test_failbit() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + locale loc(locale::classic(), new __gnu_test::fail_num_put_wchar_t); + wostringstream stream(L"jaylib - champion sound"); + stream.imbue(loc); + + stream.exceptions(ios_base::failbit); + + try + { + T i = T(); + stream << i; + } + catch (const ios_base::failure&) + { VERIFY( false ); } + catch(...) + { VERIFY( false ); } + + // stream should set badbit. + VERIFY( stream.bad() ); + VERIFY( (stream.rdstate() & ios_base::failbit) == 0 ); + VERIFY( !stream.eof() ); +} + +int main() +{ + test_failbit(); + test_failbit(); + test_failbit(); + test_failbit(); + test_failbit(); + test_failbit(); + test_failbit(); + + test_failbit(); + test_failbit(); + + return 0; +} -- cgit v1.2.3