aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/ifstream_members.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/ifstream_members.cc')
-rw-r--r--libstdc++-v3/testsuite/27_io/ifstream_members.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/libstdc++-v3/testsuite/27_io/ifstream_members.cc b/libstdc++-v3/testsuite/27_io/ifstream_members.cc
index 3fb7a6d1156..6a4961a82a1 100644
--- a/libstdc++-v3/testsuite/27_io/ifstream_members.cc
+++ b/libstdc++-v3/testsuite/27_io/ifstream_members.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2000 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001 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
@@ -73,9 +73,51 @@ bool test01()
return test;
}
+void
+redirect_buffer(std::ios& stream, std::streambuf* new_buf)
+{ stream.rdbuf(new_buf); }
+
+std::streambuf*
+active_buffer(std::ios& stream)
+{ return stream.rdbuf(); }
+
+// libstdc++/2832
+void test02()
+{
+ bool test = true;
+ const char* strlit01 = "fuck war";
+ const char* strlit02 = "two less cars abstract riot crew, critical mass/SF";
+ const std::string str00;
+ const std::string str01(strlit01);
+ std::string str02;
+ std::filebuf fbuf;
+ std::streambuf* pbasebuf0 = &fbuf;
+
+ std::ifstream sstrm1;
+ // derived rdbuf() always returns original streambuf, even though
+ // it's no longer associated with the stream.
+ std::filebuf* const buf1 = sstrm1.rdbuf();
+ // base rdbuf() returns the currently associated streambuf
+ std::streambuf* pbasebuf1 = active_buffer(sstrm1);
+ redirect_buffer(sstrm1, &fbuf);
+ std::filebuf* const buf2 = sstrm1.rdbuf();
+ std::streambuf* pbasebuf2 = active_buffer(sstrm1);
+ VERIFY( buf1 == buf2 );
+ VERIFY( pbasebuf1 != pbasebuf2 );
+ VERIFY( pbasebuf2 == pbasebuf0 );
+
+ // How confusing and non-intuitive is this?
+ // These semantics are a joke, a serious defect, and incredibly lame.
+}
int main()
{
test00();
test01();
+
+ test02();
+ return 0;
}
+
+
+