summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/27_io/basic_istream/extractors_other
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/extractors_other')
-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
23 files changed, 1642 insertions, 0 deletions
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;
+}