summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_streambuf
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_streambuf')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/cons/2020.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc45
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc45
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/1.cc52
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc50
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc62
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/1.cc52
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc50
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc62
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/9322.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc111
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/2.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/3599.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/1.cc110
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/2.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/3599.cc60
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/base_classes.cc36
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/typedefs.cc39
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc113
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc112
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc123
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/wchar_t/1.cc122
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/char/9538.cc66
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/wchar_t/9538.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char/1057.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/wchar_t/1057.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc117
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1057.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1.cc118
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1057.cc53
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sync/char/1057.cc101
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/sync/wchar_t/1057.cc101
35 files changed, 2520 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/2020.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/2020.cc
new file mode 100644
index 000000000..eae9453a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/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 <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// libstdc++/2020
+// should be able to use custom char_type, custom traits type
+class gnu_sbuf: public std::basic_streambuf<__gnu_test::pod_ushort>
+{ };
+
+void test07()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ { gnu_sbuf 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_streambuf/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
new file mode 100644
index 000000000..6308318f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
@@ -0,0 +1,45 @@
+// 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 <streambuf>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::constraint_streambuf buf01;
+
+ // 27.5.2.1 basic_streambuf ctors
+ // default ctor initializes
+ // - all pointer members to null pointers
+ // - locale to current global locale
+ VERIFY( buf01.check_pointers() );
+ VERIFY( buf01.getloc() == std::locale() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc
new file mode 100644
index 000000000..0fb1f5cbd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/cons/wchar_t/1.cc
@@ -0,0 +1,45 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ __gnu_test::constraint_wstreambuf buf01;
+
+ // 27.5.2.1 basic_streambuf ctors
+ // default ctor initializes
+ // - all pointer members to null pointers
+ // - locale to current global locale
+ VERIFY( buf01.check_pointers() );
+ VERIFY( buf01.getloc() == std::locale() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/1.cc
new file mode 100644
index 000000000..6e2a4a4a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/1.cc
@@ -0,0 +1,52 @@
+// 981208 bkoz test functionality of basic_stringbuf for char_type == char
+
+// Copyright (C) 1997, 1998, 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/>.
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+ typedef std::streambuf::traits_type traits_type;
+
+ testbuf() : std::streambuf() { }
+};
+
+// test the streambuf locale settings
+void test02()
+{
+ testbuf buf;
+ std::locale loc_c = std::locale::classic();
+ loc_c = buf.getloc();
+ buf.pubimbue(loc_c); //This should initialize _M_init to true
+ std::locale loc_tmp = buf.getloc();
+ VERIFY( loc_tmp == loc_c );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
+
+// more candy!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc
new file mode 100644
index 000000000..5b54ebc36
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc
@@ -0,0 +1,50 @@
+// { dg-require-namedlocale "is_IS.UTF-8" }
+
+// Copyright (C) 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.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf1 : public std::streambuf
+{
+protected:
+ void imbue(const std::locale&)
+ { }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf1 buf;
+ std::locale loc(std::locale("is_IS.UTF-8"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc
new file mode 100644
index 000000000..4b3c903c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc
@@ -0,0 +1,62 @@
+// { dg-require-namedlocale "en_US" }
+
+// Copyright (C) 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.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf2 : public std::streambuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::streambuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf2 buf;
+ std::locale loc(std::locale("en_US"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc
new file mode 100644
index 000000000..dcc42ee7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/9322.cc
@@ -0,0 +1,65 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "de_DE" }
+
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+ typedef std::streambuf::traits_type traits_type;
+
+ testbuf() : std::streambuf() { }
+};
+
+// libstdc++/9322
+void test08()
+{
+ using std::locale;
+ bool test __attribute__((unused)) = true;
+
+ locale loc;
+ testbuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de = locale("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/1.cc
new file mode 100644
index 000000000..f8448912a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/1.cc
@@ -0,0 +1,52 @@
+// 981208 bkoz test functionality of basic_streambuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 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/>.
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+ typedef std::wstreambuf::traits_type traits_type;
+
+ testbuf() : std::wstreambuf() { }
+};
+
+// test the streambuf locale settings
+void test02()
+{
+ testbuf buf;
+ std::locale loc_c = std::locale::classic();
+ loc_c = buf.getloc();
+ buf.pubimbue(loc_c); //This should initialize _M_init to true
+ std::locale loc_tmp = buf.getloc();
+ VERIFY( loc_tmp == loc_c );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
+
+// more candy!!!
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc
new file mode 100644
index 000000000..b0e7a61b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc
@@ -0,0 +1,50 @@
+// { dg-require-namedlocale "is_IS.UTF-8" }
+
+// Copyright (C) 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.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf1 : public std::wstreambuf
+{
+protected:
+ void imbue(const std::locale&)
+ { }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf1 buf;
+ std::locale loc(std::locale("is_IS.UTF-8"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc
new file mode 100644
index 000000000..15007de2a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc
@@ -0,0 +1,62 @@
+// { dg-require-namedlocale "en_US" }
+
+// Copyright (C) 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.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf2 : public std::wstreambuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::wstreambuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf2 buf;
+ std::locale loc(std::locale("en_US"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/9322.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/9322.cc
new file mode 100644
index 000000000..1d4d494c4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/9322.cc
@@ -0,0 +1,65 @@
+// { dg-require-namedlocale "en_US" }
+// { dg-require-namedlocale "de_DE" }
+
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+ typedef std::wstreambuf::traits_type traits_type;
+
+ testbuf() : std::wstreambuf() { }
+};
+
+// libstdc++/9322
+void test08()
+{
+ using std::locale;
+ bool test __attribute__((unused)) = true;
+
+ locale loc;
+ testbuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de = locale("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc
new file mode 100644
index 000000000..ed9e7f15f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc
@@ -0,0 +1,53 @@
+// 2005-06-07 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+typedef std::basic_streambuf<char> streambuf_type;
+
+struct testbuf : streambuf_type
+{
+ testbuf() { }
+};
+
+void test05()
+{
+ typedef streambuf_type::int_type int_type;
+ typedef streambuf_type::traits_type traits_type;
+ typedef streambuf_type::pos_type pos_type;
+ typedef streambuf_type::off_type off_type;
+ typedef size_t size_type;
+
+ bool test __attribute__((unused)) = true;
+ std::streamoff strmof_1;
+ testbuf sb01;
+
+ // int in_avail()
+ strmof_1 = sb01.in_avail();
+ VERIFY( strmof_1 == 0 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc
new file mode 100644
index 000000000..ba978f676
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc
@@ -0,0 +1,53 @@
+// 2005-06-07 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+typedef std::basic_streambuf<wchar_t> streambuf_type;
+
+struct testbuf : streambuf_type
+{
+ testbuf() { }
+};
+
+void test05()
+{
+ typedef streambuf_type::int_type int_type;
+ typedef streambuf_type::traits_type traits_type;
+ typedef streambuf_type::pos_type pos_type;
+ typedef streambuf_type::off_type off_type;
+ typedef size_t size_type;
+
+ bool test __attribute__((unused)) = true;
+ std::streamoff strmof_1;
+ testbuf sb01;
+
+ // int in_avail()
+ strmof_1 = sb01.in_avail();
+ VERIFY( strmof_1 == 0 );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc
new file mode 100644
index 000000000..65aff09ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc
@@ -0,0 +1,111 @@
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::streambuf::traits_type traits_type;
+ typedef std::streambuf::char_type char_type;
+
+ testbuf(): std::streambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(char* beg, char* cur, char *end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(char* beg, char* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ char lit01[52];
+ std::strcpy(lit01, "chicago underground trio/possible cube on delmark");
+ testbuf buf01;
+
+ // pbackfail
+ int i01 = 3;
+ buf01.pub_setg(lit01, lit01, (lit01 + i01));
+ VERIFY( i01 == buf01.in_avail() );
+ int_type intt01 = traits_type::to_int_type('b');
+ VERIFY( traits_type::eof() == buf01.pub_pbackfail(intt01) );
+
+ // overflow
+ VERIFY( traits_type::eof() == buf01.pub_overflow(intt01) );
+ VERIFY( traits_type::eof() == buf01.pub_overflow() );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[0]) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/2.cc
new file mode 100644
index 000000000..2544d3398
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/2.cc
@@ -0,0 +1,73 @@
+// 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 <streambuf>
+#include <ostream>
+#include <string>
+#include <testsuite_hooks.h>
+
+// test03
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html
+template<typename charT, typename traits = std::char_traits<charT> >
+ class basic_nullbuf : public std::basic_streambuf<charT, traits>
+ {
+ protected:
+ typedef typename
+ std::basic_streambuf<charT, traits>::int_type int_type;
+ virtual int_type
+ overflow(int_type c)
+ { return traits::not_eof(c); }
+ };
+
+typedef basic_nullbuf<char> nullbuf;
+
+template<typename T>
+ char
+ print(const T& x)
+ {
+ nullbuf ob;
+ std::ostream out(&ob);
+ out << x << std::endl;
+ return (!out ? '0' : '1');
+ }
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string control01("11111");
+ std::string test01;
+
+ test01 += print(true);
+ test01 += print(3.14159);
+ test01 += print(10);
+ test01 += print('x');
+ test01 += print("pipo");
+
+ VERIFY( test01 == control01 );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/3599.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/3599.cc
new file mode 100644
index 000000000..16d117eed
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/3599.cc
@@ -0,0 +1,60 @@
+// 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 <streambuf>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3599
+class testbuf : public std::streambuf
+{
+public:
+ typedef std::streambuf::traits_type traits_type;
+
+ testbuf() : std::streambuf() { }
+
+protected:
+ int_type
+ overflow(int_type c __attribute__((unused)) = traits_type::eof())
+ { return traits_type::not_eof(0); }
+};
+
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ testbuf ob;
+ std::ostream out(&ob);
+
+ out << "gasp";
+ VERIFY( out.good() );
+
+ out << std::endl;
+ VERIFY( out.good() );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/1.cc
new file mode 100644
index 000000000..30b67e4e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/1.cc
@@ -0,0 +1,110 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::wstreambuf::traits_type traits_type;
+ typedef std::wstreambuf::char_type char_type;
+
+ testbuf(): std::wstreambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(wchar_t* beg, wchar_t* cur, wchar_t* end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(wchar_t* beg, wchar_t* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ wchar_t lit01[52];
+ std::wcscpy(lit01, L"chicago underground trio/possible cube on delmark");
+ testbuf buf01;
+
+ // pbackfail
+ int i01 = 3;
+ buf01.pub_setg(lit01, lit01, (lit01 + i01));
+ VERIFY( i01 == buf01.in_avail() );
+ int_type intt01 = traits_type::to_int_type(L'b');
+ VERIFY( traits_type::eof() == buf01.pub_pbackfail(intt01) );
+
+ // overflow
+ VERIFY( traits_type::eof() == buf01.pub_overflow(intt01) );
+ VERIFY( traits_type::eof() == buf01.pub_overflow() );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[0]) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/2.cc
new file mode 100644
index 000000000..be1cb29fe
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/2.cc
@@ -0,0 +1,73 @@
+// 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 <streambuf>
+#include <ostream>
+#include <string>
+#include <testsuite_hooks.h>
+
+// test03
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html
+template<typename charT, typename traits = std::char_traits<charT> >
+ class basic_nullbuf : public std::basic_streambuf<charT, traits>
+ {
+ protected:
+ typedef typename
+ std::basic_streambuf<charT, traits>::int_type int_type;
+ virtual int_type
+ overflow(int_type c)
+ { return traits::not_eof(c); }
+ };
+
+typedef basic_nullbuf<wchar_t> nullbuf;
+
+template<typename T>
+ wchar_t
+ print(const T& x)
+ {
+ nullbuf ob;
+ std::wostream out(&ob);
+ out << x << std::endl;
+ return (!out ? L'0' : L'1');
+ }
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring control01(L"11111");
+ std::wstring test01;
+
+ test01 += print(true);
+ test01 += print(3.14159);
+ test01 += print(10);
+ test01 += print(L'x');
+ test01 += print(L"pipo");
+
+ VERIFY( test01 == control01 );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/3599.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/3599.cc
new file mode 100644
index 000000000..7ddca960d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/wchar_t/3599.cc
@@ -0,0 +1,60 @@
+// 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 <streambuf>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3599
+class testbuf : public std::wstreambuf
+{
+public:
+ typedef std::wstreambuf::traits_type traits_type;
+
+ testbuf() : std::wstreambuf() { }
+
+protected:
+ int_type
+ overflow(int_type c __attribute__((unused)) = traits_type::eof())
+ { return traits_type::not_eof(0); }
+};
+
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ testbuf ob;
+ std::wostream out(&ob);
+
+ out << L"gasp";
+ VERIFY( out.good() );
+
+ out << std::endl;
+ VERIFY( out.good() );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/base_classes.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/base_classes.cc
new file mode 100644
index 000000000..8c4fe079d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/base_classes.cc
@@ -0,0 +1,36 @@
+// 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.5.2 - Template class basic_streambuf
+// NB: This file is for testing basic_streambuf with NO OTHER INCLUDES.
+
+#include <streambuf>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// { dg-do compile }
+
+namespace std
+{
+ using __gnu_test::pod_char;
+ typedef short type_t;
+ template class basic_streambuf<type_t, char_traits<type_t> >;
+ template class basic_streambuf<pod_char, char_traits<pod_char> >;
+} // test
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/typedefs.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/typedefs.cc
new file mode 100644
index 000000000..fefed2913
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/requirements/typedefs.cc
@@ -0,0 +1,39 @@
+// 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.5.2 - Template class basic_streambuf
+// NB: This file is for testing basic_streambuf with NO OTHER INCLUDES.
+
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+// { dg-do compile }
+
+// libstdc++/7216
+void test01()
+{
+ // Check for required typedefs
+ typedef std::streambuf 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_streambuf/sgetc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc
new file mode 100644
index 000000000..cbf17820f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc
@@ -0,0 +1,113 @@
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::streambuf::traits_type traits_type;
+ typedef std::streambuf::char_type char_type;
+
+ testbuf(): std::streambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(char* beg, char* cur, char *end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(char* beg, char* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ char lit01[52];
+ std::strcpy(lit01, "chicago underground trio/possible cube on delmark");
+ testbuf buf01;
+
+ // 27.5.2.3.1 get area
+ // 27.5.2.2.3 get area
+ // 27.5.2.4.3 get area
+ int i01 = 3;
+ buf01.pub_setg(lit01, lit01, (lit01 + i01));
+ VERIFY( i01 == buf01.in_avail() );
+
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[0]) );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[1]) );
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[1]) );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[2]) );
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[2]) );
+ VERIFY( buf01.sgetc() == traits_type::eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc
new file mode 100644
index 000000000..0c5c63f33
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/wchar_t/1.cc
@@ -0,0 +1,112 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::wstreambuf::traits_type traits_type;
+ typedef std::wstreambuf::char_type char_type;
+
+ testbuf(): std::wstreambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(wchar_t* beg, wchar_t* cur, wchar_t* end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(wchar_t* beg, wchar_t* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ wchar_t lit01[52];
+ std::wcscpy(lit01, L"chicago underground trio/possible cube on delmark");
+ testbuf buf01;
+
+ // 27.5.2.3.1 get area
+ // 27.5.2.2.3 get area
+ // 27.5.2.4.3 get area
+ int i01 = 3;
+ buf01.pub_setg(lit01, lit01, (lit01 + i01));
+ VERIFY( i01 == buf01.in_avail() );
+
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[0]) );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[1]) );
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[1]) );
+ VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[2]) );
+ VERIFY( buf01.pub_uflow() == traits_type::to_int_type(lit01[2]) );
+ VERIFY( buf01.sgetc() == traits_type::eof() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc
new file mode 100644
index 000000000..d1530b18f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc
@@ -0,0 +1,123 @@
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::streambuf::traits_type traits_type;
+ typedef std::streambuf::char_type char_type;
+
+ testbuf(): std::streambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(char* beg, char* cur, char *end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(char* beg, char* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test02()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+
+ char lit01[] = "chicago underground trio/possible cube on delmark";
+ size_t i01 = traits_type::length(lit01);
+
+ testbuf buf01;
+
+ // 27.5.2.1 basic_streambuf ctors
+ // default ctor initializes
+ // - all pointer members to null pointers
+ // - locale to current global locale
+ VERIFY( buf01.check_pointers() );
+ VERIFY( buf01.getloc() == std::locale() );
+
+ // 27.5.2.2.5 Put area
+
+ char carray01[i01];
+ std::memset(carray01, 0, i01);
+
+ buf01.pub_setg(lit01, lit01, lit01 + i01);
+ buf01.sgetn(carray01, 0);
+ VERIFY( carray01[0] == 0 );
+ buf01.sgetn(carray01, 1);
+ VERIFY( carray01[0] == 'c' );
+ buf01.sgetn(carray01 + 1, i01 - 1);
+ VERIFY( carray01[0] == 'c' );
+ VERIFY( carray01[1] == 'h' );
+ VERIFY( carray01[i01 - 1] == 'k' );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/wchar_t/1.cc
new file mode 100644
index 000000000..66b4af5d3
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/wchar_t/1.cc
@@ -0,0 +1,122 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::wstreambuf::traits_type traits_type;
+ typedef std::wstreambuf::char_type char_type;
+
+ testbuf(): std::wstreambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(wchar_t* beg, wchar_t* cur, wchar_t* end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(wchar_t* beg, wchar_t* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test02()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+
+ wchar_t lit01[] = L"chicago underground trio/possible cube on delmark";
+ size_t i01 = traits_type::length(lit01);
+
+ testbuf buf01;
+
+ // 27.5.2.1 basic_streambuf ctors
+ // default ctor initializes
+ // - all pointer members to null pointers
+ // - locale to current global locale
+ VERIFY( buf01.check_pointers() );
+ VERIFY( buf01.getloc() == std::locale() );
+
+ // 27.5.2.2.5 Put area
+
+ wchar_t carray01[i01];
+ std::wmemset(carray01, 0, i01);
+
+ buf01.pub_setg(lit01, lit01, lit01 + i01);
+ buf01.sgetn(carray01, 0);
+ VERIFY( carray01[0] == 0 );
+ buf01.sgetn(carray01, 1);
+ VERIFY( carray01[0] == L'c' );
+ buf01.sgetn(carray01 + 1, i01 - 1);
+ VERIFY( carray01[0] == L'c' );
+ VERIFY( carray01[1] == L'h' );
+ VERIFY( carray01[i01 - 1] == L'k' );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/char/9538.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/char/9538.cc
new file mode 100644
index 000000000..bd632aba1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/char/9538.cc
@@ -0,0 +1,66 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 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.8.1.4 Overridden virtual functions
+
+#include <streambuf>
+#include <locale>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class MyTraits : public std::char_traits<char>
+{
+public:
+ static bool eq(char c1, char c2)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( c1 != 'X' );
+ VERIFY( c2 != 'X' );
+ return std::char_traits<char>::eq(c1, c2);
+ }
+};
+
+class MyBuf : public std::basic_streambuf<char, MyTraits>
+{
+ char buffer[8];
+
+public:
+ MyBuf()
+ {
+ std::memset(buffer, 'X', sizeof(buffer));
+ std::memset(buffer + 2, 'f', 4);
+ setg(buffer + 2, buffer + 2, buffer + 6);
+ }
+};
+
+// libstdc++/9538
+void test08()
+{
+ bool test __attribute__((unused)) = true;
+
+ MyBuf mb;
+ mb.sputbackc('a');
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/wchar_t/9538.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/wchar_t/9538.cc
new file mode 100644
index 000000000..f72f61778
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/wchar_t/9538.cc
@@ -0,0 +1,65 @@
+// 2001-05-21 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.8.1.4 Overridden virtual functions
+
+#include <streambuf>
+#include <locale>
+#include <cwchar>
+#include <testsuite_hooks.h>
+
+class MyTraits : public std::char_traits<wchar_t>
+{
+public:
+ static bool eq(wchar_t c1, wchar_t c2)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( c1 != L'X' );
+ VERIFY( c2 != L'X' );
+ return std::char_traits<wchar_t>::eq(c1, c2);
+ }
+};
+
+class MyBuf : public std::basic_streambuf<wchar_t, MyTraits>
+{
+ wchar_t buffer[8];
+
+public:
+ MyBuf()
+ {
+ std::wmemset(buffer, L'X', sizeof(buffer) / sizeof(buffer[0]));
+ std::wmemset(buffer + 2, L'f', 4);
+ setg(buffer + 2, buffer + 2, buffer + 6);
+ }
+};
+
+// libstdc++/9538
+void test08()
+{
+ bool test __attribute__((unused)) = true;
+
+ MyBuf mb;
+ mb.sputbackc(L'a');
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char/1057.cc
new file mode 100644
index 000000000..440d82b5a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/char/1057.cc
@@ -0,0 +1,53 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 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.5.2 template class basic_streambuf
+
+#include <string>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::streambuf
+{
+ char foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(0, 0);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::string text1 = "abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as sputc writes to null pointer
+ nsp.sputc('a');
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/wchar_t/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/wchar_t/1057.cc
new file mode 100644
index 000000000..5e7166fdd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputc/wchar_t/1057.cc
@@ -0,0 +1,53 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.5.2 template class basic_streambuf
+
+#include <string>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::wstreambuf
+{
+ wchar_t foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(0, 0);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::wstring text1 = L"abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as sputc writes to null pointer
+ nsp.sputc(L'a');
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc
new file mode 100644
index 000000000..2874b0eea
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc
@@ -0,0 +1,117 @@
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::streambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::streambuf::traits_type traits_type;
+ typedef std::streambuf::char_type char_type;
+
+ testbuf(): std::streambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(char* beg, char* cur, char *end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(char* beg, char* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ testbuf buf01;
+
+ // sputn/xsputn
+ char lit02[] = "isotope 217: the unstable molecule on thrill jockey";
+ const int i02 = std::strlen(lit02);
+
+ char carray[i02 + 1];
+ std::memset(carray, 0, i02 + 1);
+
+ buf01.pub_setp(carray, (carray + i02));
+ buf01.sputn(lit02, 0);
+ VERIFY( carray[0] == 0 );
+ VERIFY( lit02[0] == 'i' );
+ buf01.sputn(lit02, 1);
+ VERIFY( lit02[0] == carray[0] );
+ VERIFY( lit02[1] == 's' );
+ VERIFY( carray[1] == 0 );
+ buf01.sputn(lit02 + 1, 10);
+ VERIFY( std::memcmp(lit02, carray, 10) == 0 );
+ buf01.sputn(lit02 + 11, 20);
+ VERIFY( std::memcmp(lit02, carray, 30) == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1057.cc
new file mode 100644
index 000000000..dda78bde4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1057.cc
@@ -0,0 +1,53 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <string>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::streambuf
+{
+ char foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(0, 0);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::string text1 = "abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as xsputn writes to null pointer
+ nsp.sputn(text1.c_str(), text1.length());
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1.cc
new file mode 100644
index 000000000..09b263b6c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1.cc
@@ -0,0 +1,118 @@
+// 1999-10-11 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <cwchar>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+class testbuf : public std::wstreambuf
+{
+public:
+
+ // Typedefs:
+ typedef std::wstreambuf::traits_type traits_type;
+ typedef std::wstreambuf::char_type char_type;
+
+ testbuf(): std::wstreambuf()
+ { }
+
+ bool
+ check_pointers()
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( !this->eback() );
+ VERIFY( !this->gptr() );
+ VERIFY( !this->egptr() );
+ VERIFY( !this->pbase() );
+ VERIFY( !this->pptr() );
+ VERIFY( !this->epptr() );
+ return test;
+ }
+
+ int_type
+ pub_uflow()
+ { return (this->uflow()); }
+
+ int_type
+ pub_overflow(int_type __c = traits_type::eof())
+ { return (this->overflow(__c)); }
+
+ int_type
+ pub_pbackfail(int_type __c)
+ { return (this->pbackfail(__c)); }
+
+ void
+ pub_setg(wchar_t* beg, wchar_t* cur, wchar_t* end)
+ { this->setg(beg, cur, end); }
+
+ void
+ pub_setp(wchar_t* beg, wchar_t* end)
+ { this->setp(beg, end); }
+
+protected:
+ int_type
+ underflow()
+ {
+ int_type __retval = traits_type::eof();
+ if (this->gptr() < this->egptr())
+ __retval = traits_type::not_eof(0);
+ return __retval;
+ }
+};
+
+void test01()
+{
+ typedef testbuf::traits_type traits_type;
+ typedef testbuf::int_type int_type;
+
+ bool test __attribute__((unused)) = true;
+ testbuf buf01;
+
+ // sputn/xsputn
+ wchar_t lit02[] = L"isotope 217: the unstable molecule on thrill jockey";
+ const int i02 = std::wcslen(lit02);
+
+ wchar_t carray[i02 + 1];
+ std::wmemset(carray, 0, i02 + 1);
+
+ buf01.pub_setp(carray, (carray + i02));
+ buf01.sputn(lit02, 0);
+ VERIFY( carray[0] == 0 );
+ VERIFY( lit02[0] == L'i' );
+ buf01.sputn(lit02, 1);
+ VERIFY( lit02[0] == carray[0] );
+ VERIFY( lit02[1] == L's' );
+ VERIFY( carray[1] == 0 );
+ buf01.sputn(lit02 + 1, 10);
+ VERIFY( std::memcmp(lit02, carray, 10) == 0 );
+ buf01.sputn(lit02 + 11, 20);
+ VERIFY( std::memcmp(lit02, carray, 30) == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1057.cc
new file mode 100644
index 000000000..9b148bab9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/wchar_t/1057.cc
@@ -0,0 +1,53 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <string>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::wstreambuf
+{
+ wchar_t foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(0, 0);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::wstring text1 = L"abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as xsputn writes to null pointer
+ nsp.sputn(text1.c_str(), text1.length());
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/char/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/char/1057.cc
new file mode 100644
index 000000000..08fd18f02
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/char/1057.cc
@@ -0,0 +1,101 @@
+// 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 <streambuf>
+#include <string>
+#include <testsuite_hooks.h>
+
+class setpbuf : public std::streambuf
+{
+ char buffer[4];
+ std::string result;
+
+public:
+
+ std::string&
+ get_result()
+ { return result; }
+
+ setpbuf()
+ {
+ char foo [32];
+ setp(foo, foo + 32);
+ setp(buffer, buffer + 4);
+ }
+
+ ~setpbuf()
+ { sync(); }
+
+ virtual int_type
+ overflow(int_type n)
+ {
+ if (sync() != 0)
+ return traits_type::eof();
+
+ result += traits_type::to_char_type(n);
+
+ return n;
+ }
+
+ virtual int
+ sync()
+ {
+ result.append(pbase(), pptr());
+ setp(buffer, buffer + 4);
+ return 0;
+ }
+};
+
+// libstdc++/1057
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ std::string text = "abcdefghijklmn";
+
+ // 01
+ setpbuf sp1;
+ // Here xsputn writes over sp1.result
+ sp1.sputn(text.c_str(), text.length());
+
+ // This crashes when result is accessed
+ sp1.pubsync();
+ VERIFY( sp1.get_result() == text );
+
+ // 02
+ setpbuf sp2;
+ for (std::string::size_type i = 0; i < text.length(); ++i)
+ {
+ // sputc also writes over result
+ sp2.sputc(text[i]);
+ }
+
+ // Crash here
+ sp2.pubsync();
+ VERIFY( sp2.get_result() == text );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/wchar_t/1057.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/wchar_t/1057.cc
new file mode 100644
index 000000000..7da657528
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/sync/wchar_t/1057.cc
@@ -0,0 +1,101 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 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.5.2 template class basic_streambuf
+
+#include <streambuf>
+#include <string>
+#include <testsuite_hooks.h>
+
+class setpbuf : public std::wstreambuf
+{
+ wchar_t buffer[4];
+ std::wstring result;
+
+public:
+
+ std::wstring&
+ get_result()
+ { return result; }
+
+ setpbuf()
+ {
+ wchar_t foo[32];
+ setp(foo, foo + 32);
+ setp(buffer, buffer + 4);
+ }
+
+ ~setpbuf()
+ { sync(); }
+
+ virtual int_type
+ overflow(int_type n)
+ {
+ if (sync() != 0)
+ return traits_type::eof();
+
+ result += traits_type::to_char_type(n);
+
+ return n;
+ }
+
+ virtual int
+ sync()
+ {
+ result.append(pbase(), pptr());
+ setp(buffer, buffer + 4);
+ return 0;
+ }
+};
+
+// libstdc++/1057
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring text = L"abcdefghijklmn";
+
+ // 01
+ setpbuf sp1;
+ // Here xsputn writes over sp1.result
+ sp1.sputn(text.c_str(), text.length());
+
+ // This crashes when result is accessed
+ sp1.pubsync();
+ VERIFY( sp1.get_result() == text );
+
+ // 02
+ setpbuf sp2;
+ for (std::wstring::size_type i = 0; i < text.length(); ++i)
+ {
+ // sputc also writes over result
+ sp2.sputc(text[i]);
+ }
+
+ // Crash here
+ sp2.pubsync();
+ VERIFY( sp2.get_result() == text );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}