summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_istream
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/cons/3.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/exceptions/char/9561.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/exceptions/wchar_t/9561.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc123
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc47
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc148
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc67
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc51
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc134
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/11.cc56
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/9555-ia.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc101
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_badbit_throw.cc75
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc66
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit_throw.cc68
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/pod/3983-1.cc68
-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
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/1.cc109
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/2.cc91
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/3.cc93
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/4.cc93
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/pod/3983-2.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/1.cc80
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/11095-i.cc52
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/2.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/3.cc91
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc90
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/9555-ic.cc62
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/1.cc141
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/26181.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/3.cc51
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9318-in.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9424-in.cc105
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9555-io.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/error_failbit.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_badbit_throw.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_failbit_throw.cc80
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc67
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc137
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc56
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc103
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc80
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/char/1.cc123
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/char/3.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/1.cc120
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/3.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/1.cc120
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/2.cc99
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/3.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/4.cc99
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc88
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/char/6.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/1.cc117
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/2.cc98
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/3.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/4.cc103
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc88
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/6.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc78
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc87
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc98
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc47
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc67
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc75
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc87
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc94
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc45
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/char/1.cc92
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc40
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/1.cc89
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/12296.cc40
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc47
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc75
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/putback/wchar_t/1.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc69
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-1.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-2.cc64
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/8258.cc48
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-1.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-2.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/8258.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/requirements/base_classes.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/requirements/explicit_instantiation.cc36
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/requirements/typedefs.cc39
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc48
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-1.cc52
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-2.cc52
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc87
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc128
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/sstream.cc136
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/2.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-1.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-2.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/exceptions_badbit_throw.cc87
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc124
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc134
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/1.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc41
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/2.cc51
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/pod/1.cc166
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/1.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc41
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/2.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/3.cc42
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc68
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc88
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/sstream.cc94
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/1.cc64
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/2.cc42
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/exceptions_badbit_throw.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc84
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc90
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ws/char/1.cc77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/ws/wchar_t/1.cc74
163 files changed, 11763 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/cons/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/cons/3.cc
new file mode 100644
index 000000000..3b2cb845e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/cons/3.cc
@@ -0,0 +1,53 @@
+// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+// 2005, 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.8.1.1 - Template class basic_filebuf
+// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
+
+#include <istream>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/2020
+// should be able to use custom char_type, custom traits type
+void test07()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::basic_istream<__gnu_test::pod_ushort> gnu_istr;
+
+ try
+ { gnu_istr obj(0); }
+ catch(std::exception& obj)
+ {
+ test = false;
+ VERIFY( test );
+ }
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
+
+
+
+// more surf!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/char/9561.cc b/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/char/9561.cc
new file mode 100644
index 000000000..3c8b37952
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/char/9561.cc
@@ -0,0 +1,60 @@
+// 2003-03-08 Jerry Quinn <jlquinn@optonline.net>
+
+// 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 <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// libstdc++/9561
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ __gnu_test::fail_streambuf b;
+ std::istream strm (&b);
+ strm.exceptions (std::ios::badbit);
+ int i = 0;
+
+ try
+ {
+ i = strm.get();
+ i = strm.get();
+ i = strm.get();
+ }
+ catch (__gnu_test::underflow_error&)
+ {
+ // strm should throw facet_error and not do anything else
+ VERIFY(strm.bad());
+ }
+ catch (...)
+ {
+ VERIFY(false);
+ }
+
+ VERIFY(i == 's');
+}
+
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/wchar_t/9561.cc b/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/wchar_t/9561.cc
new file mode 100644
index 000000000..a05228411
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/exceptions/wchar_t/9561.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/>.
+
+#include <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// libstdc++/9561
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ __gnu_test::fail_wstreambuf b;
+ std::wistream strm (&b);
+ strm.exceptions (std::wios::badbit);
+ wchar_t i = 0;
+
+ try
+ {
+ i = strm.get();
+ i = strm.get();
+ i = strm.get();
+ }
+ catch (__gnu_test::underflow_error&)
+ {
+ // strm should throw facet_error and not do anything else
+ VERIFY(strm.bad());
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ VERIFY( i == L's' );
+}
+
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc
new file mode 100644
index 000000000..a8d91695b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/01.cc
@@ -0,0 +1,123 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 2002, 2003, 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::string str_01;
+std::string str_02("true false 0 1 110001");
+std::string str_03("-19999999 777777 -234234 233 -234 33 1 66300.25 .315 1.5");
+std::string str_04("0123");
+
+std::stringbuf isbuf_01(std::ios_base::in);
+std::stringbuf isbuf_02(str_02, std::ios_base::in);
+std::stringbuf isbuf_03(str_03, std::ios_base::in);
+std::stringbuf isbuf_04(str_04, std::ios_base::in);
+
+std::istream is_01(0);
+std::istream is_02(&isbuf_02);
+std::istream is_03(&isbuf_03);
+std::istream is_04(&isbuf_04);
+std::stringstream 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/char/02.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc
new file mode 100644
index 000000000..3c82f3b91
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/02.cc
@@ -0,0 +1,47 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 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/>.
+
+// 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::string str_01("20000AB");
+ std::stringbuf strb_01(str_01, std::ios_base::in);
+ std::istream is(&strb_01);
+
+ int n = 15;
+ is >> n;
+ VERIFY( n == 20000 );
+ char c = is.peek();
+ VERIFY( c == 65 );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc
new file mode 100644
index 000000000..a2d983573
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/03.cc
@@ -0,0 +1,46 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+bool test03()
+{
+ std::stringbuf sbuf;
+ std::istream istr(&sbuf);
+ std::ostream ostr(&sbuf);
+
+ bool test __attribute__((unused)) = true;
+ long l01;
+ ostr << "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/char/06.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc
new file mode 100644
index 000000000..bfe7042f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/06.cc
@@ -0,0 +1,60 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 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/>.
+
+// 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;
+ char c;
+ std::string s("205,199,144");
+ std::istringstream is(s);
+
+ is >> h4; // 205
+ VERIFY( h4 == 205 );
+ is >> c; // ','
+ VERIFY( c == ',' );
+
+ is >> h4; // 199
+ VERIFY( h4 == 199 );
+ is >> c; // ','
+ VERIFY( c == ',' );
+
+ is >> h4; // 144
+ VERIFY( is.rdstate() == std::ios_base::eofbit );
+ VERIFY( h4 == 144 );
+ is >> c; // EOF
+ VERIFY( c == ',' );
+ 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/char/07.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc
new file mode 100644
index 000000000..45975870c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc
@@ -0,0 +1,148 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 2002, 2003, 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<char>
+ {
+ 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::string s1("205,199 23,445.25 1,024,365 123,22,24");
+ std::istringstream 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::string s2(",111 4,,4 0.25,345 5..25 156,, 1,000000 1000000 1234,567");
+ h3 = h4 = h2 = 0;
+ f1 = 0.0;
+ const char c_control = '?';
+ char 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 == ',' );
+ 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 == ',' );
+ is >> c;
+ VERIFY( c == '4' );
+ VERIFY( is.good() );
+
+ is >> f1;
+ VERIFY( f1 == 0.25 );
+ VERIFY( is.good() );
+ is >> c;
+ VERIFY( c == ',' );
+ 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 == ',' ); // 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/char/08.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc
new file mode 100644
index 000000000..99c017aa5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/08.cc
@@ -0,0 +1,67 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+namespace std {
+ class test_numpunct2 : public numpunct<char>
+ {
+ 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::string s1("1,22 205,19 22,123,22");
+
+ std::istringstream 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/char/09.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc
new file mode 100644
index 000000000..bf64448bf
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/09.cc
@@ -0,0 +1,51 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 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/>.
+
+// 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::string st("2.456e3-+0.567e-2");
+ std::stringbuf sb(st);
+ std::istream is(&sb);
+ double f1 = 0, f2 = 0;
+ char c;
+ (is>>std::ws) >> f1;
+ (is>>std::ws) >> c;
+ (is>>std::ws) >> f2;
+ test = f1 == 2456;
+ VERIFY( f2 == 0.00567 );
+ VERIFY( c == '-' );
+ return test;
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
new file mode 100644
index 000000000..bd7241b38
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/10.cc
@@ -0,0 +1,134 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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::string str_01("0 00 000 +0 +0 -0");
+ std::stringbuf isbuf_01(str_01);
+ std::istream 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::string str_02("0x32 0X33 033 33");
+ std::stringbuf isbuf_02(str_02);
+ std::istream 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::stringbuf isbuf_03(str_02);
+ std::istream is_03(&isbuf_03);
+ char c;
+ int m;
+
+ is_03 >> std::dec >> n >> c >> m;
+ VERIFY( n == 0 );
+ VERIFY( c == 'x' );
+ VERIFY( m == 32 );
+
+ is_03 >> std::oct >> m >> c >> n;
+ VERIFY( m == 0 );
+ VERIFY( c == '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::string str_04("3. 4.5E+2a5E-3 .6E1");
+ std::stringbuf isbuf_04(str_04);
+ std::istream 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::string str_05("0E20 5Ea E16");
+ std::stringbuf isbuf_05(str_05);
+ std::istream 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 == '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/char/11.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/11.cc
new file mode 100644
index 000000000..cffb39a76
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/11.cc
@@ -0,0 +1,56 @@
+// 1999-04-12 bkoz
+
+// 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/>.
+
+// 27.6.1.2.2 arithmetic extractors
+
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <cstdlib>
+#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 char* cstrlit = "0x2a";
+
+ // sanity check via 'C' library call
+ char* err;
+ long l = std::strtol(cstrlit, &err, 0);
+
+ std::istringstream iss(cstrlit);
+ iss.setf(std::ios::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/char/12.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc
new file mode 100644
index 000000000..70f74fd7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc
@@ -0,0 +1,77 @@
+// 1999-04-12 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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::string st;
+ std::string part = "1234567890123456789012345678901234567890";
+ for (std::size_t i = 0; i < digits_overflow / part.size() + 1; ++i)
+ st += part;
+ std::stringbuf sb(st);
+ std::istream 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/char/13.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc
new file mode 100644
index 000000000..ac5533a49
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc
@@ -0,0 +1,70 @@
+// 1999-04-12 bkoz
+
+// 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/>.
+
+// 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 char* l2 = "1.2345678901234567890123456789012345678901234567890123456"
+ " "
+ "1246.9";
+
+ // 1
+ // used to core.
+ double d;
+ istringstream 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;
+ string digits;
+ for (int j = 0; j < max_digits; ++j)
+ digits += '1';
+ istringstream iss2(digits);
+ iss2 >> i;
+ VERIFY( !iss2.fail() );
+
+ digits += '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/char/9555-ia.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/9555-ia.cc
new file mode 100644
index 000000000..44a695def
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/9555-ia.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 <istream>
+#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::istream 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/char/dr696.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc
new file mode 100644
index 000000000..a1a71cc57
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/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;
+ ostringstream oss1;
+ oss1 << numeric_limits<short>::max();
+ istringstream iss1(oss1.str());
+ iss1 >> s1;
+ VERIFY( s1 == numeric_limits<short>::max() );
+ VERIFY( !iss1.fail() && iss1.eof() );
+
+ short s2 = 0;
+ ostringstream oss2;
+ oss2 << static_cast<long long>(numeric_limits<short>::max()) + 1;
+ istringstream iss2(oss2.str());
+ iss2 >> s2;
+ VERIFY( s2 == numeric_limits<short>::max() );
+ VERIFY( iss2.fail() && iss2.eof() );
+
+ short s3 = 0;
+ ostringstream oss3;
+ oss3 << numeric_limits<short>::min();
+ istringstream iss3(oss3.str());
+ iss3 >> s3;
+ VERIFY( s3 == numeric_limits<short>::min() );
+ VERIFY( !iss3.fail() && iss3.eof() );
+
+ short s4 = 0;
+ ostringstream oss4;
+ oss4 << static_cast<long long>(numeric_limits<short>::min()) - 1;
+ istringstream iss4(oss4.str());
+ iss4 >> s4;
+ VERIFY( s4 == numeric_limits<short>::min() );
+ VERIFY( iss4.fail() && iss4.eof() );
+
+ int i1 = 0;
+ ostringstream oss5;
+ oss5 << numeric_limits<int>::max();
+ istringstream iss5(oss5.str());
+ iss5 >> i1;
+ VERIFY( i1 == numeric_limits<int>::max() );
+ VERIFY( !iss5.fail() && iss5.eof() );
+
+ int i2 = 0;
+ ostringstream oss6;
+ oss6 << static_cast<long long>(numeric_limits<int>::max()) + 1;
+ istringstream iss6(oss6.str());
+ iss6 >> i2;
+ VERIFY( i1 == numeric_limits<int>::max() );
+ VERIFY( iss6.fail() && iss6.eof() );
+
+ int i3 = 0;
+ ostringstream oss7;
+ oss7 << numeric_limits<int>::min();
+ istringstream iss7(oss7.str());
+ iss7 >> i3;
+ VERIFY( i3 == numeric_limits<int>::min() );
+ VERIFY( !iss7.fail() && iss7.eof() );
+
+ int i4 = 0;
+ ostringstream oss8;
+ oss8 << static_cast<long long>(numeric_limits<int>::min()) - 1;
+ istringstream 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/char/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..30bfa334a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_badbit_throw.cc
@@ -0,0 +1,75 @@
+// 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_get_char);
+ istringstream stream("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/char/exceptions_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc
new file mode 100644
index 000000000..b14647126
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc
@@ -0,0 +1,66 @@
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/10093
+template<typename T>
+void test_failbit()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream stream("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/char/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit_throw.cc
new file mode 100644
index 000000000..23237ccf1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit_throw.cc
@@ -0,0 +1,68 @@
+// 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_get_char);
+ istringstream stream("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;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/pod/3983-1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/pod/3983-1.cc
new file mode 100644
index 000000000..311b4d410
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/pod/3983-1.cc
@@ -0,0 +1,68 @@
+// 2001-06-05 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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/>.
+
+
+// 27.4.2.1.6 class ios_base::init
+
+#include <sstream>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/3983
+// Sentry uses locale info, so have to try one formatted input/output.
+void test03()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_istream<pod_ushort> istream_type;
+
+ stringbuf_type strbuf01;
+ istream_type iss(&strbuf01);
+
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ int i;
+ iss >> i;
+ }
+ catch (std::bad_cast& obj)
+ { }
+ catch (std::exception& obj)
+ { VERIFY( false ); }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test03();
+ return 0;
+}
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;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/1.cc
new file mode 100644
index 000000000..7e4387d31
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/1.cc
@@ -0,0 +1,109 @@
+// 1999-07-26 bkoz
+
+// Copyright (C) 1999, 2003, 2005, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string str_01;
+ const std::string str_02("coltrane playing 'softly as a morning sunrise'");
+ const std::string str_03("coltrane");
+
+ std::stringbuf isbuf_01(std::ios_base::in);
+ std::stringbuf isbuf_02(str_02, std::ios_base::in);
+ std::istream is_01(0);
+ std::istream is_02(&isbuf_02);
+
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT*)
+ const int n = 20;
+ char array1[n];
+ array1[0] = '\0';
+ typedef std::ios::traits_type ctraits_type;
+ ctraits_type::int_type i1, i2;
+
+ state1 = is_01.rdstate();
+ i1 = ctraits_type::length(array1);
+ is_01 >> array1; // should snake 0 characters, not alter stream state
+ i2 = ctraits_type::length(array1);
+ state2 = is_01.rdstate();
+ VERIFY( i1 == i2 );
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake "coltrane"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( array1[str_03.size() - 1] == 'e' );
+ array1[str_03.size()] = '\0';
+ VERIFY( !str_03.compare(0, str_03.size(), array1) );
+ std::istream::int_type int1 = is_02.peek(); // should be ' '
+ VERIFY( int1 == ' ' );
+
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake "playing" as sentry "eats" ws
+ state2 = is_02.rdstate();
+ int1 = is_02.peek(); // should be ' '
+ VERIFY( int1 == ' ' );
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, unsigned char*)
+ unsigned char array2[n];
+ state1 = is_02.rdstate();
+ is_02 >> array2; // should snake 'softly
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( array2[0] == '\'' );
+ VERIFY( array2[1] == 's' );
+ VERIFY( array2[6] == 'y' );
+ int1 = is_02.peek(); // should be ' '
+ VERIFY( int1 == ' ' );
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, signed char*)
+ signed char array3[n];
+ state1 = is_02.rdstate();
+ is_02 >> array3; // should snake "as"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( array3[0] == 'a' );
+ VERIFY( array3[1] == 's' );
+ int1 = is_02.peek(); // should be ' '
+ VERIFY( int1 == ' ' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc
new file mode 100644
index 000000000..0462df0c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/11095-i.cc
@@ -0,0 +1,54 @@
+// 2003-06-05 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/11095
+// operator>>(basic_istream&, _CharT*)
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string str_01("Consoli ");
+
+ std::stringbuf isbuf_01(str_01, std::ios_base::in);
+ std::istream is_01(&isbuf_01);
+
+ std::ios_base::iostate state1, state2;
+
+ char array1[10];
+ typedef std::ios::traits_type ctraits_type;
+
+ is_01.width(-60);
+ state1 = is_01.rdstate();
+ is_01 >> array1;
+ state2 = is_01.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, "Consoli", 7) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/2.cc
new file mode 100644
index 000000000..812d54134
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/2.cc
@@ -0,0 +1,91 @@
+// 1999-07-26 bkoz
+
+// Copyright (C) 1999, 2003, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ typedef std::ios::traits_type ctraits_type;
+
+ bool test __attribute__((unused)) = true;
+ std::string str_01;
+ const std::string str_02("or coltrane playing tunji with jimmy garrison");
+ const std::string str_03("coltrane");
+
+ std::stringbuf isbuf_01(std::ios_base::in);
+ std::stringbuf isbuf_02(str_02, std::ios_base::in);
+ std::istream is_01(0);
+ std::istream is_02(&isbuf_02);
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT&)
+ char c1 = 'c', c2 = 'c';
+ state1 = is_01.rdstate();
+ is_01 >> c1;
+ state2 = is_01.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( c1 == c2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ state1 = is_02.rdstate();
+ is_02 >> c1;
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( c1 == 'o' );
+ is_02 >> c1;
+ is_02 >> c1;
+ VERIFY( c1 == 'c' );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, unsigned char&)
+ unsigned char uc1 = 'c';
+ state1 = is_02.rdstate();
+ is_02 >> uc1;
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( uc1 == 'o' );
+ is_02 >> uc1;
+ is_02 >> uc1;
+ VERIFY( uc1 == 't' );
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, signed char&)
+ signed char sc1 = 'c';
+ state1 = is_02.rdstate();
+ is_02 >> sc1;
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( sc1 == 'r' );
+ is_02 >> sc1;
+ is_02 >> sc1;
+ VERIFY( sc1 == 'n' );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/3.cc
new file mode 100644
index 000000000..551cb111a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/3.cc
@@ -0,0 +1,93 @@
+// 1999-07-26 bkoz
+
+// Copyright (C) 1999, 2003, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string str_01;
+ const std::string str_02("coltrane playing 'softly as a morning sunrise'");
+ const std::string str_03("coltrane");
+
+ std::stringbuf isbuf_01(std::ios_base::in);
+ std::stringbuf isbuf_02(str_02, std::ios_base::in);
+ std::istream is_01(0);
+ std::istream is_02(&isbuf_02);
+
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT*)
+ int n = 20;
+ char array1[n];
+ typedef std::ios::traits_type ctraits_type;
+
+ // testing with width() control enabled.
+ is_02.width(8);
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake "coltran"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, "coltran", 7) );
+
+ is_02.width(1);
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake nothing, set failbit
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == statefail );
+ VERIFY( array1[0] == '\0' );
+
+ is_02.width(8);
+ is_02.clear();
+ state1 = is_02.rdstate();
+ VERIFY( !state1 );
+ is_02 >> array1; // should snake "e"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, "e", 1) );
+
+ // testing for correct exception setting
+ const std::string str_04(" impulse!!");
+ std::stringbuf isbuf_03(str_04, std::ios_base::in);
+ std::stringbuf isbuf_04(str_04, std::ios_base::in);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+
+ is_03 >> array1;
+ VERIFY( !ctraits_type::compare(array1,"impulse!!", 10) );
+ VERIFY( is_03.rdstate() == std::ios_base::eofbit );
+
+ is_04.width(9);
+ is_04 >> array1;
+ VERIFY( ! std::ios::traits_type::compare(array1,"impulse!", 9) );
+ VERIFY( !is_04.rdstate() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/4.cc
new file mode 100644
index 000000000..68aefcbf3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/4.cc
@@ -0,0 +1,93 @@
+// 2005-07-22 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2006, 2007, 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.1.2.3 basic_istream::operator>>
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks)
+{
+ string ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (string::size_type j = 0; j < len; ++j)
+ ret.push_back('a' + rand() % 26);
+ len *= 2;
+ ret.push_back(' ');
+ }
+ return ret;
+}
+
+void check(istream& stream, const string& str, unsigned nchunks)
+{
+ bool test __attribute__((unused)) = true;
+
+ char* chunk = new char[str.size()];
+ memset(chunk, 'X', str.size());
+
+ string::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream >> chunk)
+ {
+ index_new = str.find(' ', index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ memset(chunk, 'X', str.size());
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+
+ delete[] chunk;
+}
+
+// istream& operator>>(istream&, charT*)
+void test01()
+{
+ const char filename[] = "inserters_extractors-4.txt";
+
+ const unsigned nchunks = 10;
+ const string data = prepare(666, nchunks);
+
+ ofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc
new file mode 100644
index 000000000..41eb6e3f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc
@@ -0,0 +1,70 @@
+// 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 <istream>
+#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::istream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ test = false;
+ VERIFY( test );
+ }
+}
+
+int main()
+{
+ char c = 'a';
+ unsigned char uc = 'a';
+ signed char sc = 'a';
+ char* cp = &c;
+ signed char* scp = &sc;
+ unsigned char* ucp = &uc;
+
+ testthrow(c);
+ testthrow(uc);
+ testthrow(sc);
+ testthrow(cp);
+ testthrow(scp);
+ testthrow(ucp);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc
new file mode 100644
index 000000000..a2e480ebc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/char/9826.cc
@@ -0,0 +1,53 @@
+// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2002, 2003, 2005, 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.7.4 - Template class basic_stringstream
+// NB: This file is for testing basic_stringstream with NO OTHER INCLUDES.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// { dg-do compile }
+
+// libstdc++/9826
+void test02()
+{
+ using namespace std;
+ using __gnu_test::pod_char;
+
+ basic_stringstream<pod_char, char_traits<pod_char> > sstr;
+ // 1
+ basic_string<pod_char, char_traits<pod_char> > str;
+ sstr >> str;
+
+ // 2
+ pod_char* chr = 0;
+ sstr >> chr;
+
+ // 3
+ sstr >> ws;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/pod/3983-2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/pod/3983-2.cc
new file mode 100644
index 000000000..ff70fda76
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/pod/3983-2.cc
@@ -0,0 +1,74 @@
+// 2001-06-05 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.4.2.1.6 class ios_base::init
+
+#include <sstream>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/3983
+// Sentry uses locale info, so have to try one formatted input/output.
+void test03()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef pod_ushort::value_type value_type;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_istream<pod_ushort> istream_type;
+
+ stringbuf_type strbuf01;
+ istream_type iss(&strbuf01);
+
+ bool test __attribute__((unused)) = true;
+
+ // input streams
+ pod_ushort arr[6] = { { value_type('a') }, { value_type('b') },
+ { value_type('c') }, { value_type('d') },
+ { value_type('e') } };
+
+ try
+ {
+ iss >> arr;
+ }
+ catch (std::bad_cast& obj)
+ { }
+ catch (std::exception& obj)
+ { VERIFY( false ); }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/1.cc
new file mode 100644
index 000000000..f7b749a5d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/1.cc
@@ -0,0 +1,80 @@
+// Copyright (C) 2004, 2005, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str_01;
+ const std::wstring str_02(L"coltrane playing 'softly as a morning sunrise'");
+ const std::wstring str_03(L"coltrane");
+
+ std::wstringbuf isbuf_01(std::ios_base::in);
+ std::wstringbuf isbuf_02(str_02, std::ios_base::in);
+ std::wistream is_01(0);
+ std::wistream is_02(&isbuf_02);
+
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT*)
+ const int n = 20;
+ wchar_t array1[n];
+ array1[0] = L'\0';
+ typedef std::wios::traits_type ctraits_type;
+ ctraits_type::int_type i1, i2;
+
+ state1 = is_01.rdstate();
+ i1 = ctraits_type::length(array1);
+ is_01 >> array1; // should snake 0 characters, not alter stream state
+ i2 = ctraits_type::length(array1);
+ state2 = is_01.rdstate();
+ VERIFY( i1 == i2 );
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake L"coltrane"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( array1[str_03.size() - 1] == L'e' );
+ array1[str_03.size()] = L'\0';
+ VERIFY( !str_03.compare(0, str_03.size(), array1) );
+ std::wistream::int_type int1 = is_02.peek(); // should be L' '
+ VERIFY( int1 == L' ' );
+
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake L"playing" as sentry "eats" ws
+ state2 = is_02.rdstate();
+ int1 = is_02.peek(); // should be L' '
+ VERIFY( int1 == L' ' );
+ VERIFY( state1 == state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/11095-i.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/11095-i.cc
new file mode 100644
index 000000000..334311e9f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/11095-i.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2004, 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/11095
+// operator>>(basic_istream&, _CharT*)
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01(L"Consoli ");
+
+ std::wstringbuf isbuf_01(str_01, std::ios_base::in);
+ std::wistream is_01(&isbuf_01);
+
+ std::ios_base::iostate state1, state2;
+
+ wchar_t array1[10];
+ typedef std::wios::traits_type ctraits_type;
+
+ is_01.width(-60);
+ state1 = is_01.rdstate();
+ is_01 >> array1;
+ state2 = is_01.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, L"Consoli", 7) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/2.cc
new file mode 100644
index 000000000..a697ef2b2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/2.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2004, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str_01;
+ const std::wstring str_02(L"or coltrane playing tunji with jimmy garrison");
+ const std::wstring str_03(L"coltrane");
+
+ std::wstringbuf isbuf_01(std::ios_base::in);
+ std::wstringbuf isbuf_02(str_02, std::ios_base::in);
+ std::wistream is_01(0);
+ std::wistream is_02(&isbuf_02);
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT&)
+ wchar_t c1 = L'c', c2 = L'c';
+ state1 = is_01.rdstate();
+ is_01 >> c1;
+ state2 = is_01.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( c1 == c2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ state1 = is_02.rdstate();
+ is_02 >> c1;
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( c1 == L'o' );
+ is_02 >> c1;
+ is_02 >> c1;
+ VERIFY( c1 == L'c' );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/3.cc
new file mode 100644
index 000000000..6ea22e395
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/3.cc
@@ -0,0 +1,91 @@
+// Copyright (C) 2004, 2009, 2010 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.1.2.3 character extractors
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str_01;
+ const std::wstring str_02(L"coltrane playing 'softly as a morning sunrise'");
+ const std::wstring str_03(L"coltrane");
+
+ std::wstringbuf isbuf_01(std::ios_base::in);
+ std::wstringbuf isbuf_02(str_02, std::ios_base::in);
+ std::wistream is_01(0);
+ std::wistream is_02(&isbuf_02);
+
+ std::ios_base::iostate state1, state2, statefail;
+ statefail = std::ios_base::failbit;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(istream&, _CharT*)
+ int n = 20;
+ wchar_t array1[n];
+ typedef std::wios::traits_type ctraits_type;
+
+ // testing with width() control enabled.
+ is_02.width(8);
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake L"coltran"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, L"coltran", 7) );
+
+ is_02.width(1);
+ state1 = is_02.rdstate();
+ is_02 >> array1; // should snake nothing, set failbit
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == statefail );
+ VERIFY( array1[0] == L'\0' );
+
+ is_02.width(8);
+ is_02.clear();
+ state1 = is_02.rdstate();
+ VERIFY( !state1 );
+ is_02 >> array1; // should snake L"e"
+ state2 = is_02.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !ctraits_type::compare(array1, L"e", 1) );
+
+ // testing for correct exception setting
+ const std::wstring str_04(L" impulse!!");
+ std::wstringbuf isbuf_03(str_04, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_04, std::ios_base::in);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+
+ is_03 >> array1;
+ VERIFY( !ctraits_type::compare(array1, L"impulse!!", 10) );
+ VERIFY( is_03.rdstate() == std::ios_base::eofbit );
+
+ is_04.width(9);
+ is_04 >> array1;
+ VERIFY( !ctraits_type::compare(array1, L"impulse!", 9) );
+ VERIFY( !is_04.rdstate() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc
new file mode 100644
index 000000000..2e27c800e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc
@@ -0,0 +1,90 @@
+// 2005-07-22 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 2006, 2007, 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.1.2.3 basic_istream::operator>>
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring prepare(wstring::size_type len, unsigned nchunks)
+{
+ wstring ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (wstring::size_type j = 0; j < len; ++j)
+ ret.push_back(L'a' + rand() % 26);
+ len *= 2;
+ ret.push_back(L' ');
+ }
+ return ret;
+}
+
+void check(wistream& stream, const wstring& str, unsigned nchunks)
+{
+ bool test __attribute__((unused)) = true;
+
+ wchar_t* chunk = new wchar_t[str.size()];
+ wmemset(chunk, L'X', str.size());
+
+ wstring::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream >> chunk)
+ {
+ index_new = str.find(' ', index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ wmemset(chunk, L'X', str.size());
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+
+ delete[] chunk;
+}
+
+// istream& operator>>(istream&, charT*)
+void test01()
+{
+ const char filename[] = "inserters_extractors-4.txt";
+
+ const unsigned nchunks = 10;
+ const wstring data = prepare(666, nchunks);
+
+ wofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/9555-ic.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/9555-ic.cc
new file mode 100644
index 000000000..a7ba5cd91
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_character/wchar_t/9555-ic.cc
@@ -0,0 +1,62 @@
+// 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::wios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ test = false;
+ VERIFY( test );
+ }
+}
+
+int main()
+{
+ wchar_t c = L'a';
+ wchar_t* cp = &c;
+
+ testthrow(c);
+ testthrow(cp);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/1.cc
new file mode 100644
index 000000000..854dc7c85
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/1.cc
@@ -0,0 +1,141 @@
+// 1999-07-28 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+// 2009, 2010
+// 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.1.2.3 basic_istream::operator>>
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// stringbufs.
+void test01()
+{
+ typedef std::ios::traits_type ctraits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string str_01;
+ const std::string str_02("art taylor kickin it on DAKAR");
+ std::string strtmp;
+
+ std::stringbuf isbuf_00(std::ios_base::in);
+ std::stringbuf isbuf_01(std::ios_base::in | std::ios_base::out);
+ std::stringbuf isbuf_02(str_01, std::ios_base::in);
+ std::stringbuf isbuf_03(str_01, std::ios_base::in | std::ios_base::out);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+ std::stringbuf isbuf_05(str_02, std::ios_base::in | std::ios_base::out);
+
+ std::istream is_00(0);
+ std::istream is_01(&isbuf_01);
+ std::istream is_02(&isbuf_02);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::istream is_05(&isbuf_05);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_streambuf*)
+
+ // null istream to empty in_buf
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_00;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_00.str() == str_01 );
+
+ // null istream to empty in_out_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_01;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_01.str() == str_01 );
+
+ // null istream to full in_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_04;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_04.str() == str_02 );
+
+ // null istream to full in_out_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_05;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_05.str() == str_02 );
+
+ // empty but non-null istream to full in_buf
+ state1 = is_02.rdstate();
+ is_02 >> &isbuf_04;
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_04.str() == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_04.sgetc() == 'a' );
+
+ // empty but non-null istream to full in_out_buf
+ is_02.clear(std::ios_base::goodbit);
+ state1 = is_02.rdstate();
+ is_02 >> &isbuf_05;
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_05.str() == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_05.sgetc() == 'a' );
+
+ // full istream to empty in_buf (need out_buf, you know?)
+ state1 = is_04.rdstate();
+ is_04 >> &isbuf_02;
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_02.str() == str_01 ); // as only an "in" buffer
+ VERIFY( isbuf_02.sgetc() == ctraits_type::eof() );
+ VERIFY( is_04.peek() == ctraits_type::eof() ); // as failed
+
+ // full istream to empty in_out_buf
+ is_04.clear(std::ios_base::goodbit);
+ state1 = is_04.rdstate();
+ is_04 >> &isbuf_03;
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( state2 == stateeof );
+ strtmp = isbuf_03.str();
+ VERIFY( strtmp == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_03.sgetc() == 'a' );
+ VERIFY( is_04.peek() == ctraits_type::eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc
new file mode 100644
index 000000000..8a71b88ee
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc
@@ -0,0 +1,60 @@
+// 1999-07-28 bkoz
+
+// Copyright (C) 1999, 2001, 2003, 2004, 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.1.2.3 basic_istream::operator>>
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// filebufs.
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char name_01[] = "istream_extractor_other-1.txt"; //read
+ const char name_02[] = "istream_extractor_other-2.txt"; //write
+
+ std::filebuf fbin, fbout;
+ fbin.open(name_01, std::ios_base::in);
+ fbout.open(name_02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( fbin.is_open() );
+ VERIFY( fbout.is_open() );
+
+ if (test)
+ {
+ std::istream is(&fbin);
+ is.unsetf(std::ios_base::skipws);
+ is >> &fbout;
+ }
+
+ fbout.close();
+ fbin.close();
+ VERIFY( !fbin.is_open() );
+ VERIFY( !fbout.is_open() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/26181.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/26181.cc
new file mode 100644
index 000000000..8ad53480e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/26181.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2006, 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26181
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef istringstream::pos_type pos_type;
+
+ istringstream iss("Territoires de l'Oubli");
+ ostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(22) );
+
+ iss.get();
+ VERIFY( iss.tellg() == pos_type(-1) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/3.cc
new file mode 100644
index 000000000..01c1645b5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/3.cc
@@ -0,0 +1,51 @@
+// 1999-07-28 bkoz
+
+// Copyright (C) 1999, 2001, 2003, 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.1.2.3 basic_istream::operator>>
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(ios_base& (*pf) (ios_base&))
+ {
+ int i = 0;
+ std::istringstream iss(" 43");
+ iss >> std::noskipws >> i;
+ VERIFY ( !iss ); //should set failbit
+ }
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_ios& (*pf) (basic_ios&))
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_istream& (*pf) (basic_istream&))
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9318-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9318-in.cc
new file mode 100644
index 000000000..d82ec5604
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9318-in.cc
@@ -0,0 +1,63 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// 27.5.2 template class basic_streambuf
+
+#include <sstream>
+#include <istream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9318
+class Outbuf : public std::streambuf
+{
+public:
+ typedef std::streambuf::traits_type traits_type;
+
+ std::string result() const { return str; }
+
+protected:
+ virtual int_type overflow(int_type c = traits_type::eof())
+ {
+ if (!traits_type::eq_int_type(c, traits_type::eof()))
+ str.push_back(traits_type::to_char_type(c));
+ return traits_type::not_eof(c);
+ }
+
+private:
+ std::string str;
+};
+
+void test09()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::istringstream stream("Bad Moon Rising");
+ Outbuf buf;
+ stream >> &buf;
+
+ VERIFY( buf.result() == "Bad Moon Rising" );
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9424-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9424-in.cc
new file mode 100644
index 000000000..ee630b3f1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9424-in.cc
@@ -0,0 +1,105 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// 27.5.2 template class basic_streambuf
+
+#include <cstring> // for memset, memcmp
+#include <streambuf>
+#include <sstream>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9424
+class Outbuf_2 : public std::streambuf
+{
+ char buf[1];
+
+public:
+ Outbuf_2()
+ {
+ setp(buf, buf + 1);
+ }
+
+ int_type overflow(int_type c)
+ {
+ int_type eof = traits_type::eof();
+
+ if (pptr() < epptr())
+ {
+ if (traits_type::eq_int_type(c, eof))
+ return traits_type::not_eof(c);
+
+ *pptr() = traits_type::to_char_type(c);
+ pbump(1);
+ return c;
+ }
+
+ return eof;
+ }
+};
+
+class Inbuf_2 : public std::streambuf
+{
+ static const char buf[];
+ const char* current;
+ int size;
+
+public:
+ Inbuf_2()
+ {
+ current = buf;
+ size = std::strlen(buf);
+ }
+
+ int_type underflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current);
+ return traits_type::eof();
+ }
+
+ int_type uflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current++);
+ return traits_type::eof();
+ }
+};
+
+const char Inbuf_2::buf[] = "Atteivlis";
+
+void test11()
+{
+ bool test __attribute__((unused)) = true;
+
+ Inbuf_2 inbuf1;
+ std::istream is(&inbuf1);
+ Outbuf_2 outbuf1;
+ is >> &outbuf1;
+ VERIFY( inbuf1.sgetc() == 't' );
+ VERIFY( is.good() );
+}
+
+int main()
+{
+ test11();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9555-io.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9555-io.cc
new file mode 100644
index 000000000..248193c43
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/9555-io.cc
@@ -0,0 +1,59 @@
+// 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 <istream>
+#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::istream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ buf b;
+
+ testthrow(&b);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/error_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/error_failbit.cc
new file mode 100644
index 000000000..cc92d486d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/error_failbit.cc
@@ -0,0 +1,58 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test6()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stringbuf sbuf("", ios_base::out);
+
+ stream >> &sbuf;
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+void test8()
+{
+ bool test __attribute__((unused)) = true;
+ istringstream stream("foo, bar, qux");
+ __gnu_test::fail_streambuf bob;
+
+ stream >> &bob;
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+// libstdc++/9371
+int main()
+{
+ test6();
+ test8();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..0b0ae2318
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_badbit_throw.cc
@@ -0,0 +1,70 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test14()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+ stringbuf sbuf("", ios_base::out);
+
+ try
+ {
+ stream >> &sbuf;
+ }
+ catch (...)
+ { VERIFY(false); }
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+void test16()
+{
+ bool test __attribute__((unused)) = true;
+ istringstream stream("foo, bar, qux");
+ stream.exceptions(ios_base::badbit);
+ __gnu_test::fail_streambuf bob;
+
+ try
+ {
+ stream >> &bob;
+ }
+ catch (...)
+ { VERIFY(false); }
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+// libstdc++/9371
+int main()
+{
+ test14();
+ test16();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_failbit_throw.cc
new file mode 100644
index 000000000..d35587077
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_failbit_throw.cc
@@ -0,0 +1,80 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test10()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stream.exceptions(ios_base::failbit);
+ stringbuf sbuf("", ios_base::out);
+
+ try
+ {
+ stream >> &sbuf;
+ VERIFY(false);
+ }
+ catch (ios_base::failure&)
+ { VERIFY(false); }
+ catch (__gnu_test::underflow_error&)
+ { }
+ catch (...)
+ { VERIFY(false); }
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+void test12()
+{
+ bool test __attribute__((unused)) = true;
+ istringstream stream("foo, bar, qux");
+ stream.exceptions(ios_base::failbit);
+ __gnu_test::fail_streambuf bob;
+
+ try
+ {
+ stream >> &bob;
+ VERIFY(false);
+ }
+ catch (ios_base::failure&)
+ { VERIFY(false); }
+ catch (__gnu_test::overflow_error&)
+ { }
+ catch (...)
+ { VERIFY(false); }
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+ VERIFY((stream.rdstate() & ios_base::badbit) == 0);
+}
+
+// libstdc++/9371
+int main()
+{
+ test10();
+ test12();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc
new file mode 100644
index 000000000..96ba71930
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2003, 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/>.
+
+
+#include <istream>
+#include <ostream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+void test2()
+{
+ bool test __attribute__((unused)) = true;
+ istringstream stream;
+ stream >> static_cast<streambuf*>(0);
+ VERIFY(stream.rdstate() & ios_base::failbit);
+}
+
+void test4()
+{
+ bool test __attribute__((unused)) = true;
+ istringstream stream;
+ stream.exceptions(ios_base::failbit);
+
+ try
+ {
+ stream >> static_cast<streambuf*>(0);
+ VERIFY(false);
+ }
+ catch (ios_base::failure&)
+ {
+ }
+
+ VERIFY(stream.rdstate() & ios_base::failbit);
+}
+
+// libstdc++/9371
+int main()
+{
+ test2();
+ test4();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc
new file mode 100644
index 000000000..ac799b794
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc
@@ -0,0 +1,67 @@
+// 2001-06-05 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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/>.
+
+
+// 27.4.2.1.6 class ios_base::init
+
+#include <sstream>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/3983
+// Sentry uses locale info, so have to try one formatted input/output.
+void test03()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_istream<pod_ushort> istream_type;
+
+ stringbuf_type strbuf01;
+ istream_type iss(&strbuf01);
+
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ iss >> std::ws;
+ }
+ catch (std::bad_cast& obj)
+ { }
+ catch (std::exception& obj)
+ { VERIFY( false ); }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc
new file mode 100644
index 000000000..eab6650b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc
@@ -0,0 +1,137 @@
+// Copyright (C) 2004, 2005, 2006, 2009, 2010 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.1.2.3 basic_istream::operator>>
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// stringbufs.
+void test01()
+{
+ typedef std::wios::traits_type ctraits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01;
+ const std::wstring str_02(L"art taylor kickin it on DAKAR");
+ std::wstring strtmp;
+
+ std::wstringbuf isbuf_00(std::ios_base::in);
+ std::wstringbuf isbuf_01(std::ios_base::in | std::ios_base::out);
+ std::wstringbuf isbuf_02(str_01, std::ios_base::in);
+ std::wstringbuf isbuf_03(str_01, std::ios_base::in | std::ios_base::out);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_05(str_02, std::ios_base::in | std::ios_base::out);
+
+ std::wistream is_00(0);
+ std::wistream is_01(&isbuf_01);
+ std::wistream is_02(&isbuf_02);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::wistream is_05(&isbuf_05);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_streambuf*)
+
+ // null istream to empty in_buf
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_00;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_00.str() == str_01 );
+
+ // null istream to empty in_out_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_01;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_01.str() == str_01 );
+
+ // null istream to full in_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_04;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_04.str() == str_02 );
+
+ // null istream to full in_out_buf
+ is_00.clear(std::ios_base::goodbit);
+ state1 = is_00.rdstate();
+ is_00 >> &isbuf_05;
+ state2 = is_00.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_05.str() == str_02 );
+
+ // empty but non-null istream to full in_buf
+ state1 = is_02.rdstate();
+ is_02 >> &isbuf_04;
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_04.str() == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_04.sgetc() == L'a' );
+
+ // empty but non-null istream to full in_out_buf
+ is_02.clear(std::ios_base::goodbit);
+ state1 = is_02.rdstate();
+ is_02 >> &isbuf_05;
+ state2 = is_02.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_05.str() == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_05.sgetc() == L'a' );
+
+ // full istream to empty in_buf (need out_buf, you know?)
+ state1 = is_04.rdstate();
+ is_04 >> &isbuf_02;
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( isbuf_02.str() == str_01 ); // as only an "in" buffer
+ VERIFY( isbuf_02.sgetc() == ctraits_type::eof() );
+ VERIFY( is_04.peek() == ctraits_type::eof() ); // as failed
+
+ // full istream to empty in_out_buf
+ is_04.clear(std::ios_base::goodbit);
+ state1 = is_04.rdstate();
+ is_04 >> &isbuf_03;
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( !static_cast<bool>(state2 & statefail) );
+ VERIFY( state2 == stateeof );
+ strtmp = isbuf_03.str();
+ VERIFY( strtmp == str_02 ); // as only an "in" buffer
+ VERIFY( isbuf_03.sgetc() == L'a' );
+ VERIFY( is_04.peek() == ctraits_type::eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc
new file mode 100644
index 000000000..b4f3c9a60
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc
@@ -0,0 +1,56 @@
+// Copyright (C) 2004, 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.1.2.3 basic_istream::operator>>
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// filebufs.
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char name_01[] = "wistream_extractor_other-1.txt"; //read
+ const char name_02[] = "wistream_extractor_other-2.txt"; //write
+
+ std::wfilebuf fbin, fbout;
+ fbin.open(name_01, std::ios_base::in);
+ fbout.open(name_02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( fbin.is_open() );
+ VERIFY( fbout.is_open() );
+
+ if (test)
+ {
+ std::wistream is(&fbin);
+ is.unsetf(std::ios_base::skipws);
+ is >> &fbout;
+ }
+
+ fbout.close();
+ fbin.close();
+ VERIFY( !fbin.is_open() );
+ VERIFY( !fbout.is_open() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc
new file mode 100644
index 000000000..4e54e2296
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2006, 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26181
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wistringstream::pos_type pos_type;
+
+ wistringstream iss(L"Territoires de l'Oubli");
+ wostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(22) );
+
+ iss.get();
+ VERIFY( iss.tellg() == pos_type(-1) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc
new file mode 100644
index 000000000..1918f9bb6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2004, 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.1.2.3 basic_istream::operator>>
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(ios_base& (*pf) (ios_base&))
+ {
+ int i = 0;
+ std::wistringstream iss(L" 43");
+ iss >> std::noskipws >> i;
+ VERIFY ( !iss ); //should set failbit
+ }
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_ios& (*pf) (basic_ios&))
+
+ // template<_CharT, _Traits>
+ // basic_istream& operator>>(basic_istream& (*pf) (basic_istream&))
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc
new file mode 100644
index 000000000..c2925f24c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc
@@ -0,0 +1,60 @@
+// 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.5.2 template class basic_streambuf
+
+#include <sstream>
+#include <istream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9318
+class Outbuf : public std::wstreambuf
+{
+public:
+ typedef std::wstreambuf::traits_type traits_type;
+
+ std::wstring result() const { return str; }
+
+protected:
+ virtual int_type overflow(int_type c = traits_type::eof())
+ {
+ if (!traits_type::eq_int_type(c, traits_type::eof()))
+ str.push_back(traits_type::to_char_type(c));
+ return traits_type::not_eof(c);
+ }
+
+private:
+ std::wstring str;
+};
+
+void test09()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wistringstream stream(L"Bad Moon Rising");
+ Outbuf buf;
+ stream >> &buf;
+
+ VERIFY( buf.result() == L"Bad Moon Rising" );
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc
new file mode 100644
index 000000000..38b345715
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc
@@ -0,0 +1,103 @@
+// 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.5.2 template class basic_streambuf
+
+#include <cstring>
+#include <cwchar>
+#include <streambuf>
+#include <sstream>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9424
+class Outbuf_2 : public std::wstreambuf
+{
+ wchar_t buf[1];
+
+public:
+ Outbuf_2()
+ {
+ setp(buf, buf + 1);
+ }
+
+ int_type overflow(int_type c)
+ {
+ int_type eof = traits_type::eof();
+
+ if (pptr() < epptr())
+ {
+ if (traits_type::eq_int_type(c, eof))
+ return traits_type::not_eof(c);
+
+ *pptr() = traits_type::to_char_type(c);
+ pbump(1);
+ return c;
+ }
+
+ return eof;
+ }
+};
+
+class Inbuf_2 : public std::wstreambuf
+{
+ static const wchar_t buf[];
+ const wchar_t* current;
+ int size;
+
+public:
+ Inbuf_2()
+ {
+ current = buf;
+ size = std::wcslen(buf);
+ }
+
+ int_type underflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current);
+ return traits_type::eof();
+ }
+
+ int_type uflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current++);
+ return traits_type::eof();
+ }
+};
+
+const wchar_t Inbuf_2::buf[] = L"Atteivlis";
+
+void test11()
+{
+ bool test __attribute__((unused)) = true;
+
+ Inbuf_2 inbuf1;
+ std::wistream is(&inbuf1);
+ Outbuf_2 outbuf1;
+ is >> &outbuf1;
+ VERIFY( inbuf1.sgetc() == L't' );
+ VERIFY( is.good() );
+}
+
+int main()
+{
+ test11();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc
new file mode 100644
index 000000000..a46c2b91f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc
@@ -0,0 +1,59 @@
+// 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::wios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ buf b;
+
+ testthrow(&b);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc
new file mode 100644
index 000000000..bbac2413d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc
@@ -0,0 +1,58 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test6()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ wstringbuf sbuf(L"", ios_base::out);
+
+ stream >> &sbuf;
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+void test8()
+{
+ bool test __attribute__((unused)) = true;
+ wistringstream stream(L"foo, bar, qux");
+ __gnu_test::fail_wstreambuf bob;
+
+ stream >> &bob;
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+// libstdc++/9371
+int main()
+{
+ test6();
+ test8();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..d7e16905b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc
@@ -0,0 +1,70 @@
+// 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 <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test14()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+ wstringbuf sbuf(L"", ios_base::out);
+
+ try
+ {
+ stream >> &sbuf;
+ }
+ catch (...)
+ { VERIFY( false ); }
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+void test16()
+{
+ bool test __attribute__((unused)) = true;
+ wistringstream stream(L"foo, bar, qux");
+ stream.exceptions(ios_base::badbit);
+ __gnu_test::fail_wstreambuf bob;
+
+ try
+ {
+ stream >> &bob;
+ }
+ catch (...)
+ { VERIFY( false ); }
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+// libstdc++/9371
+int main()
+{
+ test14();
+ test16();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc
new file mode 100644
index 000000000..a9f4b9734
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc
@@ -0,0 +1,80 @@
+// 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 <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test10()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ stream.exceptions(ios_base::failbit);
+ wstringbuf sbuf(L"", ios_base::out);
+
+ try
+ {
+ stream >> &sbuf;
+ VERIFY( false );
+ }
+ catch (ios_base::failure&)
+ { VERIFY( false ); }
+ catch (__gnu_test::underflow_error&)
+ { }
+ catch (...)
+ { VERIFY( false ); }
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+void test12()
+{
+ bool test __attribute__((unused)) = true;
+ wistringstream stream(L"foo, bar, qux");
+ stream.exceptions(ios_base::failbit);
+ __gnu_test::fail_wstreambuf bob;
+
+ try
+ {
+ stream >> &bob;
+ VERIFY( false );
+ }
+ catch (ios_base::failure&)
+ { VERIFY( false ); }
+ catch (__gnu_test::overflow_error&)
+ { }
+ catch (...)
+ { VERIFY( false ); }
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+ VERIFY( (stream.rdstate() & ios_base::badbit) == 0 );
+}
+
+// libstdc++/9371
+int main()
+{
+ test10();
+ test12();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc
new file mode 100644
index 000000000..bc04b7d9b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc
@@ -0,0 +1,59 @@
+// 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/>.
+
+
+#include <istream>
+#include <ostream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+void test2()
+{
+ bool test __attribute__((unused)) = true;
+ wistringstream stream;
+ stream >> static_cast<wstreambuf*>(0);
+ VERIFY( stream.rdstate() & ios_base::failbit );
+}
+
+void test4()
+{
+ bool test __attribute__((unused)) = true;
+ wistringstream stream;
+ stream.exceptions(ios_base::failbit);
+
+ try
+ {
+ stream >> static_cast<wstreambuf*>(0);
+ VERIFY( false );
+ }
+ catch (ios_base::failure&)
+ {
+ }
+
+ VERIFY( stream.rdstate() & ios_base::failbit );
+}
+
+// libstdc++/9371
+int main()
+{
+ test2();
+ test4();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/1.cc
new file mode 100644
index 000000000..f7957d8a5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/1.cc
@@ -0,0 +1,123 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ typedef std::char_traits<char> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const char str_lit01[] =
+ " sun*ra \n\t\t\t & his arkestra, featuring john gilmore: \n"
+ " "
+ "jazz in silhouette: images and forecasts of tomorrow";
+
+ std::string str01(str_lit01);
+ std::string strtmp;
+
+ std::stringbuf sbuf_03;
+ std::stringbuf sbuf_04(str01, std::ios_base::in);
+ std::stringbuf sbuf_05(str01, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_04(&sbuf_04);
+ std::istream is_05(&sbuf_05);
+ std::ios_base::iostate statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+ char carray1[400] = "";
+
+ // int_type get()
+ // istream& get(char*, streamsize, char delim)
+ // istream& get(char*, streamsize)
+ // istream& get(streambuf&, char delim)
+ // istream& get(streambuf&)
+ is_00.get(carray1, 2);
+ VERIFY( static_cast<bool>(is_00.rdstate() & statefail) );
+ VERIFY( is_00.gcount() == 0 );
+
+ is_04.get(carray1, 4);
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( !traits_type::compare(carray1, " ", 4) );
+ VERIFY( is_04.gcount() == 3 );
+
+ is_04.clear();
+ is_04.get(carray1 + 3, 200);
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( !(is_04.rdstate() & stateeof) );
+ VERIFY( !traits_type::compare(carray1, str_lit01, 10) );
+ VERIFY( is_04.gcount() == 7 );
+
+ is_04.clear();
+ is_04.get(carray1, 200);
+ VERIFY( !(is_04.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_04.rdstate() & statefail) ); // delimiter
+ VERIFY( is_04.gcount() == 0 );
+ is_04.clear();
+ is_04.get(carray1, 200, '[');
+ VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( is_04.gcount() == 125 );
+ is_04.clear();
+ is_04.get(carray1, 200);
+ VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_04.rdstate() & statefail) );
+ VERIFY( is_04.gcount() == 0 );
+
+ std::stringbuf sbuf_02(std::ios_base::in);
+ is_05.clear();
+ is_05.get(sbuf_02);
+ VERIFY( is_05.gcount() == 0 );
+ VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
+ VERIFY( !(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03);
+ VERIFY( is_05.gcount() == 10 );
+ VERIFY( sbuf_03.str() == " sun*ra " );
+ VERIFY( !(is_05.rdstate() & statefail) );
+ VERIFY( !(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03, '|');
+ VERIFY( is_05.gcount() == 125 );
+ VERIFY( sbuf_03.str() == str_lit01 );
+ VERIFY( !(is_05.rdstate() & statefail) );
+ VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03, '|');
+ VERIFY( is_05.gcount() == 0 );
+ VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
+}
+
+int
+main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc
new file mode 100644
index 000000000..c677b4334
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc
@@ -0,0 +1,59 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+//libstdc++/92: Bug in istream::get(basic_streambuf*)
+// bug reported by bgarcia@laurelnetworks.com
+// http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ const char* tfn = "istream_unformatted-1.txt";
+ std::ifstream infile;
+ infile.open(tfn);
+ VERIFY( !(!infile) );
+ while (infile)
+ {
+ std::string line;
+ std::ostringstream line_ss;
+ while (infile.peek() == '\n')
+ infile.get();
+ infile.get(*(line_ss.rdbuf()));
+ line = line_ss.str();
+ VERIFY( line == "1234567890" || line == "" );
+ }
+}
+
+int
+main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/3.cc
new file mode 100644
index 000000000..5804fd7b8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/3.cc
@@ -0,0 +1,57 @@
+// 2004-11-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// DR 243. get and getline when sentry reports failure.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringbuf strbuf01;
+ stringbuf strbuf02;
+ istream istr01(&strbuf01);
+ istream istr02(&strbuf02);
+ char buf02[2] = "*" ;
+
+ istr01.peek();
+ VERIFY( istr01.eof() );
+
+ istr01.get(0, 0);
+ VERIFY( istr01.gcount() == 0 );
+ VERIFY( istr01.fail() );
+
+ istr02.peek();
+ VERIFY( istr02.eof() );
+
+ istr02.get(buf02, 1);
+ VERIFY( istr02.gcount() == 0 );
+ VERIFY( istr02.fail() );
+ VERIFY( buf02[0] == char() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/1.cc
new file mode 100644
index 000000000..b3027c3af
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/1.cc
@@ -0,0 +1,120 @@
+// Copyright (C) 2004, 2009, 2010 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ typedef std::char_traits<wchar_t> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const wchar_t str_lit01[] =
+ L" sun*ra \n\t\t\t & his arkestra, featuring john gilmore: \n"
+ L" "
+ L"jazz in silhouette: images and forecasts of tomorrow";
+
+ std::wstring str01(str_lit01);
+ std::wstring strtmp;
+
+ std::wstringbuf sbuf_03;
+ std::wstringbuf sbuf_04(str01, std::ios_base::in);
+ std::wstringbuf sbuf_05(str01, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_04(&sbuf_04);
+ std::wistream is_05(&sbuf_05);
+ std::ios_base::iostate statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+ wchar_t carray1[400] = L"";
+
+ // int_type get()
+ // istream& get(wchar_t*, streamsize, wchar_t delim)
+ // istream& get(wchar_t*, streamsize)
+ // istream& get(streambuf&, wchar_t delim)
+ // istream& get(streambuf&)
+ is_00.get(carray1, 2);
+ VERIFY( static_cast<bool>(is_00.rdstate() & statefail) );
+ VERIFY( is_00.gcount() == 0 );
+
+ is_04.get(carray1, 4);
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( !traits_type::compare(carray1, L" ", 4) );
+ VERIFY( is_04.gcount() == 3 );
+
+ is_04.clear();
+ is_04.get(carray1 + 3, 200);
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( !(is_04.rdstate() & stateeof) );
+ VERIFY( !traits_type::compare(carray1, str_lit01, 10) );
+ VERIFY( is_04.gcount() == 7 );
+
+ is_04.clear();
+ is_04.get(carray1, 200);
+ VERIFY( !(is_04.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_04.rdstate() & statefail) ); // delimiter
+ VERIFY( is_04.gcount() == 0 );
+ is_04.clear();
+ is_04.get(carray1, 200, L'[');
+ VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
+ VERIFY( !(is_04.rdstate() & statefail) );
+ VERIFY( is_04.gcount() == 125 );
+ is_04.clear();
+ is_04.get(carray1, 200);
+ VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_04.rdstate() & statefail) );
+ VERIFY( is_04.gcount() == 0 );
+
+ std::wstringbuf sbuf_02(std::ios_base::in);
+ is_05.clear();
+ is_05.get(sbuf_02);
+ VERIFY( is_05.gcount() == 0 );
+ VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
+ VERIFY( !(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03);
+ VERIFY( is_05.gcount() == 10 );
+ VERIFY( sbuf_03.str() == L" sun*ra " );
+ VERIFY( !(is_05.rdstate() & statefail) );
+ VERIFY( !(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03, L'|');
+ VERIFY( is_05.gcount() == 125 );
+ VERIFY( sbuf_03.str() == str_lit01 );
+ VERIFY( !(is_05.rdstate() & statefail) );
+ VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
+
+ is_05.clear();
+ is_05.get(sbuf_03, L'|');
+ VERIFY( is_05.gcount() == 0 );
+ VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
+ VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
+}
+
+int
+main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc
new file mode 100644
index 000000000..9cfb004cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+//libstdc++/92: Bug in istream::get(basic_streambuf*)
+// bug reported by bgarcia@laurelnetworks.com
+// http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ const char* tfn = "istream_unformatted-1.txt";
+ std::wifstream infile;
+ infile.open(tfn);
+ VERIFY( !(!infile) );
+ while (infile)
+ {
+ std::wstring line;
+ std::wostringstream line_ss;
+ while (infile.peek() == L'\n')
+ infile.get();
+ infile.get(*(line_ss.rdbuf()));
+ line = line_ss.str();
+ VERIFY( line == L"1234567890" || line == L"" );
+ }
+}
+
+int
+main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/3.cc
new file mode 100644
index 000000000..f1a2718be
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/3.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// DR 243. get and getline when sentry reports failure.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wstringbuf strbuf01;
+ wstringbuf strbuf02;
+ wistream istr01(&strbuf01);
+ wistream istr02(&strbuf02);
+ wchar_t buf02[2] = L"*" ;
+
+ istr01.peek();
+ VERIFY( istr01.eof() );
+
+ istr01.get(0, 0);
+ VERIFY( istr01.gcount() == 0 );
+ VERIFY( istr01.fail() );
+
+ istr02.peek();
+ VERIFY( istr02.eof() );
+
+ istr02.get(buf02, 1);
+ VERIFY( istr02.gcount() == 0 );
+ VERIFY( istr02.fail() );
+ VERIFY( buf02[0] == wchar_t() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/1.cc
new file mode 100644
index 000000000..48b245f9b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/1.cc
@@ -0,0 +1,120 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ typedef std::char_traits<char> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const char str_lit01[] = "\t\t\t sun*ra \n"
+ " "
+ "and his myth science arkestra present\n"
+ " "
+ "angles and demons @ play\n"
+ " "
+ "the nubians of plutonia";
+ std::string str01(str_lit01);
+ std::string strtmp;
+
+ std::stringbuf sbuf_04(str01, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_04(&sbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+ char carray1[400] = "";
+
+ // istream& getline(char* s, streamsize n, char delim)
+ // istream& getline(char* s, streamsize n)
+ state1 = is_00.rdstate();
+ is_00.getline(carray1, 20, '*');
+ state2 = is_00.rdstate();
+ // make sure failbit was set, since we couldn't extract
+ // from the null streambuf...
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ VERIFY( is_04.gcount() == 0 );
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 1, '\t'); // extracts, throws away
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 1 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare("", carray1, 1) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 20, '*');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 10 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare("\t\t sun", carray1, 10) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 20);
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 4 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare("ra ", carray1, 4) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 65);
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 64 );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == statefail );
+ VERIFY( !traits_type::compare(
+ " and his myth science arkestra presen",
+ carray1, 65) );
+
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 120, '|');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 106 );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 100, '|');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 0 );
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+}
+
+int
+main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/2.cc
new file mode 100644
index 000000000..486e0e5fc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/2.cc
@@ -0,0 +1,99 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <cstring> // for strlen
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// [patch] bits/istream.tcc - getline(char_type*,streamsize,char_type)
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00003.html
+void
+test05()
+{
+ const char* charray = "\n"
+"a\n"
+"aa\n"
+"aaa\n"
+"aaaa\n"
+"aaaaa\n"
+"aaaaaa\n"
+"aaaaaaa\n"
+"aaaaaaaa\n"
+"aaaaaaaaa\n"
+"aaaaaaaaaa\n"
+"aaaaaaaaaaa\n"
+"aaaaaaaaaaaa\n"
+"aaaaaaaaaaaaa\n"
+"aaaaaaaaaaaaaa\n";
+
+ bool test __attribute__((unused)) = true;
+ const std::streamsize it = 5;
+ std::streamsize br = 0;
+ char tmp[it];
+ std::stringbuf sb(charray, std::ios_base::in);
+ std::istream ifs(&sb);
+ std::streamsize blen = std::strlen(charray);
+ VERIFY(!(!ifs));
+ while(ifs.getline(tmp, it) || ifs.gcount())
+ {
+ br += ifs.gcount();
+ if(ifs.eof())
+ {
+ // Just sanity checks to make sure we've extracted the same
+ // number of chars that were in the streambuf
+ VERIFY(br == blen);
+ // Also, we should only set the failbit if we could
+ // _extract_ no chars from the stream, i.e. the first read
+ // returned EOF.
+ VERIFY(ifs.fail() && ifs.gcount() == 0);
+ }
+ else if(ifs.fail())
+ {
+ // delimiter not read
+ //
+ // either
+ // -> extracted no characters
+ // or
+ // -> n - 1 characters are stored
+ ifs.clear(ifs.rdstate() & ~std::ios::failbit);
+ VERIFY((ifs.gcount() == 0) || (std::strlen(tmp) == it - 1));
+ VERIFY(!(!ifs));
+ continue;
+ }
+ else
+ {
+ // delimiter was read.
+ //
+ // -> strlen(__s) < n - 1
+ // -> delimiter was seen -> gcount() > strlen(__s)
+ VERIFY(ifs.gcount() == static_cast<std::streamsize>(std::strlen(tmp) + 1) );
+ continue;
+ }
+ }
+}
+
+int
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/3.cc
new file mode 100644
index 000000000..f71e1ca16
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/3.cc
@@ -0,0 +1,60 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <cstring> // for strlen
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// [bug] istream::getline(char*,streamsize) still broken
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00126.html
+// brent verner <brent at rcfile dot org
+void
+test06()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ const streamsize it = 5;
+ char tmp[it];
+ const char* str_lit = "abcd\n";
+
+ stringbuf strbuf(str_lit, std::ios_base::in);
+ istream istr(&strbuf);
+
+ istr.getline(tmp,it);
+ VERIFY( istr.gcount() == it ); // extracted whole string
+ VERIFY( strlen(tmp) == 4 ); // stored all but '\n'
+ VERIFY( !istr.eof() ); // extracted up to but not eof
+ VERIFY( !istr.fail() ); // failbit not set
+
+ char c = 'z';
+ istr.get(c);
+ VERIFY( c == 'z' );
+ VERIFY( istr.eof() );
+}
+
+int
+main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/4.cc
new file mode 100644
index 000000000..4f2909232
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/4.cc
@@ -0,0 +1,99 @@
+// 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.3 unformatted input functions
+
+#include <cstring> // for strlen
+#include <istream>
+#include <testsuite_hooks.h>
+
+class Inbuf : public std::streambuf
+{
+ static const char buf[];
+ const char* current;
+ int size;
+
+public:
+ Inbuf()
+ {
+ current = buf;
+ size = std::strlen(buf);
+ }
+
+ int_type underflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current);
+ return traits_type::eof();
+ }
+
+ int_type uflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current++);
+ return traits_type::eof();
+ }
+};
+
+const char Inbuf::buf[] = "1234567890abcdefghij";
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef char_traits<char> traits_type;
+
+ Inbuf inbuf1;
+ istream is(&inbuf1);
+
+ char buffer[10];
+ traits_type::assign(buffer, sizeof(buffer), 'X');
+
+ is.getline(buffer, sizeof(buffer), '0');
+ VERIFY( is.rdstate() == ios_base::goodbit );
+ VERIFY( !traits_type::compare(buffer, "123456789\0", sizeof(buffer)) );
+ VERIFY( is.gcount() == 10 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer), 'X');
+ is.getline(buffer, sizeof(buffer));
+ VERIFY( is.rdstate() == ios_base::failbit );
+ VERIFY( !traits_type::compare(buffer, "abcdefghi\0", sizeof(buffer)) );
+ VERIFY( is.gcount() == 9 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer), 'X');
+ is.getline(buffer, sizeof(buffer));
+ VERIFY( is.rdstate() == ios_base::eofbit );
+ VERIFY( !traits_type::compare(buffer, "j\0XXXXXXXX", sizeof(buffer)) );
+ VERIFY( is.gcount() == 1 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer), 'X');
+ is.getline(buffer, sizeof(buffer));
+ VERIFY( is.rdstate() == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( !traits_type::compare(buffer, "\0XXXXXXXXX", sizeof(buffer)) );
+ VERIFY( is.gcount() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc
new file mode 100644
index 000000000..310f637f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/5.cc
@@ -0,0 +1,88 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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.1.3 unformatted input functions
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks, char delim)
+{
+ string ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (string::size_type j = 0; j < len; ++j)
+ ret.push_back('a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void check(istream& stream, const string& str, unsigned nchunks, char delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ char buf[1000000];
+ string::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream.getline(buf, sizeof(buf), delim))
+ {
+ index_new = str.find(delim, index);
+ VERIFY( static_cast<string::size_type>(stream.gcount()) ==
+ index_new - index + 1 );
+ VERIFY( !str.compare(index, index_new - index, buf) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.gcount() == 0 );
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+void test01()
+{
+ const char filename[] = "istream_getline.txt";
+
+ const char delim = '|';
+ const unsigned nchunks = 10;
+ const string data = prepare(777, nchunks, delim);
+
+ ofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/6.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/6.cc
new file mode 100644
index 000000000..0a129ecbf
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/char/6.cc
@@ -0,0 +1,57 @@
+// 2004-11-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// DR 243. get and getline when sentry reports failure.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringbuf strbuf01;
+ stringbuf strbuf02;
+ istream istr01(&strbuf01);
+ istream istr02(&strbuf02);
+ char buf02[2] = "*" ;
+
+ istr01.peek();
+ VERIFY( istr01.eof() );
+
+ istr01.getline(0, 0);
+ VERIFY( istr01.gcount() == 0 );
+ VERIFY( istr01.fail() );
+
+ istr02.peek();
+ VERIFY( istr02.eof() );
+
+ istr02.getline(buf02, 1);
+ VERIFY( istr02.gcount() == 0 );
+ VERIFY( istr02.fail() );
+ VERIFY( buf02[0] == char() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/1.cc
new file mode 100644
index 000000000..2445dd4f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/1.cc
@@ -0,0 +1,117 @@
+// Copyright (C) 2004, 2009, 2010 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ typedef std::char_traits<wchar_t> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const wchar_t str_lit01[] = L"\t\t\t sun*ra \n"
+ L" "
+ L"and his myth science arkestra present\n"
+ L" "
+ L"angles and demons @ play\n"
+ L" "
+ L"the nubians of plutonia";
+ std::wstring str01(str_lit01);
+ std::wstring strtmp;
+
+ std::wstringbuf sbuf_04(str01, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_04(&sbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+ wchar_t carray1[400] = L"";
+
+ // istream& getline(wchar_t* s, streamsize n, wchar_t delim)
+ // istream& getline(wchar_t* s, streamsize n)
+ state1 = is_00.rdstate();
+ is_00.getline(carray1, 20, L'*');
+ state2 = is_00.rdstate();
+ // make sure failbit was set, since we couldn't extract
+ // from the null streambuf...
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+
+ VERIFY( is_04.gcount() == 0 );
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 1, L'\t'); // extracts, throws away
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 1 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare(L"", carray1, 1) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 20, L'*');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 10 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare(L"\t\t sun", carray1, 10) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 20);
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 4 );
+ VERIFY( state1 == state2 );
+ VERIFY( state1 == 0 );
+ VERIFY( !traits_type::compare(L"ra ", carray1, 4) );
+
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 65);
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 64 );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == statefail );
+ VERIFY( !traits_type::compare(
+ L" and his myth science arkestra presen",
+ carray1, 65) );
+
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 120, L'|');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 106 );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.getline(carray1, 100, L'|');
+ state2 = is_04.rdstate();
+ VERIFY( is_04.gcount() == 0 );
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+}
+
+int
+main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/2.cc
new file mode 100644
index 000000000..192de56a2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/2.cc
@@ -0,0 +1,98 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <cwchar> // for wcslen
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// [patch] bits/istream.tcc - getline(char_type*,streamsize,char_type)
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00003.html
+void
+test05()
+{
+ const wchar_t* charray = L"\n"
+L"a\n"
+L"aa\n"
+L"aaa\n"
+L"aaaa\n"
+L"aaaaa\n"
+L"aaaaaa\n"
+L"aaaaaaa\n"
+L"aaaaaaaa\n"
+L"aaaaaaaaa\n"
+L"aaaaaaaaaa\n"
+L"aaaaaaaaaaa\n"
+L"aaaaaaaaaaaa\n"
+L"aaaaaaaaaaaaa\n"
+L"aaaaaaaaaaaaaa\n";
+
+ bool test __attribute__((unused)) = true;
+ const std::streamsize it = 5;
+ std::streamsize br = 0;
+ wchar_t tmp[it];
+ std::wstringbuf sb(charray, std::ios_base::in);
+ std::wistream ifs(&sb);
+ std::streamsize blen = std::wcslen(charray);
+ VERIFY(!(!ifs));
+ while(ifs.getline(tmp, it) || ifs.gcount())
+ {
+ br += ifs.gcount();
+ if(ifs.eof())
+ {
+ // Just sanity checks to make sure we've extracted the same
+ // number of chars that were in the streambuf
+ VERIFY( br == blen );
+ // Also, we should only set the failbit if we could
+ // _extract_ no chars from the stream, i.e. the first read
+ // returned EOF.
+ VERIFY( ifs.fail() && ifs.gcount() == 0 );
+ }
+ else if(ifs.fail())
+ {
+ // delimiter not read
+ //
+ // either
+ // -> extracted no characters
+ // or
+ // -> n - 1 characters are stored
+ ifs.clear(ifs.rdstate() & ~std::ios::failbit);
+ VERIFY( (ifs.gcount() == 0) || (std::wcslen(tmp) == it - 1) );
+ VERIFY( !(!ifs) );
+ continue;
+ }
+ else
+ {
+ // delimiter was read.
+ //
+ // -> wcslen(__s) < n - 1
+ // -> delimiter was seen -> gcount() > wcslen(__s)
+ VERIFY( ifs.gcount() == static_cast<std::streamsize>(std::wcslen(tmp)
+ + 1) );
+ continue;
+ }
+ }
+}
+
+int
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/3.cc
new file mode 100644
index 000000000..af7033ddd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/3.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <cwchar> // for wcslen
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// [bug] istream::getline(char*,streamsize) still broken
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00126.html
+// brent verner <brent at rcfile dot org
+void
+test06()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ const streamsize it = 5;
+ wchar_t tmp[it];
+ const wchar_t* str_lit = L"abcd\n";
+
+ wstringbuf strbuf(str_lit, std::ios_base::in);
+ wistream istr(&strbuf);
+
+ istr.getline(tmp,it);
+ VERIFY( istr.gcount() == it ); // extracted whole string
+ VERIFY( wcslen(tmp) == 4 ); // stored all but '\n'
+ VERIFY( !istr.eof() ); // extracted up to but not eof
+ VERIFY( !istr.fail() ); // failbit not set
+
+ wchar_t c = L'z';
+ istr.get(c);
+ VERIFY( c == L'z' );
+ VERIFY( istr.eof() );
+}
+
+int
+main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/4.cc
new file mode 100644
index 000000000..1e147c748
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/4.cc
@@ -0,0 +1,103 @@
+// 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.3 unformatted input functions
+
+#include <cwchar> // for wcslen
+#include <istream>
+#include <testsuite_hooks.h>
+
+class Inbuf : public std::wstreambuf
+{
+ static const wchar_t buf[];
+ const wchar_t* current;
+ int size;
+
+public:
+ Inbuf()
+ {
+ current = buf;
+ size = std::wcslen(buf);
+ }
+
+ int_type underflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current);
+ return traits_type::eof();
+ }
+
+ int_type uflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current++);
+ return traits_type::eof();
+ }
+};
+
+const wchar_t Inbuf::buf[] = L"1234567890abcdefghij";
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef char_traits<wchar_t> traits_type;
+
+ Inbuf inbuf1;
+ wistream is(&inbuf1);
+
+ wchar_t buffer[10];
+ traits_type::assign(buffer, sizeof(buffer) / sizeof(wchar_t), L'X');
+
+ is.getline(buffer, sizeof(buffer) / sizeof(wchar_t), L'0');
+ VERIFY( is.rdstate() == ios_base::goodbit );
+ VERIFY( !traits_type::compare(buffer, L"123456789\0",
+ sizeof(buffer) / sizeof(wchar_t)) );
+ VERIFY( is.gcount() == 10 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer) / sizeof(wchar_t), L'X');
+ is.getline(buffer, sizeof(buffer) / sizeof(wchar_t));
+ VERIFY( is.rdstate() == ios_base::failbit );
+ VERIFY( !traits_type::compare(buffer, L"abcdefghi\0",
+ sizeof(buffer) / sizeof(wchar_t)) );
+ VERIFY( is.gcount() == 9 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer) / sizeof(wchar_t), L'X');
+ is.getline(buffer, sizeof(buffer) / sizeof(wchar_t));
+ VERIFY( is.rdstate() == ios_base::eofbit );
+ VERIFY( !traits_type::compare(buffer, L"j\0XXXXXXXX",
+ sizeof(buffer) / sizeof(wchar_t)) );
+ VERIFY( is.gcount() == 1 );
+
+ is.clear();
+ traits_type::assign(buffer, sizeof(buffer) / sizeof(wchar_t), L'X');
+ is.getline(buffer, sizeof(buffer) / sizeof(wchar_t));
+ VERIFY( is.rdstate() == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( !traits_type::compare(buffer, L"\0XXXXXXXXX",
+ sizeof(buffer) / sizeof(wchar_t)) );
+ VERIFY( is.gcount() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc
new file mode 100644
index 000000000..39fb59572
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc
@@ -0,0 +1,88 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring
+prepare(wstring::size_type len, unsigned nchunks, wchar_t delim)
+{
+ wstring ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (wstring::size_type j = 0; j < len; ++j)
+ ret.push_back(L'a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void
+check(wistream& stream, const wstring& str, unsigned nchunks, wchar_t delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ static wchar_t buf[1000000];
+ wstring::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream.getline(buf, sizeof(buf) / sizeof(wchar_t), delim))
+ {
+ index_new = str.find(delim, index);
+ VERIFY( static_cast<string::size_type>(stream.gcount()) ==
+ index_new - index + 1 );
+ VERIFY( !str.compare(index, index_new - index, buf) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.gcount() == 0 );
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+void test01()
+{
+ const char filename[] = "wistream_getline.txt";
+
+ const wchar_t delim = L'|';
+ const unsigned nchunks = 10;
+ const wstring data = prepare(777, nchunks, delim);
+
+ wofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/6.cc b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/6.cc
new file mode 100644
index 000000000..0a4376c88
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/6.cc
@@ -0,0 +1,57 @@
+// 2004-11-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// DR 243. get and getline when sentry reports failure.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wstringbuf strbuf01;
+ wstringbuf strbuf02;
+ wistream istr01(&strbuf01);
+ wistream istr02(&strbuf02);
+ wchar_t buf02[2] = L"*" ;
+
+ istr01.peek();
+ VERIFY( istr01.eof() );
+
+ istr01.getline(0, 0);
+ VERIFY( istr01.gcount() == 0 );
+ VERIFY( istr01.fail() );
+
+ istr02.peek();
+ VERIFY( istr02.eof() );
+
+ istr02.getline(buf02, 1);
+ VERIFY( istr02.gcount() == 0 );
+ VERIFY( istr02.fail() );
+ VERIFY( buf02[0] == wchar_t() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc
new file mode 100644
index 000000000..4e0ce25aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc
@@ -0,0 +1,78 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::ios::traits_type traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string str_01;
+ const std::string str_02("soul eyes: john coltrane quartet");
+ std::string strtmp;
+
+ std::stringbuf isbuf_03(str_02, std::ios_base::in);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ // istream& read(char_type* s, streamsize n)
+ char carray[60] = "";
+ is_04.read(carray, 9);
+ VERIFY( is_04.peek() == ':' );
+
+ // istream& ignore(streamsize n = 1, int_type delim = traits::eof())
+ state1 = is_04.rdstate();
+ is_04.ignore();
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == ' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(0);
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == ' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(5, traits_type::to_int_type(' '));
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == 'j' );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc
new file mode 100644
index 000000000..05236fd57
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc
@@ -0,0 +1,87 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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.1.3 unformatted input functions
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <limits>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks, char delim)
+{
+ string ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (string::size_type j = 0; j < len; ++j)
+ ret.push_back('a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void check(istream& stream, const string& str, unsigned nchunks, char delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ string::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream.ignore(numeric_limits<streamsize>::max(), delim).good())
+ {
+ index_new = str.find(delim, index);
+ VERIFY( static_cast<string::size_type>(stream.gcount()) ==
+ index_new - index + 1 );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.gcount() == 0 );
+ VERIFY( !stream.fail() );
+ VERIFY( n == nchunks );
+}
+
+void test01()
+{
+ const char filename[] = "istream_ignore.txt";
+
+ const char delim = '|';
+ const unsigned nchunks = 10;
+ const string data = prepare(555, nchunks, delim);
+
+ ofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc
new file mode 100644
index 000000000..218a21b54
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc
@@ -0,0 +1,98 @@
+// 2004-06-20 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <fstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// istream& ignore(streamsize n)
+void
+test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char filename[] ="istream_unformatted-1.txt";
+ ios_base::iostate state1, state2;
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+
+ state1 = ifstrm.rdstate();
+ VERIFY( state1 == ios_base::goodbit );
+ VERIFY( ifstrm.peek() == '1' );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(1);
+ VERIFY( ifstrm.gcount() == 1 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == '2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(10);
+ VERIFY( ifstrm.gcount() == 10 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == '1' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(100);
+ VERIFY( ifstrm.gcount() == 100 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == '2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(1000);
+ VERIFY( ifstrm.gcount() == 1000 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == '1' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(10000);
+ VERIFY( ifstrm.gcount() == 10000 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == '2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(numeric_limits<streamsize>::max());
+ VERIFY( ifstrm.gcount() == 5389 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == ios_base::eofbit );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc
new file mode 100644
index 000000000..04f72a6b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc
@@ -0,0 +1,47 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// 2002-04-19 PR libstdc++ 6360
+void
+test08()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ stringstream ss("abcd" "\xFF" "1234ina donna coolbrith");
+ char c;
+ ss >> c;
+ VERIFY( c == 'a' );
+ ss.ignore(8);
+ ss >> c;
+ VERIFY( c == 'i' );
+}
+
+int
+main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc
new file mode 100644
index 000000000..141832692
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc
@@ -0,0 +1,67 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/70220
+void
+test10()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ typedef string string_type;
+ typedef stringbuf stringbuf_type;
+ typedef istream istream_type;
+
+ streamsize n;
+ string_type input("abcdefg\n");
+ stringbuf_type sbuf(input);
+ istream_type istr(&sbuf);
+
+ istr.ignore(0);
+ if (istr.gcount() != 0)
+ test = false;
+ VERIFY( test );
+
+ istr.ignore(0, 'b');
+ if (istr.gcount() != 0)
+ test = false;
+ VERIFY( test );
+
+ istr.ignore(); // Advance to next position.
+ istr.ignore(0, 'b');
+ if ((n=istr.gcount()) != 0)
+ test = false;
+ VERIFY( test );
+
+ if (istr.peek() != 'b')
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test10();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc
new file mode 100644
index 000000000..c4a7a33d0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc
@@ -0,0 +1,75 @@
+// Copyright (C) 2004, 2009, 2010 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::ios::traits_type traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01;
+ const std::wstring str_02(L"soul eyes: john coltrane quartet");
+ std::wstring strtmp;
+
+ std::wstringbuf isbuf_03(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ // istream& read(char_type* s, streamsize n)
+ wchar_t carray[60] = L"";
+ is_04.read(carray, 9);
+ VERIFY( is_04.peek() == L':' );
+
+ // istream& ignore(streamsize n = 1, int_type delim = traits::eof())
+ state1 = is_04.rdstate();
+ is_04.ignore();
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(0);
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(5, traits_type::to_int_type(' '));
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L'j' );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc
new file mode 100644
index 000000000..8a2421041
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc
@@ -0,0 +1,87 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <limits>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring
+prepare(wstring::size_type len, unsigned nchunks, wchar_t delim)
+{
+ wstring ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (wstring::size_type j = 0; j < len; ++j)
+ ret.push_back(L'a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void
+check(wistream& stream, const wstring& str, unsigned nchunks, wchar_t delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ wstring::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream.ignore(numeric_limits<streamsize>::max(), delim).good())
+ {
+ index_new = str.find(delim, index);
+ VERIFY( static_cast<string::size_type>(stream.gcount()) ==
+ index_new - index + 1 );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.gcount() == 0 );
+ VERIFY( !stream.fail() );
+ VERIFY( n == nchunks );
+}
+
+void test01()
+{
+ const char filename[] = "wistream_ignore.txt";
+
+ const wchar_t delim = L'|';
+ const unsigned nchunks = 10;
+ const wstring data = prepare(555, nchunks, delim);
+
+ wofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc
new file mode 100644
index 000000000..edd822df4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc
@@ -0,0 +1,94 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <fstream>
+#include <limits>
+#include <testsuite_hooks.h>
+
+// istream& ignore(streamsize n)
+void
+test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char filename[] ="istream_unformatted-1.txt";
+ ios_base::iostate state1, state2;
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+
+ state1 = ifstrm.rdstate();
+ VERIFY( state1 == ios_base::goodbit );
+ VERIFY( ifstrm.peek() == L'1' );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(1);
+ VERIFY( ifstrm.gcount() == 1 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == L'2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(10);
+ VERIFY( ifstrm.gcount() == 10 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == L'1' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(100);
+ VERIFY( ifstrm.gcount() == 100 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == L'2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(1000);
+ VERIFY( ifstrm.gcount() == 1000 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == L'1' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(10000);
+ VERIFY( ifstrm.gcount() == 10000 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( ifstrm.peek() == L'2' );
+
+ state1 = ifstrm.rdstate();
+ ifstrm.ignore(numeric_limits<streamsize>::max());
+ VERIFY( ifstrm.gcount() == 5389 );
+ state2 = ifstrm.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == ios_base::eofbit );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc
new file mode 100644
index 000000000..3e837e8b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// 2002-04-19 PR libstdc++ 6360
+void
+test08()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wstringstream ss(L"abcd" L"\xFF" L"1234ina donna coolbrith");
+ wchar_t c;
+ ss >> c;
+ VERIFY( c == L'a' );
+ ss.ignore(8);
+ ss >> c;
+ VERIFY( c == L'i' );
+}
+
+int
+main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc
new file mode 100644
index 000000000..d3d7f1ec0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc
@@ -0,0 +1,65 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/70220
+void
+test10()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ typedef wstring string_type;
+ typedef wstringbuf stringbuf_type;
+ typedef wistream istream_type;
+
+ streamsize n;
+ string_type input(L"abcdefg\n");
+ stringbuf_type sbuf(input);
+ istream_type istr(&sbuf);
+
+ istr.ignore(0);
+ if (istr.gcount() != 0)
+ test = false;
+ VERIFY( test );
+
+ istr.ignore(0, L'b');
+ if (istr.gcount() != 0)
+ test = false;
+ VERIFY( test );
+
+ istr.ignore(); // Advance to next position.
+ istr.ignore(0, L'b');
+ if ((n=istr.gcount()) != 0)
+ test = false;
+ VERIFY( test );
+
+ if (istr.peek() != L'b')
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test10();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/1.cc
new file mode 100644
index 000000000..39a3fdff3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/1.cc
@@ -0,0 +1,92 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::ios::traits_type traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string str_01;
+ const std::string str_02("soul eyes: john coltrane quartet");
+ std::string strtmp;
+
+ std::stringbuf isbuf_03(str_02, std::ios_base::in);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ char carray[60] = "";
+
+ // istream& ignore(streamsize n = 1, int_type delim = traits::eof())
+ is_04.read(carray, 9);
+ VERIFY( is_04.peek() == ':' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore();
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == ' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(0);
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == ' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(5, traits_type::to_int_type(' '));
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == 'j' );
+
+ // int_type peek()
+ state1 = is_04.rdstate();
+ VERIFY( is_04.peek() == 'j' );
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ is_04.ignore(30);
+ state1 = is_04.rdstate();
+ VERIFY( is_04.peek() == traits_type::eof() );
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc
new file mode 100644
index 000000000..7263c7c42
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/12296.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2003, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/12296
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream stream;
+ VERIFY( stream.rdstate() == ios_base::goodbit );
+ istringstream::int_type c = stream.peek();
+ VERIFY( c == istringstream::traits_type::eof() );
+ VERIFY( stream.rdstate() == ios_base::eofbit );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc
new file mode 100644
index 000000000..5d02fc912
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc
@@ -0,0 +1,49 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ bool test __attribute__((unused)) = true;
+ std::istream::pos_type pos01, pos02;
+ const char str_lit01[] = "istream_seeks-1.txt";
+ std::ifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+
+ // libstdc++/6414
+ if01.seekg(0, std::ios_base::beg);
+ pos01 = if01.tellg();
+ if01.peek();
+ pos02 = if01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/1.cc
new file mode 100644
index 000000000..612e60600
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/1.cc
@@ -0,0 +1,89 @@
+// Copyright (C) 2004, 2009, 2010 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ typedef std::wios::traits_type traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01;
+ const std::wstring str_02(L"soul eyes: john coltrane quartet");
+ std::wstring strtmp;
+
+ std::wstringbuf isbuf_03(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ wchar_t carray[60] = L"";
+
+ // istream& ignore(streamsize n = 1, int_type delim = traits::eof())
+ is_04.read(carray, 9);
+ VERIFY( is_04.peek() == L':' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore();
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(0);
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L' ' );
+
+ state1 = is_04.rdstate();
+ is_04.ignore(5, traits_type::to_int_type(' '));
+ VERIFY( is_04.gcount() == 1 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L'j' );
+
+ // int_type peek()
+ state1 = is_04.rdstate();
+ VERIFY( is_04.peek() == L'j' );
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ is_04.ignore(30);
+ state1 = is_04.rdstate();
+ VERIFY( is_04.peek() == traits_type::eof() );
+ VERIFY( is_04.gcount() == 0 );
+ state2 = is_04.rdstate();
+ VERIFY( state1 != state2 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/12296.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/12296.cc
new file mode 100644
index 000000000..c1fcce837
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/12296.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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.1.3 unformatted input functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/12296
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream stream;
+ VERIFY( stream.rdstate() == ios_base::goodbit );
+ wistringstream::int_type c = stream.peek();
+ VERIFY( c == wistringstream::traits_type::eof() );
+ VERIFY( stream.rdstate() == ios_base::eofbit );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc
new file mode 100644
index 000000000..9c74fa3f4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc
@@ -0,0 +1,47 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ bool test __attribute__((unused)) = true;
+ std::wistream::pos_type pos01, pos02;
+ const char str_lit01[] = "wistream_seeks-1.txt";
+ std::wifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+
+ // libstdc++/6414
+ if01.seekg(0, std::ios_base::beg);
+ pos01 = if01.tellg();
+ if01.peek();
+ pos02 = if01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc
new file mode 100644
index 000000000..123d488fd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/putback/char/1.cc
@@ -0,0 +1,75 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string str_01;
+ const std::string str_02("soul eyes: john coltrane quartet");
+ std::string strtmp;
+
+ std::stringbuf isbuf_03(str_02, std::ios_base::in);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+ std::stringbuf isbuf_05(str_02, std::ios_base::in);
+
+ std::istream is_00(&isbuf_05);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ // istream& putback(char c)
+ is_04.ignore(30);
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.putback('t');
+ VERIFY( is_04.gcount() == 0 ); // DR 60
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == 't' );
+
+ // istream& unget()
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.unget();
+ VERIFY( is_04.gcount() == 0 ); // DR 60
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == 'r' );
+
+ // int sync()
+ is_00.ignore(10);
+ int count1 = is_00.gcount();
+ is_00.sync();
+ int count2 = is_00.gcount();
+ VERIFY (count1 == count2 ); // DR 60
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/putback/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/putback/wchar_t/1.cc
new file mode 100644
index 000000000..3cd981b36
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/putback/wchar_t/1.cc
@@ -0,0 +1,73 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_01;
+ const std::wstring str_02(L"soul eyes: john coltrane quartet");
+ std::wstring strtmp;
+
+ std::wstringbuf isbuf_03(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_05(str_02, std::ios_base::in);
+
+ std::wistream is_00(&isbuf_05);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2;
+
+ // istream& putback(char_type c)
+ is_04.ignore(30);
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.putback(L't');
+ VERIFY( is_04.gcount() == 0 ); // DR 60
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L't' );
+
+ // istream& unget()
+ is_04.clear();
+ state1 = is_04.rdstate();
+ is_04.unget();
+ VERIFY( is_04.gcount() == 0 ); // DR 60
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( is_04.peek() == L'r' );
+
+ // int sync()
+ is_00.ignore(10);
+ int count1 = is_00.gcount();
+ is_00.sync();
+ int count2 = is_00.gcount();
+ VERIFY (count1 == count2 ); // DR 60
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc
new file mode 100644
index 000000000..3879f7b42
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/1.cc
@@ -0,0 +1,72 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009, 2010
+// 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.1.3 unformatted input functions
+
+#include <cstring> // for strncmp,...
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string str_02("soul eyes: john coltrane quartet");
+
+ std::stringbuf isbuf_03(str_02, std::ios_base::in);
+ std::stringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::istream is_00(0);
+ std::istream is_03(&isbuf_03);
+ std::istream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ // istream& read(char_type* s, streamsize n)
+ char carray[60] = "";
+ state1 = is_04.rdstate();
+ is_04.read(carray, 0);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = is_04.rdstate();
+ is_04.read(carray, 9);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !std::strncmp(carray, "soul eyes", 9) );
+ VERIFY( is_04.peek() == ':' );
+
+ state1 = is_03.rdstate();
+ is_03.read(carray, 60);
+ state2 = is_03.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( !std::strncmp(carray, "soul eyes: john coltrane quartet", 35) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc
new file mode 100644
index 000000000..acb1b800a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/2.cc
@@ -0,0 +1,58 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Jim Parsons <parsons at clearway dot com>
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00177.html
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::string str_00("Red_Garland_Qunitet-Soul_Junction");
+ char c_array[str_00.size() + 4];
+
+ std::stringbuf isbuf_00(str_00, std::ios_base::in);
+ std::istream is_00(&isbuf_00);
+ std::ios_base::iostate state1, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ state1 = stateeof | statefail;
+ VERIFY( is_00.gcount() == 0 );
+ is_00.read(c_array, str_00.size() + 1);
+ VERIFY( is_00.gcount() == static_cast<std::streamsize>(str_00.size()) );
+ VERIFY( is_00.rdstate() == state1 );
+
+ is_00.read(c_array, str_00.size());
+ VERIFY( is_00.rdstate() == state1 );
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc
new file mode 100644
index 000000000..c3c7769d4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/char/3.cc
@@ -0,0 +1,46 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Theodore Papadopoulo
+void
+test09()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream iss("Juana Briones");
+ char tab[13];
+ iss.read(tab, 13);
+ if (!iss)
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc
new file mode 100644
index 000000000..508e0c8cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/1.cc
@@ -0,0 +1,69 @@
+// Copyright (C) 2004, 2009, 2010 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.1.3 unformatted input functions
+
+#include <cwchar> // for wcsncmp,...
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring str_02(L"soul eyes: john coltrane quartet");
+
+ std::wstringbuf isbuf_03(str_02, std::ios_base::in);
+ std::wstringbuf isbuf_04(str_02, std::ios_base::in);
+
+ std::wistream is_00(0);
+ std::wistream is_03(&isbuf_03);
+ std::wistream is_04(&isbuf_04);
+ std::ios_base::iostate state1, state2, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ // istream& read(char_type* s, streamsize n)
+ wchar_t carray[60] = L"";
+ state1 = is_04.rdstate();
+ is_04.read(carray, 0);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+
+ state1 = is_04.rdstate();
+ is_04.read(carray, 9);
+ state2 = is_04.rdstate();
+ VERIFY( state1 == state2 );
+ VERIFY( !std::wcsncmp(carray, L"soul eyes", 9) );
+ VERIFY( is_04.peek() == L':' );
+
+ state1 = is_03.rdstate();
+ is_03.read(carray, 60);
+ state2 = is_03.rdstate();
+ VERIFY( state1 != state2 );
+ VERIFY( static_cast<bool>(state2 & stateeof) );
+ VERIFY( static_cast<bool>(state2 & statefail) );
+ VERIFY( !std::wcsncmp(carray, L"soul eyes: john coltrane quartet", 35) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc
new file mode 100644
index 000000000..2ea0b663d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/2.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Jim Parsons <parsons at clearway dot com>
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00177.html
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::wstring str_00(L"Red_Garland_Qunitet-Soul_Junction");
+ wchar_t c_array[str_00.size() + 4];
+
+ std::wstringbuf isbuf_00(str_00, std::ios_base::in);
+ std::wistream is_00(&isbuf_00);
+ std::ios_base::iostate state1, statefail, stateeof;
+ statefail = std::ios_base::failbit;
+ stateeof = std::ios_base::eofbit;
+
+ state1 = stateeof | statefail;
+ VERIFY( is_00.gcount() == 0 );
+ is_00.read(c_array, str_00.size() + 1);
+ VERIFY( is_00.gcount() == static_cast<std::streamsize>(str_00.size()) );
+ VERIFY( is_00.rdstate() == state1 );
+
+ is_00.read(c_array, str_00.size());
+ VERIFY( is_00.rdstate() == state1 );
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc
new file mode 100644
index 000000000..0de14bdd8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/read/wchar_t/3.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// Theodore Papadopoulo
+void
+test09()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream iss(L"Juana Briones");
+ wchar_t tab[13];
+ iss.read(tab, 13);
+ if (!iss)
+ test = false;
+ VERIFY( test );
+}
+
+int
+main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-1.cc
new file mode 100644
index 000000000..4e126da30
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-1.cc
@@ -0,0 +1,55 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/6746
+void test12()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ streamsize sum = 0;
+ istringstream iss("shamma shamma");
+
+ // test01
+ size_t i = iss.rdbuf()->in_avail();
+ VERIFY( i != 0 );
+
+ // test02
+ streamsize extracted;
+ do
+ {
+ char buf[1024];
+ extracted = iss.readsome(buf, sizeof buf);
+ sum += extracted;
+ }
+ while (iss.good() && extracted);
+ VERIFY( sum != 0 );
+}
+
+int
+main()
+{
+ test12();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-2.cc
new file mode 100644
index 000000000..ed74751dc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/6746-2.cc
@@ -0,0 +1,64 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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/>.
+
+// The ARM simulator does not provide support for "fstat", which
+// causes "in_avail" to return an incorrect value.
+// { dg-do run { xfail arm*-*-elf arm*-*-eabi } }
+
+// 27.6.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+// { dg-require-binary-io "" }
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/6746
+void test13()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ streamsize sum = 0;
+ ifstream ifs("istream_unformatted-1.tst");
+
+ // test01
+ size_t i = ifs.rdbuf()->in_avail();
+ VERIFY( i != 0 );
+
+ // test02
+ streamsize extracted;
+ do
+ {
+ char buf[1024];
+ extracted = ifs.readsome(buf, sizeof buf);
+ sum += extracted;
+ }
+ while (ifs.good() && extracted);
+ VERIFY( sum != 0 );
+}
+
+int
+main()
+{
+ test13();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/8258.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/8258.cc
new file mode 100644
index 000000000..fad9ea233
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/char/8258.cc
@@ -0,0 +1,48 @@
+// 1999-08-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+// libstdc++/8258
+class mybuf : public std::basic_streambuf<char>
+{ };
+
+void test11()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ char arr[10];
+ mybuf sbuf;
+ basic_istream<char, char_traits<char> > istr(&sbuf);
+
+ VERIFY(istr.rdstate() == ios_base::goodbit);
+ VERIFY(istr.readsome(arr, 10) == 0);
+ VERIFY(istr.rdstate() == ios_base::goodbit);
+}
+
+int
+main()
+{
+ test11();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-1.cc
new file mode 100644
index 000000000..a710aea39
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-1.cc
@@ -0,0 +1,53 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/6746
+void test12()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ streamsize sum = 0;
+ wistringstream iss(L"shamma shamma");
+
+ // test01
+ size_t i = iss.rdbuf()->in_avail();
+ VERIFY( i != 0 );
+
+ // test02
+ streamsize extracted;
+ do
+ {
+ wchar_t buf[1024];
+ extracted = iss.readsome(buf, sizeof(buf) / sizeof(wchar_t));
+ sum += extracted;
+ }
+ while (iss.good() && extracted);
+ VERIFY( sum != 0 );
+}
+
+int
+main()
+{
+ test12();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-2.cc
new file mode 100644
index 000000000..c77031322
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/6746-2.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2004, 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/>.
+
+// The ARM simulator does not provide support for "fstat", which
+// causes "in_avail" to return an incorrect value.
+// { dg-do run { xfail arm*-*-elf arm*-*-eabi } }
+
+// { dg-require-binary-io "" }
+
+// 27.6.1.3 unformatted input functions
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/6746
+void test13()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ streamsize sum = 0;
+ wifstream ifs("wistream_unformatted-1.tst");
+
+ // test01
+ size_t i = ifs.rdbuf()->in_avail();
+ VERIFY( i != 0 );
+
+ // test02
+ streamsize extracted;
+ do
+ {
+ wchar_t buf[1024];
+ extracted = ifs.readsome(buf, sizeof(buf) / sizeof(wchar_t));
+ sum += extracted;
+ }
+ while (ifs.good() && extracted);
+ VERIFY( sum != 0 );
+}
+
+int
+main()
+{
+ test13();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/8258.cc b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/8258.cc
new file mode 100644
index 000000000..725c90259
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/readsome/wchar_t/8258.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+
+#include <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+// libstdc++/8258
+class mybuf : public std::basic_streambuf<wchar_t>
+{ };
+
+void test11()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ wchar_t arr[10];
+ mybuf sbuf;
+ basic_istream<wchar_t, char_traits<wchar_t> > istr(&sbuf);
+
+ VERIFY( istr.rdstate() == ios_base::goodbit );
+ VERIFY( istr.readsome(arr, 10) == 0 );
+ VERIFY( istr.rdstate() == ios_base::goodbit );
+}
+
+int
+main()
+{
+ test11();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/requirements/base_classes.cc b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/base_classes.cc
new file mode 100644
index 000000000..6454081f6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/base_classes.cc
@@ -0,0 +1,46 @@
+// { dg-do compile }
+// 2003-03-26 B enjamin Kosnik <bkoz@redhat.com>
+
+// 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/>.
+
+// 27.8.1.1 - Template class basic_filebuf
+
+#include <istream>
+#include <sstream>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::istream test_type;
+ typedef std::ios base_type;
+
+ std::stringbuf buf;
+ const test_type& obj = *new test_type(&buf);
+ const base_type* base __attribute__((unused)) = &obj;
+}
+
+// more surf!!!
+
+
+
+
+
+
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..6118eb137
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/explicit_instantiation.cc
@@ -0,0 +1,36 @@
+// { dg-do compile }
+// 1999-09-20 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.1 basic_istream
+// NB: This file is for testing istream with NO OTHER INCLUDES.
+
+#include <istream>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+namespace std
+{
+ using __gnu_test::pod_char;
+ typedef short type_t;
+ template class basic_istream<type_t, char_traits<type_t> >;
+ template class basic_istream<pod_char, char_traits<pod_char> >;
+} // test
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/requirements/typedefs.cc b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/typedefs.cc
new file mode 100644
index 000000000..f6167c070
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/requirements/typedefs.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+// 1999-09-20 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// 27.6.1.1 basic_istream
+// NB: This file is for testing istream with NO OTHER INCLUDES.
+
+#include <istream>
+#include <testsuite_hooks.h>
+
+// libstdc++/7216
+void test01()
+{
+ // Check for required typedefs
+ typedef std::istream test_type;
+ typedef test_type::char_type char_type;
+ typedef test_type::traits_type traits_type;
+ typedef test_type::int_type int_type;
+ typedef test_type::pos_type pos_type;
+ typedef test_type::off_type off_type;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc
new file mode 100644
index 000000000..56800531d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2.cc
@@ -0,0 +1,48 @@
+// 2003-04-22 pme
+
+// Copyright (C) 2003, 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.1.3 unformatted input functions
+// DR 60 -- seekg does not effect calls to gcount
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream ist("the lamb lies down on broadway");
+ ios::pos_type pos = ist.tellg();
+ ist.ignore(4);
+ int count1 = ist.gcount();
+ ist.seekg(pos);
+ int count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+ ist.seekg(ios::off_type(pos), ios::beg);
+ count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc
new file mode 100644
index 000000000..be2865078
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc
@@ -0,0 +1,63 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef istringstream::pos_type pos_type;
+
+ istringstream iss("Duos for Doris");
+ ostringstream oss;
+
+ const pos_type p0 = iss.tellg();
+ VERIFY( p0 == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( iss.good() );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(p0);
+ VERIFY( iss.good() );
+
+ iss.seekg(p0);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-1.cc
new file mode 100644
index 000000000..1c28cf369
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-1.cc
@@ -0,0 +1,52 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ string num1("555");
+
+ // seekg
+ {
+ istringstream iss(num1);
+ istream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(pos1);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-2.cc
new file mode 100644
index 000000000..899a48d78
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/8348-2.cc
@@ -0,0 +1,52 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010
+// 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ string num1("555");
+
+ // seekg
+ {
+ istringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(0, ios_base::beg);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..3d66ce70b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc
@@ -0,0 +1,87 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ istream::pos_type pos;
+
+ try
+ {
+ stream.seekg(pos);
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ istream::off_type off(5);
+
+ try
+ {
+ stream.seekg(off, ios_base::cur);
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+// libstdc++/9546
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc
new file mode 100644
index 000000000..503841a75
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc
@@ -0,0 +1,128 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ typedef std::istream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::istream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "istream_seeks-1.txt";
+ const char str_lit02[] = "istream_seeks-2.txt";
+ std::ifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+ std::ifstream if02(str_lit01, std::ios_base::in);
+ std::ifstream if03(str_lit02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::istream is01(if01.rdbuf());
+ std::istream is02(if02.rdbuf());
+ std::istream is03(if03.rdbuf());
+
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+
+ // istream& seekg(pos_type)
+ // istream& seekg(off_type, ios_base::seekdir)
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(10, std::ios_base::cur);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(10, std::ios_base::cur);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // beg
+ state01 = is01.rdstate();
+ is01.seekg(20, std::ios_base::beg);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(20, std::ios_base::beg);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(20, std::ios_base::beg);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/sstream.cc
new file mode 100644
index 000000000..183decc9e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/sstream.cc
@@ -0,0 +1,136 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// stringstreams
+void test05(void)
+{
+ typedef std::istream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::istream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "istream_seeks-1.tst";
+ std::ifstream if01(str_lit01);
+ std::ifstream if02(str_lit01);
+ std::ifstream if03(str_lit01);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::stringbuf strbuf01(std::ios_base::in | std::ios_base::out);
+ if01 >> &strbuf01;
+ // initialize stringbufs that are ios_base::out
+ std::stringbuf strbuf03(strbuf01.str(), std::ios_base::out);
+ // initialize stringbufs that are ios_base::in
+ std::stringbuf strbuf02(strbuf01.str(), std::ios_base::in);
+
+ std::istream is01(&strbuf01);
+ std::istream is02(&strbuf02);
+ std::istream is03(&strbuf03);
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+
+ // istream& seekg(pos_type)
+ // istream& seekg(off_type, ios_base::seekdir)
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(10, std::ios_base::cur);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(10, std::ios_base::cur);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 ); // as only out buffer
+ VERIFY( state01 != state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // beg
+ state01 = is01.rdstate();
+ is01.seekg(20, std::ios_base::beg);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(20, std::ios_base::beg);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(20, std::ios_base::beg);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 ); // as only out buffer
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/2.cc
new file mode 100644
index 000000000..c4088d8e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/2.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// DR 60 -- seekg does not effect calls to gcount
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream ist(L"the lamb lies down on broadway");
+ wios::pos_type pos = ist.tellg();
+ ist.ignore(4);
+ int count1 = ist.gcount();
+ ist.seekg(pos);
+ int count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+ ist.seekg(wios::off_type(pos), wios::beg);
+ count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc
new file mode 100644
index 000000000..2a73e1ec7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc
@@ -0,0 +1,63 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wistringstream::pos_type pos_type;
+
+ wistringstream iss(L"Duos for Doris");
+ wostringstream oss;
+
+ const pos_type p0 = iss.tellg();
+ VERIFY( p0 == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( iss.good() );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(p0);
+ VERIFY( iss.good() );
+
+ iss.seekg(p0);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-1.cc
new file mode 100644
index 000000000..f2d323744
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-1.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2004, 2005, 2006, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ wstring num1(L"555");
+
+ // seekg
+ {
+ wistringstream iss(num1);
+ wistream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(pos1);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-2.cc
new file mode 100644
index 000000000..d428a88ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/8348-2.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2004, 2005, 2006, 2009, 2010 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ wstring num1(L"555");
+
+ // seekg
+ {
+ wistringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(0, ios_base::beg);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..849e26863
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/exceptions_badbit_throw.cc
@@ -0,0 +1,87 @@
+// 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 <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ wistream::pos_type pos;
+
+ try
+ {
+ stream.seekg(pos);
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ wistream::off_type off(5);
+
+ try
+ {
+ stream.seekg(off, ios_base::cur);
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+// libstdc++/9546
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc
new file mode 100644
index 000000000..2aa7260e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc
@@ -0,0 +1,124 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ typedef std::wistream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::wistream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "wistream_seeks-1.txt";
+ const char str_lit02[] = "wistream_seeks-2.txt";
+ std::wifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+ std::wifstream if02(str_lit01, std::ios_base::in);
+ std::wifstream if03(str_lit02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::wistream is01(if01.rdbuf());
+ std::wistream is02(if02.rdbuf());
+ std::wistream is03(if03.rdbuf());
+
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+
+ // istream& seekg(pos_type)
+ // istream& seekg(off_type, ios_base::seekdir)
+
+ // cur
+ // NB: see library issues list 136. It's the v3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(10, std::ios_base::cur);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(10, std::ios_base::cur);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // beg
+ state01 = is01.rdstate();
+ is01.seekg(20, std::ios_base::beg);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(20, std::ios_base::beg);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(20, std::ios_base::beg);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc
new file mode 100644
index 000000000..dcc196b8b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc
@@ -0,0 +1,134 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// stringstreams
+void test05(void)
+{
+ typedef std::istream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::wistream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "wistream_seeks-1.tst";
+ std::wifstream if01(str_lit01);
+ std::wifstream if02(str_lit01);
+ std::wifstream if03(str_lit01);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::wstringbuf strbuf01(std::ios_base::in | std::ios_base::out);
+ if01 >> &strbuf01;
+ // initialize stringbufs that are ios_base::out
+ std::wstringbuf strbuf03(strbuf01.str(), std::ios_base::out);
+ // initialize stringbufs that are ios_base::in
+ std::wstringbuf strbuf02(strbuf01.str(), std::ios_base::in);
+
+ std::wistream is01(&strbuf01);
+ std::wistream is02(&strbuf02);
+ std::wistream is03(&strbuf03);
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+
+ // istream& seekg(pos_type)
+ // istream& seekg(off_type, ios_base::seekdir)
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(10, std::ios_base::cur);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(10, std::ios_base::cur);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 ); // as only out buffer
+ VERIFY( state01 != state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // beg
+ state01 = is01.rdstate();
+ is01.seekg(20, std::ios_base::beg);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+
+ state01 = is02.rdstate();
+ is02.seekg(20, std::ios_base::beg);
+ state02 = is02.rdstate();
+ pos03 = is02.tellg();
+ VERIFY( pos03 == pos04 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ state01 = is03.rdstate();
+ is03.seekg(20, std::ios_base::beg);
+ state02 = is03.rdstate();
+ pos05 = is03.tellg();
+ VERIFY( pos05 == pos06 ); // as only out buffer
+ VERIFY( state01 == state02 );
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/1.cc
new file mode 100644
index 000000000..e91d151fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/1.cc
@@ -0,0 +1,57 @@
+// 1999-10-14 bkoz
+
+// Copyright (C) 1999, 2001, 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ const char* lit01 = "stereolab on the bolsinga tip";
+ const std::string str01(lit01);
+
+ std::stringbuf strbuf01;
+ std::stringbuf strbuf02(str01);
+ std::istream istr01(&strbuf01);
+ std::istream istr02(&strbuf02);
+
+ // test negatives
+ std::istream::sentry sentry01(istr01);
+ VERIFY( bool(sentry01) == false );
+
+ std::istream::sentry sentry02(istr01, true);
+ VERIFY( bool(sentry02) == false );
+
+ // positive tests
+ std::istream::sentry sentry03(istr02);
+ VERIFY( bool(sentry03) == true );
+
+ std::istream::sentry sentry04(istr02, true);
+ VERIFY( bool(sentry04) == true );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc
new file mode 100644
index 000000000..48ce9df6f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc
@@ -0,0 +1,41 @@
+// 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ using namespace std;
+ istringstream stream;
+ stream.exceptions(ios_base::eofbit);
+
+ try
+ {
+ istream::sentry sentry(stream, false);
+ VERIFY( false );
+ }
+ catch (ios_base::failure&)
+ {
+ VERIFY( stream.rdstate() == (ios_base::eofbit | ios_base::failbit) );
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/2.cc
new file mode 100644
index 000000000..4c21fe089
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/2.cc
@@ -0,0 +1,51 @@
+// 1999-10-14 bkoz
+
+// Copyright (C) 1999, 2001, 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/944
+void
+test02()
+{
+ using namespace std;
+ istringstream in("80.21 56.89 12.3");
+ bool test __attribute__((unused)) = true;
+ int i = 0;
+ double x;
+
+ // ios_base::eof == 2
+ while (in >> x)
+ {
+ ++i;
+ if (i > 3)
+ break;
+ }
+ VERIFY( i == 3 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3.cc
new file mode 100644
index 000000000..c46103464
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3.cc
@@ -0,0 +1,44 @@
+// 1999-10-14 bkoz
+
+// Copyright (C) 1999, 2001, 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9562
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::stringbuf strbuf01;
+ std::istream strm1(&strbuf01);
+ const std::istream::sentry sentry1(strm1);
+
+ VERIFY( bool(sentry1) == false );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/pod/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/pod/1.cc
new file mode 100644
index 000000000..e995f9528
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/pod/1.cc
@@ -0,0 +1,166 @@
+// 1999-10-14 bkoz
+
+// 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <typeinfo>
+#include <ext/pod_char_traits.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+void test01()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef basic_string<pod_ushort> string_type;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_istream<pod_ushort> istream_type;
+
+ bool test __attribute__((unused)) = true;
+
+
+ const string_type str01;
+ stringbuf_type strbuf01;
+ stringbuf_type strbuf02(str01);
+ istream_type istr01(&strbuf01);
+ istream_type istr02(&strbuf02);
+
+ // test negatives
+ try
+ {
+ istream_type::sentry sentry01(istr01);
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ try
+ {
+ istream_type::sentry sentry02(istr01, true);
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ // imbued.
+ const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
+ istr01.imbue(loc);
+ try
+ {
+ istream_type::sentry sentry01(istr01);
+ VERIFY( bool(sentry01) == false );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ try
+ {
+ istream_type::sentry sentry02(istr01, true);
+ VERIFY( bool(sentry02) == false );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ // test positive
+ try
+ {
+ istream_type::sentry sentry03(istr02);
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ try
+ {
+ istream_type::sentry sentry04(istr02, true);
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ // imbued.
+ istr02.imbue(loc);
+ try
+ {
+ istr02.clear();
+ istream_type::sentry sentry03(istr02);
+ // ... as eofbit set.
+ VERIFY( bool(sentry03) == false );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ try
+ {
+ istr02.clear();
+ istream_type::sentry sentry04(istr02, true);
+ VERIFY( bool(sentry04) == true );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/1.cc
new file mode 100644
index 000000000..1e4b11723
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/1.cc
@@ -0,0 +1,55 @@
+// 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.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* lit01 = L"stereolab on the bolsinga tip";
+ const std::wstring str01(lit01);
+
+ std::wstringbuf strbuf01;
+ std::wstringbuf strbuf02(str01);
+ std::wistream istr01(&strbuf01);
+ std::wistream istr02(&strbuf02);
+
+ // test negatives
+ std::wistream::sentry sentry01(istr01);
+ VERIFY( bool(sentry01) == false );
+
+ std::wistream::sentry sentry02(istr01, true);
+ VERIFY( bool(sentry02) == false );
+
+ // positive tests
+ std::wistream::sentry sentry03(istr02);
+ VERIFY( bool(sentry03) == true );
+
+ std::wistream::sentry sentry04(istr02, true);
+ VERIFY( bool(sentry04) == true );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc
new file mode 100644
index 000000000..3ce0854d1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc
@@ -0,0 +1,41 @@
+// 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.1.2 class basic_istream::sentry
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ using namespace std;
+ wistringstream stream;
+ stream.exceptions(ios_base::eofbit);
+
+ try
+ {
+ wistream::sentry sentry(stream, false);
+ VERIFY( false );
+ }
+ catch (ios_base::failure&)
+ {
+ VERIFY( stream.rdstate() == (ios_base::eofbit | ios_base::failbit) );
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/2.cc
new file mode 100644
index 000000000..8266ea6f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/2.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.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/944
+void
+test02()
+{
+ using namespace std;
+ wistringstream in(L"80.21 56.89 12.3");
+ bool test __attribute__((unused)) = true;
+ int i = 0;
+ double x;
+
+ // ios_base::eof == 2
+ while (in >> x)
+ {
+ ++i;
+ if (i > 3)
+ break;
+ }
+ VERIFY( i == 3 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/3.cc
new file mode 100644
index 000000000..e325678c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/3.cc
@@ -0,0 +1,42 @@
+// 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.1.2 class basic_istream::sentry
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9562
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstringbuf strbuf01;
+ std::wistream strm1(&strbuf01);
+ const std::wistream::sentry sentry1(strm1);
+
+ VERIFY( bool(sentry1) == false );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
new file mode 100644
index 000000000..b2680d563
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
@@ -0,0 +1,68 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef ios::off_type off_type;
+ typedef ios::pos_type pos_type;
+
+ bool test __attribute__((unused)) = true;
+ const char str_lit01[] = "istream_seeks-1.tst";
+
+ // in
+ istringstream ist1;
+ pos_type p3 = ist1.tellg();
+
+ ifstream ifs1;
+ pos_type p4 = ifs1.tellg();
+
+ // N.B. We implement the resolution of DR 453 and
+ // istringstream::tellg() doesn't fail.
+ VERIFY( p3 == pos_type(off_type(0)) );
+ VERIFY( p4 == pos_type(off_type(-1)) );
+
+ // in
+ // test ctors leave things in the same positions...
+ istringstream ist2("bob_marley:kaya");
+ p3 = ist2.tellg();
+
+ ifstream ifs2(str_lit01);
+ p4 = ifs2.tellg();
+
+ VERIFY( p3 == p4 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc
new file mode 100644
index 000000000..08cdee697
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/2.cc
@@ -0,0 +1,44 @@
+// 2003-04-22 pme
+
+// Copyright (C) 2003, 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.1.3 unformatted input functions
+// DR 60 -- tellg does not effect calls to gcount
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ istringstream ist("three sides live");
+ ist.ignore(4);
+ int count1 = ist.gcount();
+ ist.tellg();
+ int count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc
new file mode 100644
index 000000000..6677f9410
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc
@@ -0,0 +1,49 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef istringstream::pos_type pos_type;
+
+ istringstream iss("Duos for Doris");
+ ostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+ VERIFY( iss.tellg() == pos_type(-1) );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(14) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc
new file mode 100644
index 000000000..62bdd5025
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc
@@ -0,0 +1,77 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010
+// 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ string num1("555");
+
+ // tellg
+ {
+ istringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.clear();
+ iss.tellg();
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ istringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(0, ios_base::beg);
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ istringstream iss(num1);
+ istream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(pos1);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..9e58be998
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc
@@ -0,0 +1,57 @@
+// 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 <istream>
+#include <streambuf>
+#include <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_streambuf bib;
+ istream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ try
+ {
+ stream.tellg();
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+// libstdc++/9546
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc
new file mode 100644
index 000000000..da57149c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc
@@ -0,0 +1,88 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ typedef std::istream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::istream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "istream_seeks-1.txt";
+ const char str_lit02[] = "istream_seeks-2.txt";
+ std::ifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+ std::ifstream if02(str_lit01, std::ios_base::in);
+ std::ifstream if03(str_lit02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::istream is01(if01.rdbuf());
+ std::istream is02(if02.rdbuf());
+ std::istream is03(if03.rdbuf());
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ VERIFY( pos01 == pos02 );
+
+ // in
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ // out
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/sstream.cc
new file mode 100644
index 000000000..4db3fc124
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/sstream.cc
@@ -0,0 +1,94 @@
+// 2000-06-29 bkoz
+
+// Copyright (C) 2000, 2001, 2002, 2003, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// stringstreams
+void test05(void)
+{
+ typedef std::istream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::istream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "istream_seeks-1.tst";
+ std::ifstream if01(str_lit01);
+ std::ifstream if02(str_lit01);
+ std::ifstream if03(str_lit01);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::stringbuf strbuf01(std::ios_base::in | std::ios_base::out);
+ if01 >> &strbuf01;
+ // initialize stringbufs that are ios_base::out
+ std::stringbuf strbuf03(strbuf01.str(), std::ios_base::out);
+ // initialize stringbufs that are ios_base::in
+ std::stringbuf strbuf02(strbuf01.str(), std::ios_base::in);
+
+ std::istream is01(&strbuf01);
+ std::istream is02(&strbuf02);
+ std::istream is03(&strbuf03);
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ VERIFY( pos01 == pos02 );
+
+ // in
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ // out
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/1.cc
new file mode 100644
index 000000000..798b7fe6f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/1.cc
@@ -0,0 +1,64 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef ios::off_type off_type;
+ typedef ios::pos_type pos_type;
+
+ bool test __attribute__((unused)) = true;
+ const char str_lit01[] = "wistream_seeks-1.tst";
+
+ // in
+ wistringstream ist1;
+ pos_type p3 = ist1.tellg();
+
+ wifstream ifs1;
+ pos_type p4 = ifs1.tellg();
+
+ // N.B. We implement the resolution of DR 453 and
+ // istringstream::tellg() doesn't fail.
+ VERIFY( p3 == pos_type(off_type(0)) );
+ VERIFY( p4 == pos_type(off_type(-1)) );
+
+ // in
+ // test ctors leave things in the same positions...
+ wistringstream ist2(L"bob_marley:kaya");
+ p3 = ist2.tellg();
+
+ wifstream ifs2(str_lit01);
+ p4 = ifs2.tellg();
+
+ VERIFY( p3 == p4 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/2.cc
new file mode 100644
index 000000000..439f3ae33
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/2.cc
@@ -0,0 +1,42 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// DR 60 -- tellg does not effect calls to gcount
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wistringstream ist(L"three sides live");
+ ist.ignore(4);
+ int count1 = ist.gcount();
+ ist.tellg();
+ int count2 = ist.gcount();
+ VERIFY( count1 == count2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc
new file mode 100644
index 000000000..7d88d5c1f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc
@@ -0,0 +1,49 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wistringstream::pos_type pos_type;
+
+ wistringstream iss(L"Duos for Doris");
+ wostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+ VERIFY( iss.tellg() == pos_type(-1) );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(14) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc
new file mode 100644
index 000000000..6979b9c06
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc
@@ -0,0 +1,74 @@
+// Copyright (C) 2004, 2005, 2006, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ wstring num1(L"555");
+
+ // tellg
+ {
+ wistringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.clear();
+ iss.tellg();
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ wistringstream iss(num1);
+ iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(0, ios_base::beg);
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ wistringstream iss(num1);
+ wistream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(pos1);
+ VERIFY( test = !iss.fail() );
+ }
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/exceptions_badbit_throw.cc
new file mode 100644
index 000000000..1b7c96224
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/exceptions_badbit_throw.cc
@@ -0,0 +1,57 @@
+// 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 <sstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+using namespace std;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::fail_wstreambuf bib;
+ wistream stream(&bib);
+ stream.exceptions(ios_base::badbit);
+
+ try
+ {
+ stream.tellg();
+ VERIFY( false );
+ }
+ catch (const __gnu_test::positioning_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);
+ }
+}
+
+// libstdc++/9546
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc
new file mode 100644
index 000000000..9878e4772
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// fstreams
+void test04(void)
+{
+ typedef std::wistream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::wistream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "wistream_seeks-1.txt";
+ const char str_lit02[] = "wistream_seeks-2.txt";
+ std::wifstream if01(str_lit01, std::ios_base::in | std::ios_base::out);
+ std::wifstream if02(str_lit01, std::ios_base::in);
+ std::wifstream if03(str_lit02, std::ios_base::out | std::ios_base::trunc);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::wistream is01(if01.rdbuf());
+ std::wistream is02(if02.rdbuf());
+ std::wistream is03(if03.rdbuf());
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ VERIFY( pos01 == pos02 );
+
+ // in
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ // out
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc
new file mode 100644
index 000000000..e440a22cf
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc
@@ -0,0 +1,90 @@
+// Copyright (C) 2004, 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.1.3 unformatted input functions
+// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %-*.txt
+
+#include <istream>
+#include <sstream>
+#include <fstream>
+#include <testsuite_hooks.h>
+
+// stringstreams
+void test05(void)
+{
+ typedef std::wistream::off_type off_type;
+
+ bool test __attribute__((unused)) = true;
+ std::wistream::pos_type pos01, pos02, pos03, pos04, pos05, pos06;
+ std::ios_base::iostate state01, state02;
+ const char str_lit01[] = "wistream_seeks-1.tst";
+ std::wifstream if01(str_lit01);
+ std::wifstream if02(str_lit01);
+ std::wifstream if03(str_lit01);
+ VERIFY( if01.good() );
+ VERIFY( if02.good() );
+ VERIFY( if03.good() );
+
+ std::wstringbuf strbuf01(std::ios_base::in | std::ios_base::out);
+ if01 >> &strbuf01;
+ // initialize stringbufs that are ios_base::out
+ std::wstringbuf strbuf03(strbuf01.str(), std::ios_base::out);
+ // initialize stringbufs that are ios_base::in
+ std::wstringbuf strbuf02(strbuf01.str(), std::ios_base::in);
+
+ std::wistream is01(&strbuf01);
+ std::wistream is02(&strbuf02);
+ std::wistream is03(&strbuf03);
+
+ // pos_type tellg()
+ // in | out
+ pos01 = is01.tellg();
+ pos02 = is01.tellg();
+ VERIFY( pos01 == pos02 );
+
+ // in
+ pos03 = is02.tellg();
+ pos04 = is02.tellg();
+ VERIFY( pos03 == pos04 );
+
+ // out
+ pos05 = is03.tellg();
+ pos06 = is03.tellg();
+ VERIFY( pos05 == pos06 );
+
+ // cur
+ // NB: see library issues list 136. It's the v-3 interp that seekg
+ // only sets the input buffer, or else istreams with buffers that
+ // have _M_mode == ios_base::out will fail to have consistency
+ // between seekg and tellg.
+ state01 = is01.rdstate();
+ is01.seekg(10, std::ios_base::cur);
+ state02 = is01.rdstate();
+ pos01 = is01.tellg();
+ VERIFY( pos01 == pos02 + off_type(10) );
+ VERIFY( state01 == state02 );
+ pos02 = is01.tellg();
+ VERIFY( pos02 == pos01 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ws/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ws/char/1.cc
new file mode 100644
index 000000000..b59d08839
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ws/char/1.cc
@@ -0,0 +1,77 @@
+// 1999-07-22 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2003, 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.4 standard basic_istream manipulators
+
+#include <istream>
+#include <sstream>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ const char str_lit01[] = " venice ";
+ const std::string str01(" santa barbara ");
+ std::string str02(str_lit01);
+ std::string str04;
+ std::string str05;
+
+ // template<_CharT, _Traits>
+ // basic_istream<_CharT, _Traits>& ws(basic_istream<_Char, _Traits>& is)
+ std::istringstream iss01(str01);
+ std::istringstream iss02(str01);
+
+ iss01 >> str04;
+ VERIFY( str04.size() != str01.size() );
+ VERIFY( str04 == "santa" );
+
+ iss02 >> std::ws;
+ iss02 >> str05;
+ VERIFY( str05.size() != str01.size() );
+ VERIFY( str05 == "santa" );
+ VERIFY( str05 == str04 );
+
+ iss01 >> str04;
+ VERIFY( str04.size() != str01.size() );
+ VERIFY( str04 == "barbara" );
+
+ iss02 >> std::ws;
+ iss02 >> str05;
+ VERIFY( str05.size() != str01.size() );
+ VERIFY( str05 == "barbara" );
+ VERIFY( str05 == str04 );
+
+ VERIFY( !iss01.fail() );
+ VERIFY( !iss02.fail() );
+ VERIFY( !iss01.eof() );
+ VERIFY( !iss02.eof() );
+
+ iss01 >> std::ws;
+ VERIFY( !iss01.fail() );
+ VERIFY( iss01.eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ws/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ws/wchar_t/1.cc
new file mode 100644
index 000000000..8e60163c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ws/wchar_t/1.cc
@@ -0,0 +1,74 @@
+// 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.4 standard basic_istream manipulators
+
+#include <istream>
+#include <sstream>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ const wchar_t str_lit01[] = L" venice ";
+ const std::wstring str01(L" santa barbara ");
+ std::wstring str02(str_lit01);
+ std::wstring str04;
+ std::wstring str05;
+
+ // template<_CharT, _Traits>
+ // basic_istream<_CharT, _Traits>& ws(basic_istream<_Char, _Traits>& is)
+ std::wistringstream iss01(str01);
+ std::wistringstream iss02(str01);
+
+ iss01 >> str04;
+ VERIFY( str04.size() != str01.size() );
+ VERIFY( str04 == L"santa" );
+
+ iss02 >> std::ws;
+ iss02 >> str05;
+ VERIFY( str05.size() != str01.size() );
+ VERIFY( str05 == L"santa" );
+ VERIFY( str05 == str04 );
+
+ iss01 >> str04;
+ VERIFY( str04.size() != str01.size() );
+ VERIFY( str04 == L"barbara" );
+
+ iss02 >> std::ws;
+ iss02 >> str05;
+ VERIFY( str05.size() != str01.size() );
+ VERIFY( str05 == L"barbara" );
+ VERIFY( str05 == str04 );
+
+ VERIFY( !iss01.fail() );
+ VERIFY( !iss02.fail() );
+ VERIFY( !iss01.eof() );
+ VERIFY( !iss02.eof() );
+
+ iss01 >> std::ws;
+ VERIFY( !iss01.fail() );
+ VERIFY( iss01.eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}