summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_stringstream
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_stringstream')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/cons/2020.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc59
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/base_classes.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/explicit_instantiation.cc35
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/typedefs.cc38
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc76
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc74
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/4.cc44
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc56
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc42
14 files changed, 786 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/2020.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/2020.cc
new file mode 100644
index 000000000..3f04bbd71
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/2020.cc
@@ -0,0 +1,54 @@
+// 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
+// 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 <sstream>
+#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_stringstream<__gnu_test::pod_ushort> gnu_sstr;
+
+ try
+ {
+ gnu_sstr obj;
+ }
+ catch(std::exception& obj)
+ {
+ test = false;
+ VERIFY( test );
+ }
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
+
+
+
+// more surf!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc
new file mode 100644
index 000000000..5fd832be2
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/char/2832.cc
@@ -0,0 +1,61 @@
+// 2003-04-01 Benjamin 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.7.6 - Member functions [lib.stringstream.members]
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+redirect_buffer(std::ios& stream, std::streambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::streambuf*
+active_buffer(std::ios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ std::stringbuf sbuf;
+ std::streambuf* pbasebuf0 = &sbuf;
+
+ std::stringstream sstrm1;
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::stringbuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::streambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &sbuf);
+ std::stringbuf* const buf2 = sstrm1.rdbuf();
+ std::streambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.cc
new file mode 100644
index 000000000..df1b1e868
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/rdbuf/wchar_t/2832.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/>.
+
+// 27.7.6 - Member functions [lib.stringstream.members]
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+redirect_buffer(std::wios& stream, std::wstreambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::wstreambuf*
+active_buffer(std::wios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstringbuf sbuf;
+ std::wstreambuf* pbasebuf0 = &sbuf;
+
+ std::wstringstream sstrm1;
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::wstringbuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::wstreambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &sbuf);
+ std::wstringbuf* const buf2 = sstrm1.rdbuf();
+ std::wstreambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/base_classes.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/base_classes.cc
new file mode 100644
index 000000000..a68f5eb1d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/base_classes.cc
@@ -0,0 +1,44 @@
+// { 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 <iostream>
+#include <sstream>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::stringstream test_type;
+ typedef std::iostream base_type;
+ const test_type& obj = *new test_type();
+ const base_type* base __attribute__((unused)) = &obj;
+}
+
+// more surf!!!
+
+
+
+
+
+
+
+
+
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..ae134cd62
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/explicit_instantiation.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 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.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>
+
+namespace std
+{
+ using __gnu_test::pod_char;
+ typedef short type_t;
+ template class basic_stringstream<type_t, char_traits<type_t> >;
+ template class basic_stringstream<pod_char, char_traits<pod_char> >;
+} // std
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/typedefs.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/typedefs.cc
new file mode 100644
index 000000000..1fa4eb718
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/requirements/typedefs.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 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.7.4 - Template class basic_stringstream
+// NB: This file is for testing basic_stringstream with NO OTHER INCLUDES.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/7216
+void test01()
+{
+ // Check for required typedefs
+ typedef std::stringstream 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_stringstream/str/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc
new file mode 100644
index 000000000..f8f3ef129
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/1.cc
@@ -0,0 +1,76 @@
+// 2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::stringstream is01;
+ const std::string str00;
+ const std::string str01 = "123";
+ std::string str02;
+ const int i01 = 123;
+ int a = 0, b = 0;
+
+ std::ios_base::iostate state1, state2, stateeof;
+ stateeof = std::ios_base::eofbit;
+
+ // string str() const
+ str02 = is01.str();
+ VERIFY( str00 == str02 );
+
+ // void str(const basic_string&)
+ is01.str(str01);
+ str02 = is01.str();
+ VERIFY( str01 == str02 );
+ state1 = is01.rdstate();
+ is01 >> a;
+ state2 = is01.rdstate();
+ VERIFY( a == i01 );
+ // 22.2.2.1.2 num_get virtual functions
+ // p 13
+ // in any case, if stage 2 processing was terminated by the test for
+ // in == end then err != ios_base::eofbit is performed.
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+
+ is01.str(str01);
+ is01 >> b;
+ VERIFY( b != a );
+ // as is01.good() is false, istream::sentry blocks extraction.
+
+ is01.clear();
+ state1 = is01.rdstate();
+ is01 >> b;
+ state2 = is01.rdstate();
+ VERIFY( b == a );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc
new file mode 100644
index 000000000..46418e648
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/2.cc
@@ -0,0 +1,74 @@
+// 2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+redirect_buffer(std::ios& stream, std::streambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::streambuf*
+active_buffer(std::ios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* strlit01 = "fuck war";
+ const std::string str00;
+ const std::string str01(strlit01);
+ std::string str02;
+ std::stringbuf sbuf(str01);
+ std::streambuf* pbasebuf0 = &sbuf;
+
+ std::stringstream sstrm1;
+ VERIFY( sstrm1.str() == str00 );
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::stringbuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::streambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &sbuf);
+ std::stringbuf* const buf2 = sstrm1.rdbuf();
+ std::streambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // derived rdbuf() returns the original buf, so str() doesn't change.
+ VERIFY( sstrm1.str() != str01 );
+ VERIFY( sstrm1.str() == str00 );
+ // however, casting the active streambuf to a stringbuf shows what's up:
+ std::stringbuf* psbuf = dynamic_cast<std::stringbuf*>(pbasebuf2);
+ str02 = psbuf->str();
+ VERIFY( str02 == str01 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc
new file mode 100644
index 000000000..b6137878c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/3.cc
@@ -0,0 +1,58 @@
+// 2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 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/>.
+
+// 27.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ //
+ // 1: Automatic formatting of a compound string
+ //
+ int i = 1024;
+ int *pi = &i;
+ double d = 3.14159;
+ double *pd = &d;
+ std::string blank;
+ std::ostringstream ostrst01;
+ std::ostringstream ostrst02(blank);
+
+ // No buffer, so should be created.
+ ostrst01 << "i: " << i << " i's address: " << pi << '\n'
+ << "d: " << d << " d's address: " << pd << std::endl;
+ // Buffer, so existing buffer should be overwritten.
+ ostrst02 << "i: " << i << " i's address: " << pi << '\n'
+ << "d: " << d << " d's address: " << pd << std::endl;
+
+ std::string msg01 = ostrst01.str();
+ std::string msg02 = ostrst02.str();
+ VERIFY( msg01 == msg02 );
+ VERIFY( msg02 != blank );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/4.cc
new file mode 100644
index 000000000..6bd9b1d03
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/char/4.cc
@@ -0,0 +1,44 @@
+// 2001-05-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8466
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const char* strlit00 = "orvieto";
+ const std::string str00 = strlit00;
+
+ std::ostringstream oss;
+
+ oss.str(str00);
+ oss << "cortona";
+ VERIFY( str00 == strlit00 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc
new file mode 100644
index 000000000..c8b4b4d48
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/1.cc
@@ -0,0 +1,73 @@
+// Copyright (C) 2004, 2005, 2006, 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstringstream is01;
+ const std::wstring str00;
+ const std::wstring str01 = L"123";
+ std::wstring str02;
+ const int i01 = 123;
+ int a = 0, b = 0;
+
+ std::ios_base::iostate state1, state2, stateeof;
+ stateeof = std::ios_base::eofbit;
+
+ // string str() const
+ str02 = is01.str();
+ VERIFY( str00 == str02 );
+
+ // void str(const basic_string&)
+ is01.str(str01);
+ str02 = is01.str();
+ VERIFY( str01 == str02 );
+ state1 = is01.rdstate();
+ is01 >> a;
+ state2 = is01.rdstate();
+ VERIFY( a == i01 );
+ // 22.2.2.1.2 num_get virtual functions
+ // p 13
+ // in any case, if stage 2 processing was terminated by the test for
+ // in == end then err != ios_base::eofbit is performed.
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+
+ is01.str(str01);
+ is01 >> b;
+ VERIFY( b != a );
+ // as is01.good() is false, istream::sentry blocks extraction.
+
+ is01.clear();
+ state1 = is01.rdstate();
+ is01 >> b;
+ state2 = is01.rdstate();
+ VERIFY( b == a );
+ VERIFY( state1 != state2 );
+ VERIFY( state2 == stateeof );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc
new file mode 100644
index 000000000..b7ab009ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/2.cc
@@ -0,0 +1,72 @@
+// 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+redirect_buffer(std::wios& stream, std::wstreambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::wstreambuf*
+active_buffer(std::wios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* strlit01 = L"fuck war";
+ const std::wstring str00;
+ const std::wstring str01(strlit01);
+ std::wstring str02;
+ std::wstringbuf sbuf(str01);
+ std::wstreambuf* pbasebuf0 = &sbuf;
+
+ std::wstringstream sstrm1;
+ VERIFY( sstrm1.str() == str00 );
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::wstringbuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::wstreambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &sbuf);
+ std::wstringbuf* const buf2 = sstrm1.rdbuf();
+ std::wstreambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // derived rdbuf() returns the original buf, so str() doesn't change.
+ VERIFY( sstrm1.str() != str01 );
+ VERIFY( sstrm1.str() == str00 );
+ // however, casting the active streambuf to a stringbuf shows what's up:
+ std::wstringbuf* psbuf = dynamic_cast<std::wstringbuf*>(pbasebuf2);
+ str02 = psbuf->str();
+ VERIFY( str02 == str01 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc
new file mode 100644
index 000000000..ffcf3eaed
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/3.cc
@@ -0,0 +1,56 @@
+// 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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ //
+ // 1: Automatic formatting of a compound string
+ //
+ int i = 1024;
+ int *pi = &i;
+ double d = 3.14159;
+ double *pd = &d;
+ std::wstring blank;
+ std::wostringstream ostrst01;
+ std::wostringstream ostrst02(blank);
+
+ // No buffer, so should be created.
+ ostrst01 << L"i: " << i << L" i's address: " << pi << L'\n'
+ << L"d: " << d << L" d's address: " << pd << std::endl;
+ // Buffer, so existing buffer should be overwritten.
+ ostrst02 << L"i: " << i << L" i's address: " << pi << L'\n'
+ << L"d: " << d << L" d's address: " << pd << std::endl;
+
+ std::wstring msg01 = ostrst01.str();
+ std::wstring msg02 = ostrst02.str();
+ VERIFY( msg01 == msg02 );
+ VERIFY( msg02 != blank );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.cc
new file mode 100644
index 000000000..4c6590cd8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/str/wchar_t/4.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.7.6 member functions (stringstream_members)
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/8466
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ const wchar_t* strlit00 = L"orvieto";
+ const std::wstring str00 = strlit00;
+
+ std::wostringstream oss;
+
+ oss.str(str00);
+ oss << L"cortona";
+ VERIFY( str00 == strlit00 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}