summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-06 00:19:17 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-06 00:19:17 +0000
commitf492015ba9d27841fae23b83d4680ec8317317ea (patch)
tree95ab9d1fe7fba981a5d40632ce9519386ff0060d /libstdc++-v3/testsuite
parent1c59174e3e4f29ceccb1df1d8de804bc6fc74bb8 (diff)
downloadgcc-f492015ba9d27841fae23b83d4680ec8317317ea.tar.gz
2003-06-05 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/9024 * include/bits/fstream.tcc (_M_underflow): Fix for unbuffered. * include/bits/stl_algobase.h: Tweak. * include/std/std_fstream.h: Move _M_buf_size to... * include/std/std_streambuf.h: ...here. Modify. * include/bits/streambuf.tcc: Same. * testsuite/testsuite_hooks.h: Tweak. * testsuite/testsuite_io.h (constraint_filebuf): New. * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2.cc: Split into... * testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Split into... * testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: New. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: New. * testsuite/data/sgetc.txt: New. * testsuite/data/sgetn.txt: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67524 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc79
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc92
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1.cc106
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc79
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc91
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc64
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc71
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc86
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc69
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1.cc107
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc71
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc85
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc83
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc96
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc79
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1.cc148
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc83
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc95
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc79
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/3.cc (renamed from libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2.cc)2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc84
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc83
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc66
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1.cc116
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc82
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc81
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc71
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1.cc124
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc66
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc71
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2.cc129
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc69
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc65
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1.cc112
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc64
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc68
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc66
-rw-r--r--libstdc++-v3/testsuite/data/sgetc.txt3
-rw-r--r--libstdc++-v3/testsuite/data/sgetn.txt158
-rw-r--r--libstdc++-v3/testsuite/testsuite_hooks.h2
-rw-r--r--libstdc++-v3/testsuite/testsuite_io.h79
48 files changed, 2949 insertions, 843 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc
new file mode 100644
index 00000000000..e03da5f2064
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc
@@ -0,0 +1,79 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+
+ int_type c1 = fb_01.sbumpc();
+ VERIFY( c1 == '/' );
+ int_type c3 = fb_01.sbumpc();
+ VERIFY( c3 == '/' );
+
+ c1 = fb_01.sgetc();
+ int_type c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == ' ' );
+ VERIFY( c3 == '9' );
+ VERIFY( c1 == c2 );
+ VERIFY( c2 != c3 );
+
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '9' );
+ VERIFY( c2 == '9' );
+ VERIFY( c3 == '0' );
+
+ VERIFY( !fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
new file mode 100644
index 00000000000..9098a2083e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
@@ -0,0 +1,92 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_03[] = "tmp_sbumpc_1io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ int_type c5 = fb_03.sbumpc();
+ VERIFY( c5 == traits_type::eof() );
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.write_position() );
+
+ int_type c1 = fb_01.sbumpc();
+ VERIFY( c1 == '/' );
+ int_type c3 = fb_01.sbumpc();
+ VERIFY( c3 == '/' );
+
+ c1 = fb_01.sgetc();
+ int_type c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == ' ' );
+ VERIFY( c3 == '9' );
+ VERIFY( c1 == c2 );
+ VERIFY( c2 != c3 );
+
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '9' );
+ VERIFY( c2 == '9' );
+ VERIFY( c3 == '0' );
+
+ VERIFY( fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
new file mode 100644
index 00000000000..ff0cb97dd5d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
@@ -0,0 +1,63 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sbumpc_1out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ int_type c2 = fb_02.sbumpc();
+ VERIFY( c2 == traits_type::eof() );
+ int_type c4 = fb_02.sbumpc();
+ VERIFY( c4 == traits_type::eof() );
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1.cc
deleted file mode 100644
index d2c7ccd53b4..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- using namespace std;
- typedef filebuf::int_type int_type;
- typedef filebuf::traits_type traits_type;
- typedef filebuf::pos_type pos_type;
- typedef filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- filebuf f_tmp;
- streamsize strmsz_1, strmsz_2;
- streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- // GET
- fb_01.open(name_01, ios_base::in);
- fb_02.open(name_02, ios_base::out | ios_base::trunc);
- fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
- strmof_1 = fb_01.in_avail();
- strmof_2 = fb_02.in_avail();
- strmof_1 = fb_03.in_avail();
-
- // int_type sbumpc()
- // if read_cur not avail returns uflow(), else return *read_cur & increment
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- VERIFY( c1 != c2 );
- VERIFY( c1 == '/' );
- VERIFY( c2 == -1 );
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- VERIFY( c3 != c4 );
- VERIFY( c1 == c3 ); // fluke, both happen to be '/'
- VERIFY( c2 == c4 );
- int_type c5 = fb_03.sbumpc();
- VERIFY( c5 == traits_type::eof() );
- // XXX should do some kind of test to make sure that internal
- // buffers point to the same thing, to check consistancy.
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc
new file mode 100644
index 00000000000..d0f256ee10c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc
@@ -0,0 +1,79 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+
+ int_type c1 = fb_01.sbumpc();
+ VERIFY( c1 == '/' );
+ int_type c3 = fb_01.sbumpc();
+ VERIFY( c3 == '/' );
+
+ c1 = fb_01.sgetc();
+ int_type c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == ' ' );
+ VERIFY( c3 == '9' );
+ VERIFY( c1 == c2 );
+ VERIFY( c2 != c3 );
+
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '9' );
+ VERIFY( c2 == '9' );
+ VERIFY( c3 == '0' );
+
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc
new file mode 100644
index 00000000000..ef1f28f786e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc
@@ -0,0 +1,91 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_03[] = "tmp_sbumpc_2io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.unbuffered() );
+ int_type c5 = fb_03.sbumpc();
+ VERIFY( c5 == traits_type::eof() );
+ VERIFY( fb_03.unbuffered() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.unbuffered() );
+
+ int_type c1 = fb_01.sbumpc();
+ VERIFY( c1 == '/' );
+ int_type c3 = fb_01.sbumpc();
+ VERIFY( c3 == '/' );
+
+ c1 = fb_01.sgetc();
+ int_type c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == ' ' );
+ VERIFY( c3 == '9' );
+ VERIFY( c1 == c2 );
+ VERIFY( c2 != c3 );
+
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sbumpc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '9' );
+ VERIFY( c2 == '9' );
+ VERIFY( c3 == '0' );
+
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc
new file mode 100644
index 00000000000..1d8df086bcc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc
@@ -0,0 +1,64 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sbumpc_2out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ // int_type sbumpc()
+ // if read_cur not avail returns uflow(), else return *read_cur & increment
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ int_type c2 = fb_02.sbumpc();
+ VERIFY( c2 == traits_type::eof() );
+ int_type c4 = fb_02.sbumpc();
+ VERIFY( c4 == traits_type::eof() );
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc
new file mode 100644
index 00000000000..7ae7cdccee4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc
@@ -0,0 +1,71 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // in
+ {
+ constraint_filebuf fb_01; // in
+ fb_01.open(name_01, ios::in);
+ VERIFY( !fb_01.write_position() );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ c2 = fb_01.sgetc();
+ VERIFY( c1 == c2 );
+ fb_01.sbumpc();
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sgetc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ VERIFY( c2 == ' ' );
+ VERIFY( c3 == ' ' );
+ VERIFY( !fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
new file mode 100644
index 00000000000..6882234f1d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
@@ -0,0 +1,86 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_03[] = "tmp_sgetc_1io.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03; // in | out
+ fb_03.open(name_03, ios::out | ios::in | ios::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ c1 = fb_03.sgetc();
+ c2 = fb_03.sbumpc();
+ VERIFY( c1 == traits_type::eof() );
+ VERIFY( c1 == c2 );
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01; // in
+ fb_01.open(name_01, ios::in | ios::out);
+ VERIFY( fb_01.write_position() );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ c2 = fb_01.sgetc();
+ VERIFY( c1 == c2 );
+ fb_01.sbumpc();
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sgetc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ VERIFY( c2 == ' ' );
+ VERIFY( c3 == ' ' );
+ VERIFY( fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
new file mode 100644
index 00000000000..30d4d1b5e40
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
@@ -0,0 +1,69 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sgetc_1out.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // out
+ {
+ constraint_filebuf fb_02; // out
+ fb_02.open(name_02, ios::out | ios::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ c1 = fb_02.sgetc();
+ VERIFY( c1 == traits_type::eof() );
+ c2 = fb_02.sgetc();
+ VERIFY( c2 == traits_type::eof() );
+ fb_02.sbumpc();
+ c1 = fb_02.sbumpc();
+ c2 = fb_02.sgetc();
+ VERIFY( c1 == c2 );
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1.cc
deleted file mode 100644
index 37573c8edfd..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- typedef std::filebuf::int_type int_type;
- typedef std::filebuf::traits_type traits_type;
- typedef std::filebuf::pos_type pos_type;
- typedef std::filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- std::filebuf f_tmp;
- std::streamsize strmsz_1, strmsz_2;
- std::streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- // GET
- fb_01.open(name_01, std::ios_base::in);
- fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
- fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
- strmof_1 = fb_01.in_avail();
- strmof_2 = fb_02.in_avail();
- strmof_1 = fb_03.in_avail();
-
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c5 = fb_03.sbumpc();
-
- // int_type sgetc()
- // if read_cur not avail, return uflow(), else return *read_cur
- int_type c6 = fb_01.sgetc();
- int_type c7 = fb_02.sgetc();
- VERIFY( c6 != c3 );
- VERIFY( c7 == c4 ); // both -1
- int_type c8 = fb_01.sgetc();
- int_type c9 = fb_02.sgetc();
- VERIFY( c6 == c8 );
- VERIFY( c7 == c9 );
- c5 = fb_03.sgetc();
- VERIFY( c5 == traits_type::eof() );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc
new file mode 100644
index 00000000000..979a3fd3845
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc
@@ -0,0 +1,71 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // in
+ {
+ constraint_filebuf fb_01; // in
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios::in);
+ VERIFY( fb_01.unbuffered() );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ c2 = fb_01.sgetc();
+ VERIFY( c1 == c2 );
+ fb_01.sbumpc();
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sgetc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ VERIFY( c2 == ' ' );
+ VERIFY( c3 == ' ' );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc
new file mode 100644
index 00000000000..e12ef3455cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc
@@ -0,0 +1,85 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_03[] = "tmp_sgetc_2io.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03; // in | out
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios::out | ios::in | ios::trunc);
+ VERIFY( fb_03.unbuffered() );
+ c1 = fb_03.sgetc();
+ c2 = fb_03.sbumpc();
+ VERIFY( c1 == traits_type::eof() );
+ VERIFY( c1 == c2 );
+ VERIFY( fb_03.unbuffered() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01; // in
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios::in | ios::out);
+ VERIFY( fb_01.unbuffered() );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ c2 = fb_01.sgetc();
+ VERIFY( c1 == c2 );
+ fb_01.sbumpc();
+ c1 = fb_01.sbumpc();
+ c2 = fb_01.sgetc();
+ c3 = fb_01.sgetc();
+ VERIFY( c1 == '/' );
+ VERIFY( c2 == ' ' );
+ VERIFY( c3 == ' ' );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc
new file mode 100644
index 00000000000..491c028c281
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc
@@ -0,0 +1,70 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sgetc_2out.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef std::filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+
+ // out
+ {
+ constraint_filebuf fb_02; // out
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios::out | ios::trunc);
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ c1 = fb_02.sgetc();
+ VERIFY( c1 == traits_type::eof() );
+ c2 = fb_02.sgetc();
+ VERIFY( c2 == traits_type::eof() );
+ fb_02.sbumpc();
+ c1 = fb_02.sbumpc();
+ c2 = fb_02.sgetc();
+ VERIFY( c1 == c2 );
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc
new file mode 100644
index 00000000000..021a1c89d68
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc
@@ -0,0 +1,83 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetn.txt"; // file with data in it
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+ strmsz_1 = fb_01.in_avail(); // 8261
+ strmsz_2 = fb_01.sgetn(carray1, 10);
+ VERIFY( strmsz_2 == 10 );
+ strmsz_2 = fb_01.in_avail();
+ VERIFY( strmsz_1 > strmsz_2 );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == 'b' );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == strmsz_2 - 5 );
+ c4 = fb_01.sgetc(); // buffer should have underflowed from above.
+ VERIFY( c4 == 'h' );
+ strmsz_1 = fb_01.in_avail();
+ VERIFY( strmsz_1 > 0 );
+ strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
+ VERIFY( !fb_01.write_position() );
+ VERIFY( !fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
new file mode 100644
index 00000000000..432ed6cdab5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
@@ -0,0 +1,96 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetn.txt"; // file with data in it
+const char name_03[] = "tmp_sgetn_1io.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ strmsz_1 = fb_03.sgetn(carray1, 10);
+ VERIFY( strmsz_1 == 0 );
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.write_position() );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray1, 10);
+ VERIFY( strmsz_2 == 10 );
+ strmsz_2 = fb_01.in_avail();
+ VERIFY( strmsz_1 > strmsz_2 );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == 'b' );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == strmsz_2 - 5 );
+ c4 = fb_01.sgetc(); // buffer should have underflowed from above.
+ VERIFY( c4 == 'h' );
+ strmsz_1 = fb_01.in_avail();
+ VERIFY( strmsz_1 > 0 );
+ strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
+ VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
new file mode 100644
index 00000000000..dcefe01c6a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
@@ -0,0 +1,79 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sgetn_1out.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ strmsz_2 = fb_02.in_avail();
+ strmsz_2 = fb_02.sgetn(carray2, 10);
+ VERIFY( strmsz_2 == 0 );
+ c2 = fb_02.sgetc();
+ VERIFY( c2 == traits_type::eof() );
+ strmsz_1 = fb_02.in_avail();
+ strmsz_2 = fb_02.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == -1 );
+ VERIFY( strmsz_2 == 0 );
+ c4 = fb_02.sgetc();
+ VERIFY( c4 == traits_type::eof() );
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1.cc
deleted file mode 100644
index d890f3e7dcf..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1.cc
+++ /dev/null
@@ -1,148 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- using namespace std;
- typedef filebuf::int_type int_type;
- typedef filebuf::traits_type traits_type;
- typedef filebuf::pos_type pos_type;
- typedef filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- filebuf f_tmp;
- streamsize strmsz_1, strmsz_2;
- streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- // GET
- fb_01.open(name_01, ios_base::in);
- fb_02.open(name_02, ios_base::out | ios_base::trunc);
- fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
-
- strmof_1 = fb_01.in_avail();
- int_type c1 = fb_01.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c6 = fb_01.sgetc();
- int_type c8 = fb_01.sgetc();
-
- strmof_2 = fb_02.in_avail();
- int_type c2 = fb_02.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c7 = fb_02.sgetc();
- int_type c9 = fb_02.sgetc();
-
- strmof_1 = fb_03.in_avail();
- int_type c5 = fb_03.sbumpc();
- c5 = fb_03.sgetc();
-
- // int_type snextc()
- // calls sbumpc and if sbumpc != eof, return sgetc
- c6 = fb_01.snextc();
- c6 = fb_01.snextc();
-
- c7 = fb_02.snextc();
- c7 = fb_02.snextc();
-
- c5 = fb_03.snextc();
-
- // streamsize sgetn(char_type *s, streamsize n)
- // streamsize xsgetn(char_type *s, streamsize n)
- // assign up to n chars to s from input sequence, indexing in_cur as
- // approp and returning the number of chars assigned
- strmsz_1 = fb_01.in_avail();
- strmsz_2 = fb_02.in_avail();
- test = strmsz_1 != strmsz_2;
- char carray1[13] = "";
- strmsz_1 = fb_01.sgetn(carray1, 10);
- char carray2[buffer_size] = "";
- strmsz_2 = fb_02.sgetn(carray2, 10);
- VERIFY( strmsz_1 != strmsz_2 );
- VERIFY( strmsz_1 == 10 );
- VERIFY( strmsz_2 == 0 );
- c1 = fb_01.sgetc();
- c2 = fb_02.sgetc();
- VERIFY( c1 == '\n' );
- VERIFY( c7 == c2 ); // n != i
- strmsz_1 = fb_03.sgetn(carray1, 10);
- VERIFY( !strmsz_1 ); //zero
- strmsz_1 = fb_01.in_avail(); // N.B.: _M_in_end - _M_in_beg == BUFSIZ - 1
- strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
- VERIFY( strmsz_1 == strmsz_2 - 5 );
- c4 = fb_01.sgetc(); // buffer should have underflowed from above.
- VERIFY( c4 == 'h' );
- strmsz_1 = fb_01.in_avail();
- VERIFY( strmsz_1 > 0 );
- strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
- VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
- strmsz_1 = fb_02.in_avail();
- strmsz_2 = fb_02.sgetn(carray2, strmsz_1 + 5);
- VERIFY( strmsz_1 == -1 );
- VERIFY( strmsz_2 == 0 );
- c4 = fb_02.sgetc(); // should be EOF
- VERIFY( c4 == traits_type::eof() );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc
new file mode 100644
index 00000000000..62c5a0f93f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc
@@ -0,0 +1,83 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetn.txt"; // file with data in it
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray1, 10);
+ VERIFY( strmsz_2 == 10 );
+ strmsz_2 = fb_01.in_avail();
+ VERIFY( strmsz_1 > strmsz_2 );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == 'b' );
+ strmsz_1 = fb_01.in_avail(); // 8181 or 8250 depending on buffer
+ strmsz_2 = fb_01.sgetn(carray2, 8181 + 5);
+ VERIFY( 8181 == strmsz_2 - 5 );
+ c4 = fb_01.sgetc(); // buffer should have underflowed from above.
+ VERIFY( c4 == 'h' );
+ strmsz_1 = fb_01.in_avail();
+ VERIFY( strmsz_1 > 0 );
+ strmsz_2 = fb_01.sgetn(carray2, 65 + 5);
+ VERIFY( 65 == strmsz_2 ); // at the end of the actual file
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc
new file mode 100644
index 00000000000..30ccee29f2e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc
@@ -0,0 +1,95 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetn.txt"; // file with data in it
+const char name_03[] = "tmp_sgetn_2io.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.unbuffered() );
+ strmsz_1 = fb_03.sgetn(carray1, 10);
+ VERIFY( strmsz_1 == 0 );
+ VERIFY( fb_03.unbuffered() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.unbuffered() );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray1, 10);
+ VERIFY( strmsz_2 == 10 );
+ strmsz_2 = fb_01.in_avail();
+ VERIFY( strmsz_1 > strmsz_2 );
+ c1 = fb_01.sgetc();
+ VERIFY( c1 == 'b' );
+ strmsz_1 = fb_01.in_avail();
+ strmsz_2 = fb_01.sgetn(carray2, 8181 + 5);
+ VERIFY( 8181 == strmsz_2 - 5 );
+ c4 = fb_01.sgetc(); // buffer should have underflowed from above.
+ VERIFY( c4 == 'h' );
+ strmsz_1 = fb_01.in_avail();
+ VERIFY( strmsz_1 > 0 );
+ strmsz_2 = fb_01.sgetn(carray2, 65 + 5);
+ VERIFY( 65 == strmsz_2 ); //at the end of the actual file
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc
new file mode 100644
index 00000000000..99a907493d4
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc
@@ -0,0 +1,79 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sgetn_2out.tst"; // empty file, need to create
+
+// Test overloaded virtual functions.
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+
+ streamsize strmsz_1, strmsz_2, strmsz_3;
+ int i = 0, j = 0, k = 0;
+ char carray1[13] = "";
+ char carray2[8192] = "";
+ int_type c1, c2, c3, c4;
+
+ // streamsize sgetn(char_type *s, streamsize n)
+ // streamsize xsgetn(char_type *s, streamsize n)
+ // assign up to n chars to s from input sequence, indexing in_cur as
+ // approp and returning the number of chars assigned
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ strmsz_2 = fb_02.in_avail();
+ strmsz_2 = fb_02.sgetn(carray2, 10);
+ VERIFY( strmsz_2 == 0 );
+ c2 = fb_02.sgetc();
+ VERIFY( c2 == traits_type::eof() );
+ strmsz_1 = fb_02.in_avail();
+ strmsz_2 = fb_02.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == -1 );
+ VERIFY( strmsz_2 == 0 );
+ c4 = fb_02.sgetc();
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/3.cc
index 6ed16712b88..d3e41805938 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/3.cc
@@ -23,7 +23,7 @@
#include <fstream>
#include <testsuite_hooks.h>
-const char name_01[] = "filebuf_virtuals-1.tst"; // empty file, need to create
+const char name_01[] = "sgetn.txt";
void test06()
{
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc
new file mode 100644
index 00000000000..437a7fb6535
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-in.cc
@@ -0,0 +1,84 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_02[] = "tmp_snextc_1out.tst"; // empty file, need to create
+const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '/' );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == ' ' );
+ VERIFY( !fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+ int_type c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == ' ' );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '9' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == '9' );
+ VERIFY( !fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
new file mode 100644
index 00000000000..0627648cc7b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
@@ -0,0 +1,83 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_02[] = "tmp_snextc_1out.tst"; // empty file, need to create
+const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ c3 = fb_03.snextc();
+ VERIFY( c3 == traits_type::eof() );
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.write_position() );
+ int_type c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == ' ' );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '9' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == '9' );
+ VERIFY( fb_01.write_position() );
+ VERIFY( fb_01.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
new file mode 100644
index 00000000000..d226ac29699
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
@@ -0,0 +1,66 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_02[] = "tmp_snextc_1out.tst"; // empty file, need to create
+const char name_03[] = "tmp_snextc_1io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ c2 = fb_02.snextc();
+ VERIFY( c2 == traits_type::eof() );
+ c2 = fb_02.snextc();
+ VERIFY( c2 == traits_type::eof() );
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1.cc
deleted file mode 100644
index fb205bd701f..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- using namespace std;
- typedef filebuf::int_type int_type;
- typedef filebuf::traits_type traits_type;
- typedef filebuf::pos_type pos_type;
- typedef filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- filebuf f_tmp;
- streamsize strmsz_1, strmsz_2;
- streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- // GET
- fb_01.open(name_01, ios_base::in);
- fb_02.open(name_02, ios_base::out | ios_base::trunc);
- fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
- strmof_1 = fb_01.in_avail();
- strmof_2 = fb_02.in_avail();
- strmof_1 = fb_03.in_avail();
-
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c5 = fb_03.sbumpc();
-
- int_type c6 = fb_01.sgetc();
- int_type c7 = fb_02.sgetc();
- int_type c8 = fb_01.sgetc();
- int_type c9 = fb_02.sgetc();
- c5 = fb_03.sgetc();
-
- // int_type snextc()
- // calls sbumpc and if sbumpc != eof, return sgetc
- c6 = fb_01.snextc();
- c7 = fb_02.snextc();
- VERIFY( c6 != c8 );
- VERIFY( c7 == c9 ); // -1
- VERIFY( c6 == '\n' );
- c6 = fb_01.snextc();
- c7 = fb_02.snextc();
- VERIFY( c6 != c8 );
- VERIFY( c7 == c9 ); // -1
- VERIFY( c6 == '9' );
- c5 = fb_03.snextc();
- VERIFY( c5 == traits_type::eof() );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc
new file mode 100644
index 00000000000..8c563ad41e8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-in.cc
@@ -0,0 +1,82 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '/' ); // overflow
+ c1 = fb_01.snextc();
+ VERIFY( c1 == ' ' );
+ VERIFY( fb_01.unbuffered() );
+ }
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+ int_type c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == ' ' );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '9' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == '9' );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc
new file mode 100644
index 00000000000..a044c6d4f41
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-io.cc
@@ -0,0 +1,81 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "sgetc.txt"; // file with data in it
+const char name_03[] = "tmp_snextc_2io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.unbuffered() );
+ c3 = fb_03.snextc();
+ VERIFY( c3 == traits_type::eof() );
+ VERIFY( fb_03.unbuffered() );
+ }
+
+ // in | out 2
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in | ios_base::out);
+ VERIFY( fb_01.unbuffered() );
+ int_type c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sbumpc();
+ VERIFY( c4 == '/' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == ' ' );
+ c1 = fb_01.snextc();
+ VERIFY( c1 == '9' );
+ c4 = fb_01.sgetc();
+ VERIFY( c4 == '9' );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc
new file mode 100644
index 00000000000..8af126337f6
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/2-out.cc
@@ -0,0 +1,63 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_snextc_2out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ int_type c1, c2, c3;
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.unbuffered() );
+ c2 = fb_02.snextc();
+ VERIFY( c2 == traits_type::eof() );
+ c2 = fb_02.snextc();
+ VERIFY( c2 == traits_type::eof() );
+ VERIFY( fb_02.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc
new file mode 100644
index 00000000000..25d9ee0ce8d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-in.cc
@@ -0,0 +1,65 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+ c3 = fb_01.sputc('a');
+ VERIFY( c3 == traits_type::eof() );
+ VERIFY( !fb_01.write_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
new file mode 100644
index 00000000000..c1717612b6c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
@@ -0,0 +1,72 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+const char name_03[] = "tmp_sputc_1io.tst";
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ c1 = fb_03.sputc('b');
+ VERIFY( c1 == 'b' );
+ c2 = fb_03.sputc('d');
+ VERIFY( c2 == 'd' );
+ for (int i = 50; i <= 90; ++i)
+ c2 = fb_03.sputc(char(i));
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
new file mode 100644
index 00000000000..987b4e26217
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
@@ -0,0 +1,71 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sputc_1out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ c1 = fb_02.sputc('a');
+ VERIFY( c1 == 'a' );
+ c2 = fb_02.sputc('c');
+ VERIFY( c2 == 'c' );
+ for (int i = 50; i <= 90; ++i)
+ c2 = fb_02.sputc(char(i));
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1.cc
deleted file mode 100644
index b02c70fb49a..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- typedef std::filebuf::int_type int_type;
- typedef std::filebuf::traits_type traits_type;
- typedef std::filebuf::pos_type pos_type;
- typedef std::filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- std::filebuf f_tmp;
- std::streamsize strmsz_1, strmsz_2;
- std::streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- fb_01.open(name_01, std::ios_base::in);
- fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
- fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
-
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c5 = fb_03.sbumpc();
- int_type c6 = fb_01.sgetc();
- int_type c7 = fb_02.sgetc();
- int_type c8 = fb_01.sgetc();
- int_type c9 = fb_02.sgetc();
-
- // PUT
- // int_type sputc(char_type c)
- // if out_cur not avail, return overflow(traits_type::to_int_type(c))
- // else, stores c at out_cur,
- // increments out_cur, and returns c as int_type
- // strmsz_1 = fb_03.in_avail(); // XXX valid for in|out??
- c1 = fb_02.sputc('a');
- c2 = fb_03.sputc('b');
- VERIFY( c1 != c2 );
- c1 = fb_02.sputc('c');
- c2 = fb_03.sputc('d');
- VERIFY( c1 != c2 );
- // strmsz_2 = fb_03.in_avail();
- // VERIFY( strmsz_1 != strmsz_2 );
- for (int i = 50; i <= 90; ++i)
- c2 = fb_02.sputc(char(i));
- // 27filebuf-2.txt == ac23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
- // fb_02._M_out_cur = '2'
- strmsz_1 = fb_03.in_avail();
- for (int i = 50; i <= 90; ++i)
- c2 = fb_03.sputc(char(i));
- strmsz_2 = fb_03.in_avail();
- // VERIFY( strmsz_1 != strmsz_2 );
- // VERIFY( strmsz_1 > 0 );
- // VERIFY( strmsz_2 > 0 );
- // 27filebuf-2.txt == bd23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
- // fb_02._M_out_cur = '2'
- c3 = fb_01.sputc('a'); // should be EOF because this is read-only
- VERIFY( c3 == traits_type::eof() );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc
new file mode 100644
index 00000000000..85ab4efbeff
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-in.cc
@@ -0,0 +1,66 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+ c3 = fb_01.sputc('a');
+ VERIFY( c3 == traits_type::eof() );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc
new file mode 100644
index 00000000000..373a6a8cba5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-io.cc
@@ -0,0 +1,71 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+const char name_03[] = "tmp_sputc_2io.tst";
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // in | out 1
+ {
+ constraint_filebuf fb_03;
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.unbuffered() );
+ c1 = fb_03.sputc('b');
+ VERIFY( c1 == 'b' );
+ c2 = fb_03.sputc('d');
+ VERIFY( c2 == 'd' );
+ for (int i = 50; i <= 90; ++i)
+ c2 = fb_03.sputc(char(i));
+ VERIFY( fb_03.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc
new file mode 100644
index 00000000000..96e12954a97
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2-out.cc
@@ -0,0 +1,72 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sputc_2out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+ int i = 0, j = 0, k = 0;
+ int_type c1, c2, c3;
+
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow(traits_type::to_int_type(c))
+ // else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ c1 = fb_02.sputc('a');
+ VERIFY( c1 == 'a' );
+ c2 = fb_02.sputc('c');
+ VERIFY( c2 == 'c' );
+ for (int i = 50; i <= 90; ++i)
+ c2 = fb_02.sputc(char(i));
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2.cc
deleted file mode 100644
index f6a4ae8b0db..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/2.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// 2003-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- typedef std::filebuf::int_type int_type;
- typedef std::filebuf::traits_type traits_type;
- typedef std::filebuf::pos_type pos_type;
- typedef std::filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- std::filebuf f_tmp;
- std::streamsize strmsz_1, strmsz_2;
- std::streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- // Unbuffered
- fb_01.pubsetbuf(0, 0);
- fb_02.pubsetbuf(0, 0);
- fb_03.pubsetbuf(0, 0);
-
- fb_01.open(name_01, std::ios_base::in);
- fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
- fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
-
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c5 = fb_03.sbumpc();
- int_type c6 = fb_01.sgetc();
- int_type c7 = fb_02.sgetc();
- int_type c8 = fb_01.sgetc();
- int_type c9 = fb_02.sgetc();
-
- // PUT
- // int_type sputc(char_type c)
- // if out_cur not avail, return overflow(traits_type::to_int_type(c))
- // else, stores c at out_cur,
- // increments out_cur, and returns c as int_type
- // strmsz_1 = fb_03.in_avail(); // XXX valid for in|out??
- c1 = fb_02.sputc('a');
- c2 = fb_03.sputc('b');
- VERIFY( c1 != c2 );
- c1 = fb_02.sputc('c');
- c2 = fb_03.sputc('d');
- VERIFY( c1 != c2 );
- // strmsz_2 = fb_03.in_avail();
- // VERIFY( strmsz_1 != strmsz_2 );
- for (int i = 50; i <= 90; ++i)
- c2 = fb_02.sputc(char(i));
- // 27filebuf-2.txt == ac23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
- // fb_02._M_out_cur = '2'
- strmsz_1 = fb_03.in_avail();
- for (int i = 50; i <= 90; ++i)
- c2 = fb_03.sputc(char(i));
- strmsz_2 = fb_03.in_avail();
- // VERIFY( strmsz_1 != strmsz_2 );
- // VERIFY( strmsz_1 > 0 );
- // VERIFY( strmsz_2 > 0 );
- // 27filebuf-2.txt == bd23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
- // fb_02._M_out_cur = '2'
- c3 = fb_01.sputc('a'); // should be EOF because this is read-only
- VERIFY( c3 == traits_type::eof() );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc
new file mode 100644
index 00000000000..235fce07e22
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-in.cc
@@ -0,0 +1,63 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( !fb_01.write_position() );
+ strmsz_1 = fb_01.sputn("racadabra", 10);
+ VERIFY( strmsz_1 == 0 );
+ VERIFY( !fb_01.write_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
new file mode 100644
index 00000000000..37509601427
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
@@ -0,0 +1,69 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+const char name_03[] = "tmp_sputn_1io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // in | out
+ {
+ constraint_filebuf fb_03;
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
+ VERIFY( strmsz_1 == 10 );
+ strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
+ VERIFY( strmsz_2 == 10 );
+ VERIFY( strmsz_1 == strmsz_2 );
+ VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
new file mode 100644
index 00000000000..647f310d87f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
@@ -0,0 +1,65 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sputn_1out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ strmsz_1 = fb_02.sputn("racadabras", 10);
+ VERIFY( strmsz_1 == 10 );
+ VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1.cc
deleted file mode 100644
index 151ae42d66f..00000000000
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// 27.8.1.4 Overridden virtual functions
-
-#include <fstream>
-#include <testsuite_hooks.h>
-
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %*.txt
-
-// NB: This test assumes that _M_buf_size == 40, and not the usual
-// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
-// simulated a bit more readily.
-// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
-const int buffer_size = 8192;
-//const int buffer_size = 40;
-
-const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
-const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
-const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
-
-class derived_filebuf: public std::filebuf
-{
- public:
- void
- set_size(int_type __size) { _M_buf_size = __size; }
-};
-
-derived_filebuf fb_01; // in
-derived_filebuf fb_02; // out
-derived_filebuf fb_03; // in | out
-
-// Initialize filebufs to be the same size regardless of platform.
-void test03()
-{
- fb_01.set_size(buffer_size);
- fb_02.set_size(buffer_size);
- fb_03.set_size(buffer_size);
-}
-
-// Test overloaded virtual functions.
-void test05()
-{
- typedef std::filebuf::int_type int_type;
- typedef std::filebuf::traits_type traits_type;
- typedef std::filebuf::pos_type pos_type;
- typedef std::filebuf::off_type off_type;
- typedef size_t size_type;
-
- bool test = true;
- std::filebuf f_tmp;
- std::streamsize strmsz_1, strmsz_2;
- std::streamoff strmof_1, strmof_2;
- int i = 0, j = 0, k = 0;
-
- fb_01.open(name_01, std::ios_base::in);
- fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
- fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
-
- int_type c1 = fb_01.sbumpc();
- int_type c2 = fb_02.sbumpc();
- int_type c3 = fb_01.sbumpc();
- int_type c4 = fb_02.sbumpc();
- int_type c5 = fb_03.sbumpc();
- int_type c6 = fb_01.sgetc();
- int_type c7 = fb_02.sgetc();
- int_type c8 = fb_01.sgetc();
- int_type c9 = fb_02.sgetc();
-
- // PUT
- // streamsize sputn(const char_typs* s, streamsize n)
- // write up to n chars to out_cur from s, returning number assigned
- // NB *sputn will happily put '\0' into your stream if you give it a chance*
- strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
- VERIFY( strmsz_1 == 10 );
- strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
- VERIFY( strmsz_2 == 10 );
- VERIFY( strmsz_1 == strmsz_2 );
- // fb_03._M_out_beg = "YZracadabras, i wanna FGHIJKLMNOPQRSTUVW"
- // fb_03._M_out_cur = "FGHIJKLMNOPQRSTUVW"
- strmsz_1 = fb_02.sputn("racadabras", 10);
- VERIFY( strmsz_1 == 10 );
- // fb_02._M_out_beg = "YZracadabras<=>?@ABCDEFGHIJKLMNOPQRSTUVW"
- // fb_02._M_out_cur = "<=>?@ABCDEFGHIJKLMNOPQRSTUVW"
- strmsz_1 = fb_01.sputn("racadabra", 10);
- VERIFY( strmsz_1 == 0 );
-}
-
-main()
-{
- test03();
- test05();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc
new file mode 100644
index 00000000000..8972b5efcb8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-in.cc
@@ -0,0 +1,64 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // in
+ {
+ constraint_filebuf fb_01;
+ fb_01.pubsetbuf(0, 0);
+ fb_01.open(name_01, ios_base::in);
+ VERIFY( fb_01.unbuffered() );
+ strmsz_1 = fb_01.sputn("racadabra", 10);
+ VERIFY( strmsz_1 == 0 );
+ VERIFY( fb_01.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc
new file mode 100644
index 00000000000..c6109c2f100
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-io.cc
@@ -0,0 +1,68 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
+const char name_03[] = "tmp_sputn_2io.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // in | out
+ {
+ constraint_filebuf fb_03;
+ fb_03.pubsetbuf(0, 0);
+ fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
+ VERIFY( fb_03.unbuffered() );
+ strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
+ VERIFY( strmsz_1 == 10 );
+ strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
+ VERIFY( strmsz_2 == 10 );
+ VERIFY( strmsz_1 == strmsz_2 );
+ VERIFY( fb_03.unbuffered() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc
new file mode 100644
index 00000000000..81cd506aba1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/2-out.cc
@@ -0,0 +1,66 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <testsuite_hooks.h>
+#include <testsuite_io.h>
+
+// @require@ %-*.tst %-*.txt
+// @diff@ %-*.tst %*.txt
+
+const char name_02[] = "tmp_sputn_2out.tst"; // empty file, need to create
+
+void test05()
+{
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ typedef filebuf::int_type int_type;
+ typedef filebuf::traits_type traits_type;
+ typedef size_t size_type;
+
+ bool test = true;
+ streamsize strmsz_1, strmsz_2;
+
+ // streamsize sputn(const char_typs* s, streamsize n)
+ // write up to n chars to out_cur from s, returning number assigned
+ // NB *sputn will happily put '\0' into your stream if you give it a chance*
+
+ // out
+ {
+ constraint_filebuf fb_02;
+ fb_02.pubsetbuf(0, 0);
+ fb_02.open(name_02, ios_base::out | ios_base::trunc);
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ strmsz_1 = fb_02.sputn("racadabras", 10);
+ VERIFY( strmsz_1 == 10 );
+ VERIFY( fb_02.unbuffered() );
+ VERIFY( !fb_02.read_position() );
+ }
+}
+
+main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/data/sgetc.txt b/libstdc++-v3/testsuite/data/sgetc.txt
new file mode 100644
index 00000000000..87e81f67772
--- /dev/null
+++ b/libstdc++-v3/testsuite/data/sgetc.txt
@@ -0,0 +1,3 @@
+// 990117 bkoz
+// test functionality of basic_filebuf for char_type == char
+// this is a data file for 27filebuf.cc
diff --git a/libstdc++-v3/testsuite/data/sgetn.txt b/libstdc++-v3/testsuite/data/sgetn.txt
new file mode 100644
index 00000000000..cb3c57f7dfd
--- /dev/null
+++ b/libstdc++-v3/testsuite/data/sgetn.txt
@@ -0,0 +1,158 @@
+// 990117 bkoz
+// test functionality of basic_filebuf for char_type == char
+// this is a data file for 27filebuf.cc
+
+// Copyright (C) 1997-1999 Cygnus Solutions
+//
+// 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+/mnt/cdrom/sarah_vaughan/sarah_vaughan.allofme
+/mnt/cdrom/sarah_vaughan/sarah_vaughan.speaklow
+
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_01_the_way_i_feel
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_02_seduction_kidnap
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_03_just_a_ny_poem
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_04_butterflies_i_remem
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_05_luxury_poem
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_06_my_house
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_07_the_women_gather
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_08_the_life_i_led
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_09_when_i_die
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_10_revolutionary_dreams
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_11_winter_poem
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_12_a_certain_peace_i_nap
+/mnt/cdrom/nikkigiovanni_thewayifeel/ng_13_poem_for_a_lady_whose
+
+/mnt/cdrom/marley-songs_of_freedom/disk_1/
+/mnt/cdrom/marley-songs_of_freedom/disk_2/
+/mnt/cdrom/marley-songs_of_freedom/disk_4/
+
+/mnt/cdrom/marley-songs_of_freedom/disk_1/back out
+/mnt/cdrom/marley-songs_of_freedom/disk_1/bend down low
+/mnt/cdrom/marley-songs_of_freedom/disk_1/bus dem shut (pyaka)
+/mnt/cdrom/marley-songs_of_freedom/disk_1/caution
+/mnt/cdrom/marley-songs_of_freedom/disk_1/do it twice
+/mnt/cdrom/marley-songs_of_freedom/disk_1/don't rock the boat
+/mnt/cdrom/marley-songs_of_freedom/disk_1/duppy conqueror
+/mnt/cdrom/marley-songs_of_freedom/disk_1/hammer
+/mnt/cdrom/marley-songs_of_freedom/disk_1/hypocrites
+/mnt/cdrom/marley-songs_of_freedom/disk_1/i'm still waiting
+/mnt/cdrom/marley-songs_of_freedom/disk_1/judge not
+/mnt/cdrom/marley-songs_of_freedom/disk_1/mellow mood
+/mnt/cdrom/marley-songs_of_freedom/disk_1/mr brown
+/mnt/cdrom/marley-songs_of_freedom/disk_1/nice time
+/mnt/cdrom/marley-songs_of_freedom/disk_1/one cup of coffee
+/mnt/cdrom/marley-songs_of_freedom/disk_1/one love_people get ready
+/mnt/cdrom/marley-songs_of_freedom/disk_1/put it on
+/mnt/cdrom/marley-songs_of_freedom/disk_1/simmer down
+/mnt/cdrom/marley-songs_of_freedom/disk_1/small axe
+/mnt/cdrom/marley-songs_of_freedom/disk_1/soul rebel
+/mnt/cdrom/marley-songs_of_freedom/disk_1/soul shake down party
+/mnt/cdrom/marley-songs_of_freedom/disk_1/stir it up (original)
+/mnt/cdrom/marley-songs_of_freedom/disk_1/sun is shining
+/mnt/cdrom/marley-songs_of_freedom/disk_1/thank you lord (original)
+/mnt/cdrom/marley-songs_of_freedom/disk_2/acoustic medley
+/mnt/cdrom/marley-songs_of_freedom/disk_2/burnin' and lootin'
+/mnt/cdrom/marley-songs_of_freedom/disk_2/concrete jungle
+/mnt/cdrom/marley-songs_of_freedom/disk_2/craven choke puppy
+/mnt/cdrom/marley-songs_of_freedom/disk_2/get up stand up
+/mnt/cdrom/marley-songs_of_freedom/disk_2/guava jelly
+/mnt/cdrom/marley-songs_of_freedom/disk_2/high tide or low tide
+/mnt/cdrom/marley-songs_of_freedom/disk_2/i shot the sheriff
+/mnt/cdrom/marley-songs_of_freedom/disk_2/i'm hurting inside
+/mnt/cdrom/marley-songs_of_freedom/disk_2/iron lion zion
+/mnt/cdrom/marley-songs_of_freedom/disk_2/lick samba
+/mnt/cdrom/marley-songs_of_freedom/disk_2/lively up yourself
+/mnt/cdrom/marley-songs_of_freedom/disk_2/natty dread
+/mnt/cdrom/marley-songs_of_freedom/disk_2/no more trouble
+/mnt/cdrom/marley-songs_of_freedom/disk_2/rastaman chant
+/mnt/cdrom/marley-songs_of_freedom/disk_2/screw face
+/mnt/cdrom/marley-songs_of_freedom/disk_2/slave driver
+/mnt/cdrom/marley-songs_of_freedom/disk_2/trenchtown rock
+/mnt/cdrom/marley-songs_of_freedom/disk_4/africa unite
+/mnt/cdrom/marley-songs_of_freedom/disk_4/babylon system
+/mnt/cdrom/marley-songs_of_freedom/disk_4/bad card
+/mnt/cdrom/marley-songs_of_freedom/disk_4/coming in from the cold (12
+/mnt/cdrom/marley-songs_of_freedom/disk_4/could you be loved (12 mix
+/mnt/cdrom/marley-songs_of_freedom/disk_4/forever loving jah
+/mnt/cdrom/marley-songs_of_freedom/disk_4/give thanks and praise
+/mnt/cdrom/marley-songs_of_freedom/disk_4/one drop
+/mnt/cdrom/marley-songs_of_freedom/disk_4/one dub
+/mnt/cdrom/marley-songs_of_freedom/disk_4/rastaman live up
+/mnt/cdrom/marley-songs_of_freedom/disk_4/real situation
+/mnt/cdrom/marley-songs_of_freedom/disk_4/redemption song (live in pi
+/mnt/cdrom/marley-songs_of_freedom/disk_4/ride natty ride (12 mix)
+/mnt/cdrom/marley-songs_of_freedom/disk_4/so much trouble in the worl
+/mnt/cdrom/marley-songs_of_freedom/disk_4/survival
+/mnt/cdrom/marley-songs_of_freedom/disk_4/why should i (previously un
+/mnt/cdrom/marley-songs_of_freedom/disk_4/zimbabwe
+
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_01_pandemonium
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_02_sync_disjecta
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_03_object_unknown
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_04_it's_nice_not
+/mnt/cdrom/dj_spooky_rid-2dim_warefare/djspooky_05_dialectical_tra
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_06_post-human_soph
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_07_quilombo_ex
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_08_rekonstruction
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_09_scientifik
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_10_a_conversation
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_11_peace_in_zaire
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_13_degree_zero
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_14_roman_planeta
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_15_bass_digitalis
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_16_polyphony_of
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_17_riddim_warfare
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_18_the_nerd
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_20_theme_of_the
+/mnt/cdrom/dj_spooky_riddim_warefare/djspooky_21_twilight_fugue
+
+/mnt/cdrom/stuff_smith_mosaic/disk3/01_desert_sands
+/mnt/cdrom/stuff_smith_mosaic/disk3/02_soft_winds
+/mnt/cdrom/stuff_smith_mosaic/disk3/03_time_and_again
+/mnt/cdrom/stuff_smith_mosaic/disk3/04_it_don't_mean_a_thing
+/mnt/cdrom/stuff_smith_mosaic/disk3/05_in_a_mellotone
+/mnt/cdrom/stuff_smith_mosaic/disk3/06_i_know_that_you_know
+/mnt/cdrom/stuff_smith_mosaic/disk3/07_heat_wave
+/mnt/cdrom/stuff_smith_mosaic/disk3/08_things_ain't_what_they_used_to_be
+/mnt/cdrom/stuff_smith_mosaic/disk3/09_body_and_soul
+
+So I take a break, wander down to the park to stand, then lean into
+the concrete railing demarking the beginnings of space, oceanic
+space. I watch the waves break, and form, and ease back out to sea and
+wrap my arms around myself and hug tightly because it's early in the
+morning and windy, and the sun is late getting out of bed today, which
+is good because if there was brilliant light illuminating all the
+beauty around me I would be shocked, stunned, forced to retreat back
+into my cabana in a daze, blinded by hummingbirds and callilillies and
+un-named red, yellow, and blue flowers. Green envelopes me, waves
+sooth me. I can see the wind flip the top of the waves seaward, right
+before they break. The sea seems so calm from my perch above the fray
+that I wonder if maybe there is just some part of the deepest, most
+abstract ocean where there is a large creature who happily chews
+plankton and wags its tail in gentle, adulating waves that spread and
+move and gracefully glide thousands of miles, to crash upon a beach,
+one after the other, politely waiting for a turn to dance with the
+seashore.
+
+I know: it is what the Mexican schoolchildren call "la vibora de la
+mer," the serpent of the sea.
+
+
+
+
+
diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h
index 0c3aae6cec9..719135caa58 100644
--- a/libstdc++-v3/testsuite/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/testsuite_hooks.h
@@ -110,6 +110,7 @@ namespace __gnu_cxx_test
std::locale
try_named_locale(const char* name);
+
// Test data types.
struct pod_char
{
@@ -137,6 +138,7 @@ namespace __gnu_cxx_test
unsigned long l2;
};
+
// Counting.
struct counter
{
diff --git a/libstdc++-v3/testsuite/testsuite_io.h b/libstdc++-v3/testsuite/testsuite_io.h
new file mode 100644
index 00000000000..33de2a05b14
--- /dev/null
+++ b/libstdc++-v3/testsuite/testsuite_io.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+// Testing filebuf for the C++ library testsuite.
+//
+// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+//
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _GLIBCPP_TESTSUITE_IO_H
+#define _GLIBCPP_TESTSUITE_IO_H
+
+#include <fstream>
+
+namespace __gnu_cxx_test
+{
+ // Used to verify the constraints/requirements on get and put areas
+ // as defined in
+ // 27.5.1 - Stream buffer requirements: get and put areas
+ // 27.8.1.1 - Template class basic_filebuf p 3
+ // If the file is not open (ios_base::in) -> input seq. cannot be read
+ // If the file is not open (ios_base::out) -> output seq. cannot be written
+ // Joint file position
+ // 27.8.1.4 - Overridden virtual functions p9
+ // If unbuffered, pbase == pptr == NULL
+ class constraint_filebuf: public std::filebuf
+ {
+ public:
+ bool
+ write_position()
+ {
+ bool two = this->pptr() != NULL;
+ bool one = this->pptr() < this->epptr();
+ return one && two;
+ }
+
+ bool
+ read_position()
+ {
+ bool one = this->gptr() != NULL;
+ bool two = this->gptr() < this->egptr();
+
+ return one && two;
+ }
+
+ bool
+ unbuffered()
+ {
+ bool one = this->pbase() == NULL;
+ bool two = this->pptr() == NULL;
+ return one && two;
+ }
+
+ };
+}; // namespace __gnu_cxx_test
+
+#endif // _GLIBCPP_TESTSUITE_IO_H
+