summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-08 08:16:06 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-08 08:16:06 +0000
commitd224894434122edb0c9de1b7f79ee8e633d515d6 (patch)
tree9718ebdfec13ed6a37f4d78228aa105a9125271e /libstdc++-v3/testsuite
parent45c2938ec41ac5236ecc071bfb6ef147f0a8d5bb (diff)
downloadgcc-d224894434122edb0c9de1b7f79ee8e633d515d6.tar.gz
2003-03-08 Paolo Carlini <pcarlini@unitus.it>
Petur Runolfsson <peturr02@ru.is> PR libstdc++/9424 * include/bits/streambuf.tcc (__copy_streambufs): Use sgetn-sputn only when sputn cannot fail, otherwise fall back to safe snextc-sputc. * testsuite/27_io/streambuf_members.cc (test11, test12): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63974 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/27_io/streambuf_members.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/streambuf_members.cc b/libstdc++-v3/testsuite/27_io/streambuf_members.cc
index 80f569d8074..d7ae5693d33 100644
--- a/libstdc++-v3/testsuite/27_io/streambuf_members.cc
+++ b/libstdc++-v3/testsuite/27_io/streambuf_members.cc
@@ -431,6 +431,91 @@ void test10()
VERIFY( buf.result() == "Bad Moon Rising" );
}
+// libstdc++/9424
+class Outbuf_2 : public std::streambuf
+{
+ char buf[1];
+
+public:
+ Outbuf_2()
+ {
+ setp(buf, buf + 1);
+ }
+
+ int_type overflow(int_type c)
+ {
+ int_type eof = traits_type::eof();
+
+ if (pptr() < epptr())
+ {
+ if (traits_type::eq_int_type(c, eof))
+ return traits_type::not_eof(c);
+
+ *pptr() = traits_type::to_char_type(c);
+ pbump(1);
+ return c;
+ }
+
+ return eof;
+ }
+};
+
+class Inbuf_2 : public std::streambuf
+{
+ static const char buf[];
+ const char* current;
+ int size;
+
+public:
+ Inbuf_2()
+ {
+ current = buf;
+ size = std::strlen(buf);
+ }
+
+ int_type underflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current);
+ return traits_type::eof();
+ }
+
+ int_type uflow()
+ {
+ if (current < buf + size)
+ return traits_type::to_int_type(*current++);
+ return traits_type::eof();
+ }
+};
+
+const char Inbuf_2::buf[] = "Atteivlis";
+
+// <1>
+void test11()
+{
+ bool test = true;
+
+ Inbuf_2 inbuf1;
+ std::istream is(&inbuf1);
+ Outbuf_2 outbuf1;
+ is >> &outbuf1;
+ VERIFY( inbuf1.sgetc() == 't' );
+ VERIFY( is.good() );
+}
+
+// <2>
+void test12()
+{
+ bool test = true;
+
+ Outbuf_2 outbuf2;
+ std::ostream os (&outbuf2);
+ Inbuf_2 inbuf2;
+ os << &inbuf2;
+ VERIFY( inbuf2.sgetc() == 't' );
+ VERIFY( os.good() );
+}
+
int main()
{
test01();
@@ -445,5 +530,7 @@ int main()
test09();
test10();
+ test11();
+ test12();
return 0;
}