summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc120
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/02.cc45
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/03.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/06.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc145
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/08.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/09.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc132
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/11.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc67
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/9555-ia.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc101
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_badbit_throw.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit_throw.cc68
16 files changed, 1236 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc
new file mode 100644
index 000000000..5d7ec97a5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/01.cc
@@ -0,0 +1,120 @@
+// Copyright (C) 2004, 2009, 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <cstdio> // for printf
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+std::wstring str_01;
+std::wstring str_02(L"true false 0 1 110001");
+std::wstring str_03(L"-19999999 777777 -234234 233 -234 33 1 66300.25 .315 1.5");
+std::wstring str_04(L"0123");
+
+std::wstringbuf isbuf_01(std::ios_base::in);
+std::wstringbuf isbuf_02(str_02, std::ios_base::in);
+std::wstringbuf isbuf_03(str_03, std::ios_base::in);
+std::wstringbuf isbuf_04(str_04, std::ios_base::in);
+
+std::wistream is_01(0);
+std::wistream is_02(&isbuf_02);
+std::wistream is_03(&isbuf_03);
+std::wistream is_04(&isbuf_04);
+std::wstringstream ss_01(str_01);
+
+// minimal sanity check
+bool test01() {
+
+ bool test __attribute__((unused)) = true;
+
+ // Integral Types:
+ bool b1 = false;
+ short s1 = 0;
+ int i1 = 0;
+ long l1 = 0;
+ unsigned short us1 = 0;
+ unsigned int ui1 = 0;
+ unsigned long ul1 = 0;
+
+ // Floating-point Types:
+ float f1 = 0;
+ double d1 = 0;
+ long double ld1 = 0;
+
+ // process alphanumeric versions of bool values
+ is_02.setf(std::ios_base::boolalpha);
+ is_02.flags();
+ is_02 >> b1;
+ VERIFY( b1 == 1 );
+ is_02 >> b1;
+ VERIFY( b1 == 0 );
+
+ // process numeric versions of of bool values
+ is_02.unsetf(std::ios_base::boolalpha);
+ is_02.flags();
+ is_02 >> b1;
+ VERIFY( b1 == 0 );
+ is_02 >> b1;
+ VERIFY( b1 == 1 );
+
+ // is_03 == "-19999999 777777 -234234 233 -234 33 1 66300.25 .315 1.5"
+ is_03 >> l1;
+ VERIFY( l1 == -19999999 );
+ is_03 >> ul1;
+ VERIFY( ul1 == 777777 );
+ is_03 >> i1;
+ VERIFY( i1 == -234234 );
+ is_03 >> ui1;
+ VERIFY( ui1 == 233 );
+ is_03 >> s1;
+ VERIFY( s1 == -234 );
+ is_03 >> us1;
+ VERIFY( us1 == 33 );
+ is_03 >> b1;
+ VERIFY( b1 == 1 );
+ is_03 >> ld1;
+ VERIFY( ld1 == 66300.25 );
+ is_03 >> d1;
+ VERIFY( d1 == .315 );
+ is_03 >> f1;
+ VERIFY( f1 == 1.5 );
+
+ is_04 >> std::hex >> i1;
+ std::printf ("%d %d %d\n", i1, i1 == 0x123, test);
+ VERIFY( i1 == 0x123 );
+ std::printf ("%d %d %d\n", i1, i1 == 0x123, test);
+
+ // test void pointers
+ int i = 55;
+ void* po = &i;
+ void* pi;
+
+ ss_01 << po;
+ ss_01 >> pi;
+ std::printf ("%p %p\n", pi, po);
+ VERIFY( po == pi );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/02.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/02.cc
new file mode 100644
index 000000000..86c43afcd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/02.cc
@@ -0,0 +1,45 @@
+// 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// elaborated test for ints
+bool test02()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01(L"20000AB");
+ std::wstringbuf strb_01(str_01, std::ios_base::in);
+ std::wistream is(&strb_01);
+
+ int n = 15;
+ is >> n;
+ VERIFY( n == 20000 );
+ wchar_t c = is.peek();
+ VERIFY( c == L'A' );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/03.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/03.cc
new file mode 100644
index 000000000..a357814c2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/03.cc
@@ -0,0 +1,44 @@
+// 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+bool test03()
+{
+ std::wstringbuf sbuf;
+ std::wistream istr(&sbuf);
+ std::wostream ostr(&sbuf);
+
+ bool test __attribute__((unused)) = true;
+ long l01;
+ ostr << L"12220101";
+ istr >> l01; // _M_in_end set completely incorrectly here.
+ VERIFY( l01 == 12220101 );
+ VERIFY( istr.rdstate() == std::ios_base::eofbit );
+ return test;
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/06.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/06.cc
new file mode 100644
index 000000000..52c25a5bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/06.cc
@@ -0,0 +1,58 @@
+// 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00081.html
+// Jim Parsons
+void test06()
+{
+ // default locale, grouping is turned off
+ bool test __attribute__((unused)) = true;
+ unsigned int h4;
+ wchar_t c;
+ std::wstring s(L"205,199,144");
+ std::wistringstream is(s);
+
+ is >> h4; // 205
+ VERIFY( h4 == 205 );
+ is >> c; // L','
+ VERIFY( c == L',' );
+
+ is >> h4; // 199
+ VERIFY( h4 == 199 );
+ is >> c; // L','
+ VERIFY( c == L',' );
+
+ is >> h4; // 144
+ VERIFY( is.rdstate() == std::ios_base::eofbit );
+ VERIFY( h4 == 144 );
+ is >> c; // EOF
+ VERIFY( c == L',' );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc
new file mode 100644
index 000000000..8e56816cf
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc
@@ -0,0 +1,145 @@
+// Copyright (C) 2004, 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+namespace std {
+ class test_numpunct1 : public numpunct<wchar_t>
+ {
+ protected:
+ string
+ do_grouping() const
+ { return string(1, '\003'); }
+ };
+} // namespace std
+
+void test07()
+{
+ // manufactured locale, grouping is turned on
+ bool test __attribute__((unused)) = true;
+ unsigned int h4 = 0, h3 = 0, h2 = 0;
+ float f1 = 0.0;
+ const std::wstring s1(L"205,199 23,445.25 1,024,365 123,22,24");
+ std::wistringstream is(s1);
+ is.imbue(std::locale(std::locale(), new std::test_numpunct1));
+
+ // Basic operation.
+ is >> h4;
+ VERIFY( h4 == 205199 );
+ VERIFY( is.good() );
+
+ is.clear();
+ is >> f1;
+ VERIFY( f1 == 23445.25 );
+ VERIFY( is.good() );
+
+ is.clear();
+ is >> h3;
+ VERIFY( h3 == 1024365 );
+ VERIFY( is.good() );
+
+ is.clear();
+ is >> h2;
+ VERIFY( h2 == 1232224 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
+
+ // Stress tests for explicit errors in grouping corner cases. The
+ // validity of these tests and results have been hammered out in
+ // private email between bkoz and ncm between Jan 25 and Jan 27, 2000.
+ // Thanks nate -- benjamin
+ const std::wstring s2(L",111 4,,4 0.25,345 5..25 156,, 1,000000 1000000 1234,567");
+ h3 = h4 = h2 = 0;
+ f1 = 0.0;
+ const wchar_t c_control = L'?';
+ wchar_t c = c_control;
+ is.clear();
+ is.str(s2);
+
+ is >> h4;
+ VERIFY( h4 == 0 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ is.clear();
+ is >> c;
+ VERIFY( c == L',' );
+ VERIFY( is.good() );
+
+ is.ignore(3);
+ is >> f1;
+ VERIFY( f1 == 0.0 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ is.clear();
+ is >> c;
+ VERIFY( c == L',' );
+ is >> c;
+ VERIFY( c == L'4' );
+ VERIFY( is.good() );
+
+ is >> f1;
+ VERIFY( f1 == 0.25 );
+ VERIFY( is.good() );
+ is >> c;
+ VERIFY( c == L',' );
+ is >> h2;
+ VERIFY( h2 == 345 );
+ VERIFY( is.good() );
+ f1 = 0.0;
+ h2 = 0;
+
+ is >> f1;
+ VERIFY( f1 == 5.0 );
+ VERIFY( is.good() );
+ is >> f1;
+ VERIFY( f1 == .25 );
+ VERIFY( is.good() );
+
+ is >> h3;
+ VERIFY( h3 == 0 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ is.clear();
+ is >> c;
+ VERIFY( c == L',' ); // second one
+ VERIFY( is.good() );
+
+ is >> h2;
+ VERIFY( h2 == 1000000 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ h2 = 0;
+ is.clear();
+
+ is >> h2;
+ VERIFY( h2 == 1000000 );
+ VERIFY( is.good() );
+ h2 = 0;
+
+ is >> h2;
+ VERIFY( h2 == 1234567 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
+ is.clear();
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/08.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/08.cc
new file mode 100644
index 000000000..c5d78cfb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/08.cc
@@ -0,0 +1,65 @@
+// 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+namespace std {
+ class test_numpunct2 : public numpunct<wchar_t>
+ {
+ protected:
+ string
+ do_grouping() const
+ { return string("\002\003"); }
+ };
+} // namespace std
+
+void test08()
+{
+ // manufactured locale, grouping is turned on
+ bool test __attribute__((unused)) = true;
+ unsigned int h4 = 0, h3 = 0, h2 = 0;
+ const std::wstring s1(L"1,22 205,19 22,123,22");
+
+ std::wistringstream is(s1);
+ is.imbue(std::locale(std::locale(), new std::test_numpunct2));
+
+ // Basic operation.
+ is >> h4;
+ VERIFY( h4 == 122 );
+ VERIFY( is.good() );
+
+ is.clear();
+ is >> h3;
+ VERIFY( h3 == 20519 );
+ VERIFY( is.good() );
+
+ is.clear();
+ is >> h2;
+ VERIFY( h2 == 2212322 );
+ VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/09.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/09.cc
new file mode 100644
index 000000000..fbf6e5db5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/09.cc
@@ -0,0 +1,49 @@
+// 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.1.2.2 arithmetic extractors
+
+// { dg-do run { xfail lax_strtofp } }
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+bool test09()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring st(L"2.456e3-+0.567e-2");
+ std::wstringbuf sb(st);
+ std::wistream is(&sb);
+ double f1 = 0, f2 = 0;
+ wchar_t c;
+ (is >> std::ws) >> f1;
+ (is >> std::ws) >> c;
+ (is >> std::ws) >> f2;
+ test = f1 == 2456;
+ VERIFY( f2 == 0.00567 );
+ VERIFY( c == L'-' );
+ return test;
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc
new file mode 100644
index 000000000..f960f0cfb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/10.cc
@@ -0,0 +1,132 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+bool test10()
+{
+ std::wstring str_01(L"0 00 000 +0 +0 -0");
+ std::wstringbuf isbuf_01(str_01);
+ std::wistream is_01(&isbuf_01);
+
+ bool test __attribute__((unused)) = true;
+
+ int n = 365;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ n = 364;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ n = 363;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ n = 362;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ n = 361;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ n = 360;
+ is_01 >> n;
+ VERIFY( n == 0 );
+ VERIFY( is_01.rdstate() == std::ios_base::eofbit );
+
+ std::wstring str_02(L"0x32 0X33 033 33");
+ std::wstringbuf isbuf_02(str_02);
+ std::wistream is_02(&isbuf_02);
+ is_02.unsetf(std::ios_base::basefield);
+ is_02 >> n;
+ VERIFY( n == 50 );
+ is_02 >> n;
+ VERIFY( n == 51 );
+ is_02 >> n;
+ VERIFY( n == 27 );
+ is_02 >> n;
+ VERIFY( n == 33 );
+ VERIFY( is_02.rdstate() == std::ios_base::eofbit );
+
+ std::wstringbuf isbuf_03(str_02);
+ std::wistream is_03(&isbuf_03);
+ wchar_t c;
+ int m;
+
+ is_03 >> std::dec >> n >> c >> m;
+ VERIFY( n == 0 );
+ VERIFY( c == L'x' );
+ VERIFY( m == 32 );
+
+ is_03 >> std::oct >> m >> c >> n;
+ VERIFY( m == 0 );
+ VERIFY( c == L'X' );
+ VERIFY( n == 27 );
+
+ is_03 >> std::dec >> m >> n;
+ VERIFY( m == 33 );
+ VERIFY( n == 33 );
+ VERIFY( is_03.rdstate() == std::ios_base::eofbit );
+
+ std::wstring str_04(L"3. 4.5E+2a5E-3 .6E1");
+ std::wstringbuf isbuf_04(str_04);
+ std::wistream is_04(&isbuf_04);
+
+ double f;
+ is_04 >> f;
+ VERIFY( f == 3.0 );
+ is_04 >> f;
+ VERIFY( f == 450.0 );
+ is_04.ignore();
+ is_04 >> f;
+ VERIFY( f == 0.005 );
+ is_04 >> f;
+ VERIFY( f == 6 );
+ VERIFY( is_03.rdstate() == std::ios_base::eofbit );
+
+ std::wstring str_05(L"0E20 5Ea E16");
+ std::wstringbuf isbuf_05(str_05);
+ std::wistream is_05(&isbuf_05);
+
+ is_05 >> f;
+ VERIFY( f == 0 );
+ f = 1;
+ is_05 >> f;
+ VERIFY( f == 0 );
+ VERIFY( is_05.rdstate() == std::ios_base::failbit );
+ is_05.clear();
+ is_05 >> c;
+ VERIFY( c == L'a' );
+ f = 1;
+ is_05 >> f;
+ VERIFY( f == 0 );
+ VERIFY( is_05.rdstate() == std::ios_base::failbit );
+ is_05.clear();
+ is_05.ignore();
+ is_05 >> n;
+ VERIFY( n == 16 );
+ return test;
+}
+
+int main()
+{
+ test10();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/11.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/11.cc
new file mode 100644
index 000000000..5eb256ef9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/11.cc
@@ -0,0 +1,53 @@
+// 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.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+// In the presence of no fmtflags, the input operator should behave
+// like strtol(x, y, 0)
+// libstdc++/90
+bool test11()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* cstrlit = L"0x2a";
+
+ // sanity check via 'C' library call
+ wchar_t* err;
+ long l = std::wcstol(cstrlit, &err, 0);
+
+ std::wistringstream iss(cstrlit);
+ iss.setf(std::wios::fmtflags(0), std::ios::basefield);
+ int i;
+ iss >> i;
+
+ VERIFY( !iss.fail() );
+ VERIFY( l == i );
+
+ return test;
+}
+
+int main()
+{
+ test11();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc
new file mode 100644
index 000000000..dcadf8669
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc
@@ -0,0 +1,74 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009, 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+// XXX This test fails on Solaris 8 and 9 because of a bug in libc
+// XXX sscanf for very long input. See:
+// XXX http://gcc.gnu.org/ml/gcc/2002-12/msg01422.html
+// { dg-do run { xfail { { *-*-solaris2.[89] } || lax_strtofp } } }
+
+#include <istream>
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// libstdc++/3720
+// excess input should not cause a core dump
+template<typename T>
+bool test12_aux(bool integer_type)
+{
+ bool test __attribute__((unused)) = true;
+
+ int digits_overflow;
+ if (integer_type)
+ // This many digits will overflow integer types in base 10.
+ digits_overflow = std::numeric_limits<T>::digits10 + 2;
+ else
+ // This might do it, unsure.
+ digits_overflow = std::numeric_limits<T>::max_exponent10 + 1;
+
+ std::wstring st;
+ std::wstring part = L"1234567890123456789012345678901234567890";
+ for (std::size_t i = 0; i < digits_overflow / part.size() + 1; ++i)
+ st += part;
+ std::wstringbuf sb(st);
+ std::wistream is(&sb);
+ T t;
+ is >> t;
+ VERIFY( is.fail() );
+ return test;
+}
+
+bool test12()
+{
+ bool test __attribute__((unused)) = true;
+ VERIFY( test12_aux<short>(true) );
+ VERIFY( test12_aux<int>(true) );
+ VERIFY( test12_aux<long>(true) );
+ VERIFY( test12_aux<float>(false) );
+ VERIFY( test12_aux<double>(false) );
+ VERIFY( test12_aux<long double>(false) );
+ return test;
+}
+
+int main()
+{
+ test12();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc
new file mode 100644
index 000000000..0a44b1ffb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// libstdc++/3720 part two
+void test13()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ const wchar_t* l2 = L"1.2345678901234567890123456789012345678901234567890123456"
+ L" "
+ L"1246.9";
+
+ // 1
+ // used to core.
+ double d;
+ wistringstream iss1(l2);
+ iss1 >> d;
+ iss1 >> d;
+ VERIFY ( d > 1246 && d < 1247 );
+
+ // 2
+ // quick test for failbit on maximum length extraction.
+ int i;
+ int max_digits = numeric_limits<int>::digits10 + 1;
+ wstring digits;
+ for (int j = 0; j < max_digits; ++j)
+ digits += L'1';
+ wistringstream iss2(digits);
+ iss2 >> i;
+ VERIFY( !iss2.fail() );
+
+ digits += L'1';
+ i = 0;
+ iss2.str(digits);
+ iss2.clear();
+ iss2 >> i;
+ VERIFY( i == numeric_limits<int>::max() );
+ VERIFY( iss2.fail() );
+}
+
+int main()
+{
+ test13();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/9555-ia.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/9555-ia.cc
new file mode 100644
index 000000000..8ae2f09ed
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/9555-ia.cc
@@ -0,0 +1,77 @@
+// 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 <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::wstreambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test __attribute__((unused)) = true;
+ buf b;
+ std::wistream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.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_istream/extractors_arithmetic/wchar_t/dr696.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc
new file mode 100644
index 000000000..2ed5b309b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc
@@ -0,0 +1,101 @@
+// 2009-07-15 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 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.1.2.2 arithmetic extractors
+
+#include <sstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// DR 696.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ short s1 = 0;
+ wostringstream oss1;
+ oss1 << numeric_limits<short>::max();
+ wistringstream iss1(oss1.str());
+ iss1 >> s1;
+ VERIFY( s1 == numeric_limits<short>::max() );
+ VERIFY( !iss1.fail() && iss1.eof() );
+
+ short s2 = 0;
+ wostringstream oss2;
+ oss2 << static_cast<long long>(numeric_limits<short>::max()) + 1;
+ wistringstream iss2(oss2.str());
+ iss2 >> s2;
+ VERIFY( s2 == numeric_limits<short>::max() );
+ VERIFY( iss2.fail() && iss2.eof() );
+
+ short s3 = 0;
+ wostringstream oss3;
+ oss3 << numeric_limits<short>::min();
+ wistringstream iss3(oss3.str());
+ iss3 >> s3;
+ VERIFY( s3 == numeric_limits<short>::min() );
+ VERIFY( !iss3.fail() && iss3.eof() );
+
+ short s4 = 0;
+ wostringstream oss4;
+ oss4 << static_cast<long long>(numeric_limits<short>::min()) - 1;
+ wistringstream iss4(oss4.str());
+ iss4 >> s4;
+ VERIFY( s4 == numeric_limits<short>::min() );
+ VERIFY( iss4.fail() && iss4.eof() );
+
+ int i1 = 0;
+ wostringstream oss5;
+ oss5 << numeric_limits<int>::max();
+ wistringstream iss5(oss5.str());
+ iss5 >> i1;
+ VERIFY( i1 == numeric_limits<int>::max() );
+ VERIFY( !iss5.fail() && iss5.eof() );
+
+ int i2 = 0;
+ wostringstream oss6;
+ oss6 << static_cast<long long>(numeric_limits<int>::max()) + 1;
+ wistringstream iss6(oss6.str());
+ iss6 >> i2;
+ VERIFY( i1 == numeric_limits<int>::max() );
+ VERIFY( iss6.fail() && iss6.eof() );
+
+ int i3 = 0;
+ wostringstream oss7;
+ oss7 << numeric_limits<int>::min();
+ wistringstream iss7(oss7.str());
+ iss7 >> i3;
+ VERIFY( i3 == numeric_limits<int>::min() );
+ VERIFY( !iss7.fail() && iss7.eof() );
+
+ int i4 = 0;
+ wostringstream oss8;
+ oss8 << static_cast<long long>(numeric_limits<int>::min()) - 1;
+ wistringstream iss8(oss8.str());
+ iss8 >> i4;
+ VERIFY( i4 == numeric_limits<int>::min() );
+ VERIFY( iss8.fail() && iss8.eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..983aac745
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_badbit_throw.cc
@@ -0,0 +1,73 @@
+// 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 <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_get_wchar_t);
+ wistringstream stream(L"jaylib - champion sound");
+ stream.imbue(loc);
+
+ stream.exceptions(ios_base::badbit);
+ VERIFY( stream.rdstate() == ios_base::goodbit );
+
+ try
+ {
+ T i;
+ 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>();
+
+ test_badbit<void*>();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc
new file mode 100644
index 000000000..0a31e91dc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc
@@ -0,0 +1,65 @@
+// 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 <testsuite_hooks.h>
+
+// libstdc++/10093
+template<typename T>
+void test_failbit()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream stream(L"jaylib - champion sound");
+ stream.exceptions(ios_base::failbit);
+
+ try
+ {
+ T i;
+ stream >> i;
+ VERIFY( false );
+ }
+ catch (const ios_base::failure&)
+ {
+ // stream should set failbit and throw ios_base::failure.
+ VERIFY( stream.fail() );
+ VERIFY( !stream.bad() );
+ VERIFY( !stream.eof() );
+ }
+ catch(...)
+ { VERIFY( false ); }
+}
+
+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>();
+
+ test_failbit<void*>();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit_throw.cc
new file mode 100644
index 000000000..b3a1b7614
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit_throw.cc
@@ -0,0 +1,68 @@
+// 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 <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_get_wchar_t);
+ wistringstream stream(L"jaylib - champion sound");
+ stream.imbue(loc);
+
+ stream.exceptions(ios_base::failbit);
+
+ try
+ {
+ T i;
+ 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>();
+
+ test_failbit<void*>();
+
+ return 0;
+}