summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc190
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/23871.cc37
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/3.cc68
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/31031.cc51
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4.cc50
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4402.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/5.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/6.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc67
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/9555-oa.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_badbit_throw.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_failbit_throw.cc67
13 files changed, 914 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc
new file mode 100644
index 000000000..35fe23287
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/1.cc
@@ -0,0 +1,190 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+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;
+};
+
+static bool T=true;
+static bool F=false;
+
+static _TestCase testcases[] =
+{
+ // standard output (no formatting applied)
+ { 1.2, 6,0,'.',' ', F,F,F,F,F,F,F,F, "1.2" },
+ { 54, 6,0,'.',' ', F,F,F,F,F,F,F,F, "54" },
+ { -.012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-0.012" },
+ { -.00000012, 6,0,'.',' ', F,F,F,F,F,F,F,F, "-1.2e-07" },
+
+ // fixed formatting
+ { 10.2345, 0,0,'.',' ', T,F,F,F,F,F,F,F, "10" },
+ { 10.2345, 0,0,'.',' ', T,F,F,T,F,F,F,F, "10." },
+ { 10.2345, 1,0,'.',' ', T,F,F,F,F,F,F,F, "10.2" },
+ { 10.2345, 4,0,'.',' ', T,F,F,F,F,F,F,F, "10.2345" },
+ { 10.2345, 6,0,'.',' ', T,F,T,F,F,F,F,F, "+10.234500" },
+ { -10.2345, 6,0,'.',' ', T,F,F,F,F,F,F,F, "-10.234500" },
+ { -10.2345, 6,0,',',' ', T,F,F,F,F,F,F,F, "-10,234500" },
+
+ // fixed formatting with width
+ { 10.2345, 4,5,'.',' ', T,F,F,F,F,F,F,F, "10.2345" },
+ { 10.2345, 4,6,'.',' ', T,F,F,F,F,F,F,F, "10.2345" },
+ { 10.2345, 4,7,'.',' ', T,F,F,F,F,F,F,F, "10.2345" },
+ { 10.2345, 4,8,'.',' ', T,F,F,F,F,F,F,F, " 10.2345" },
+ { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,F,F, " 10.2345" },
+ { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,T,F, "10.2345 " },
+ { 10.2345, 4,10,'.',' ', T,F,F,F,F,F,F,T, " 10.2345" },
+ { 10.2345, 4,10,'.',' ', T,F,F,F,F,T,F,F, " 10.2345" },
+ { -10.2345, 4,10,'.',' ', T,F,F,F,F,T,F,F, "- 10.2345" },
+ { -10.2345, 4,10,'.','A', T,F,F,F,F,T,F,F, "-AA10.2345" },
+ { 10.2345, 4,10,'.','#', T,F,T,F,F,T,F,F, "+##10.2345" },
+
+ // scientific formatting
+ { 1.23e+12, 1,0,'.',' ', F,T,F,F,F,F,F,F, "1.2e+12" },
+ { 1.23e+12, 1,0,'.',' ', F,T,F,F,T,F,F,F, "1.2E+12" },
+ { 1.23e+12, 2,0,'.',' ', F,T,F,F,F,F,F,F, "1.23e+12" },
+ { 1.23e+12, 3,0,'.',' ', F,T,F,F,F,F,F,F, "1.230e+12" },
+ { 1.23e+12, 3,0,'.',' ', F,T,T,F,F,F,F,F, "+1.230e+12" },
+ { -1.23e-12, 3,0,'.',' ', F,T,F,F,F,F,F,F, "-1.230e-12" },
+ { 1.23e+12, 3,0,',',' ', F,T,F,F,F,F,F,F, "1,230e+12" },
+};
+
+template<typename _CharT>
+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<typename _CharT>
+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<sizeof(testcases)/sizeof(testcases[0]); j++)
+ {
+ _TestCase & tc = testcases[j];
+#ifdef TEST_NUMPUT_VERBOSE
+ cout << "expect: " << tc.result << endl;
+#endif
+ // test double with char type
+ {
+ testpunct<char>* __tp = new testpunct<char>(tc.decimal);
+ ostringstream os;
+ locale __loc(os.getloc(), __tp);
+ os.imbue(__loc);
+ apply_formatting(tc, os);
+ os << tc.val;
+#ifdef TEST_NUMPUT_VERBOSE
+ cout << j << "result 1: " << os.str() << endl;
+#endif
+ VERIFY( os && os.str() == tc.result );
+ }
+ // test long double with char type
+ {
+ testpunct<char>* __tp = new testpunct<char>(tc.decimal);
+ ostringstream os;
+ locale __loc(os.getloc(), __tp);
+ os.imbue(__loc);
+ apply_formatting(tc, os);
+ os << (long double)tc.val;
+#ifdef TEST_NUMPUT_VERBOSE
+ cout << j << "result 2: " << os.str() << endl;
+#endif
+ VERIFY( os && os.str() == tc.result );
+ }
+ }
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc
new file mode 100644
index 000000000..d0ffa2c2a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc
@@ -0,0 +1,57 @@
+// { dg-require-namedlocale "de_DE" }
+
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2002, 2003, 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
+// <http://www.gnu.org/licenses/>.
+
+#include <iostream>
+#include <iomanip>
+#include <locale>
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+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;
+
+ ostringstream os2;
+ os2.precision(3);
+ os2.setf(ios::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/char/23871.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/23871.cc
new file mode 100644
index 000000000..88b55ad9b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/23871.cc
@@ -0,0 +1,37 @@
+// 2005-09-15 Janis Johnson <janis187@us.ibm.com>
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+// libstdc++/23871
+
+#include <iostream>
+
+class mytest {
+public:
+ mytest (int);
+ unsigned char operator|| (const mytest&) const;
+ friend unsigned char operator|| (const int&, const mytest&);
+};
+
+inline unsigned char operator|| (const int& lhs, const mytest& rhs)
+{
+ std::cout << 1 << std::endl;
+ return (mytest)lhs || rhs;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/3.cc
new file mode 100644
index 000000000..fd1d14955
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/3.cc
@@ -0,0 +1,68 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2002, 2003, 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
+// <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+template<typename T>
+bool
+test03_check(T n)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringbuf strbuf;
+ ostream o(&strbuf);
+ const char *expect;
+
+ if (numeric_limits<T>::digits + 1 == 16)
+ expect = "177777 ffff";
+ else if (numeric_limits<T>::digits + 1 == 32)
+ expect = "37777777777 ffffffff";
+ else if (numeric_limits<T>::digits + 1 == 64)
+ expect = "1777777777777777777777 ffffffffffffffff";
+ else
+ expect = "wow, you've got some big numbers here";
+
+ o << oct << n << ' ' << 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/char/31031.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/31031.cc
new file mode 100644
index 000000000..1f34663a9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/31031.cc
@@ -0,0 +1,51 @@
+// { dg-do compile }
+
+// 2007-03-03 Paolo Carlini <pcarlini@suse.de>
+//
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <sstream>
+
+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::ostringstream oss;
+
+ oss << (k && X);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4.cc
new file mode 100644
index 000000000..a2b686ae7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4.cc
@@ -0,0 +1,50 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2002, 2003, 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
+// <http://www.gnu.org/licenses/>.
+
+#include <iomanip>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3655
+int
+test04()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringbuf strbuf1, strbuf2;
+ ostream o1(&strbuf1), o2(&strbuf2);
+
+ o1 << hex << showbase << setw(6) << internal << 0xff;
+ VERIFY( strbuf1.str() == "0x ff" );
+
+ // ... vs internal-adjusted const char*-type objects
+ o2 << hex << showbase << setw(6) << internal << "0xff";
+ VERIFY( strbuf2.str() == " 0xff" );
+
+ return 0;
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4402.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4402.cc
new file mode 100644
index 000000000..fe1c3b6f2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/4402.cc
@@ -0,0 +1,74 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 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
+// <http://www.gnu.org/licenses/>.
+
+#include <cstdio> // for sprintf
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // make sure we can output a very long float
+ long double val = numeric_limits<long double>::max();
+ int prec = numeric_limits<long double>::digits10;
+
+ ostringstream os;
+ os.precision(prec);
+ os.setf(ios::scientific);
+ os << val;
+
+ char largebuf[512];
+ sprintf(largebuf, "%.*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<double>::max();
+
+ ostringstream os2;
+ os2.precision(3);
+ os2.setf(ios::fixed);
+ os2 << val2;
+
+ sprintf(largebuf, "%.*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/char/5.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/5.cc
new file mode 100644
index 000000000..ba0e6a390
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/5.cc
@@ -0,0 +1,49 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2002, 2003, 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
+// <http://www.gnu.org/licenses/>.
+
+#include <cmath> // for abs
+#include <cfloat> // for DBL_EPSILON
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+void
+test05()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ double pi = 3.14159265358979323846;
+ ostringstream ostr;
+ ostr.precision(20);
+ ostr << pi;
+ string sval = ostr.str();
+ istringstream 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/char/6.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/6.cc
new file mode 100644
index 000000000..2a3d1542b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/6.cc
@@ -0,0 +1,54 @@
+// 1999-11-15 Kevin Ediger <kediger@licor.com>
+// test the floating point inserters (facet num_put)
+
+// Copyright (C) 1999, 2002, 2003, 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { xfail lax_strtofp } }
+
+#include <cmath> // for abs
+#include <cfloat> // for DBL_EPSILON
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// libstdc++/9151
+void
+test06()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ int prec = numeric_limits<double>::digits10 + 2;
+ double oval = numeric_limits<double>::min();
+
+ stringstream ostr;
+ ostr.precision(prec);
+ ostr << oval;
+ string sval = ostr.str();
+ istringstream 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/char/7.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc
new file mode 100644
index 000000000..d3e3213dd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/7.cc
@@ -0,0 +1,67 @@
+// 2005-07-11 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.6.2.5.2 Arithmetic inserters
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringstream ostr1, ostr2, ostr3, ostr4;
+
+ ostr1.setf(ios_base::oct);
+ ostr1.setf(ios_base::hex);
+
+ short s = -1;
+ ostr1 << s;
+ VERIFY( ostr1.str() == "-1" );
+
+ ostr2.setf(ios_base::oct);
+ ostr2.setf(ios_base::hex);
+
+ int i = -1;
+ ostr2 << i;
+ VERIFY( ostr2.str() == "-1" );
+
+ ostr3.setf(ios_base::oct);
+ ostr3.setf(ios_base::hex);
+
+ long l = -1;
+ ostr3 << l;
+ VERIFY( ostr3.str() == "-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() == "-1" );
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/9555-oa.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/9555-oa.cc
new file mode 100644
index 000000000..ed1e34b77
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/9555-oa.cc
@@ -0,0 +1,77 @@
+// Copyright (C) 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 <ostream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test __attribute__((unused)) = true;
+ buf b;
+ std::ostream os(&b);
+ os.exceptions(std::ios::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/char/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..6c917ad84
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_badbit_throw.cc
@@ -0,0 +1,73 @@
+// 2003-03-08 Jerry Quinn <jlquinn@optonline.net>
+
+// Copyright (C) 2003, 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 <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// libstdc++/9561
+template<typename T>
+void test_badbit()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale::classic(), new __gnu_test::fail_num_put_char);
+ ostringstream stream("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<bool>();
+ test_badbit<short>();
+ test_badbit<unsigned short>();
+ test_badbit<int>();
+ test_badbit<unsigned int>();
+ test_badbit<long>();
+ test_badbit<unsigned long>();
+
+ test_badbit<float>();
+ test_badbit<double>();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_failbit_throw.cc
new file mode 100644
index 000000000..19b1fcd84
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/exceptions_failbit_throw.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2003, 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 <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// libstdc++/10093
+template<typename T>
+void test_failbit()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale::classic(), new __gnu_test::fail_num_put_char);
+ ostringstream stream("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<bool>();
+ test_failbit<short>();
+ test_failbit<unsigned short>();
+ test_failbit<int>();
+ test_failbit<unsigned int>();
+ test_failbit<long>();
+ test_failbit<unsigned long>();
+
+ test_failbit<float>();
+ test_failbit<double>();
+
+ return 0;
+}