aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPetur Runolfsson <peturr02@ru.is>2003-09-03 14:54:03 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2003-09-03 14:54:03 +0000
commit149639d4f14ae921b4d14f6e35a840755b29f098 (patch)
tree171f78496fb967c04d39c1a4fabcdd7216ddcb8c /libstdc++-v3/testsuite
parent916b57cedabb2d80ac3e947a682efa3bce15cf4e (diff)
downloadgcc-149639d4f14ae921b4d14f6e35a840755b29f098.zip
gcc-149639d4f14ae921b4d14f6e35a840755b29f098.tar.gz
gcc-149639d4f14ae921b4d14f6e35a840755b29f098.tar.bz2
re PR libstdc++/12048 (unget does not work)
2003-09-03 Petur Runolfsson <peturr02@ru.is> PR libstdc++/12048 * include/ext/stdio_sync_filebuf.h (stdio_sync_filebuf::_M_unget_buf): Declare it. (stdio_sync_filebuf::stdio_sync_filebuf): Initialize _M_unget_buf. (stdio_sync_filebuf::uflow): Store the returned character in _M_unget_buf. (stdio_sync_filebuf::pbackfail): If argument is eof(), pass _M_unget_buf to syncungetc(). Set _M_unget_buf to eof(). (stdio_sync_filebuf<char>::xsgetn): Store last read character in _M_unget_buf, if any, else eof(). (stdio_sync_filebuf<wchar_t>::xsgetn: Store last read character in _M_unget_buf, if any, else eof(). * testsuite/27_io/objects/char/12048.cc: Rename to... * testsuite/27_io/objects/char/12048-1.cc: ...this. * testsuite/27_io/objects/char/12048-2.cc: New test. * testsuite/27_io/objects/char/12048-3.cc: New test. * testsuite/27_io/objects/char/12048-4.cc: New test. * testsuite/27_io/objects/char/12048-5.cc: New test. XFAIL. * testsuite/27_io/objects/wchar_t/12048-1.cc: New test. * testsuite/27_io/objects/wchar_t/12048-2.cc: New test. * testsuite/27_io/objects/wchar_t/12048-3.cc: New test. * testsuite/27_io/objects/wchar_t/12048-4.cc: New test. * testsuite/27_io/objects/wchar_t/12048-5.cc: New test. XFAIL. * testsuite/ext/stdio_sync_filebuf_char.cc (test02, test03, test04, test05): New tests. * testsuite/ext/stdio_sync_filebuf_wchar_t.cc (test02, test03, test04, test05): New tests. 2003-09-03 Petur Runolfsson <peturr02@ru.is> * docs/html/27_io/howto.html: setbuf(0, 0) has no effect on stringbuf or strstreambuf. Fix typos. From-SVN: r71026
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc78
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc78
2 files changed, 154 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc
index cffcf37..0958296 100644
--- a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc
@@ -52,13 +52,89 @@ void test01()
VERIFY( sbuf.sgetn(buf, 5) == 5 );
VERIFY( !memcmp(buf, c_lit + 3, 5) );
VERIFY( getc(fin) == c_lit[8] );
- VERIFY( sbuf.sungetc() == EOF );
fclose(fin);
}
+// libstdc++/12048
+void test02()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test03()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test04()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test05()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
int main ()
{
test01();
+ test02();
+ test03();
+ test04();
+ test05();
+
return 0;
}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc
index a8cde4a..25276a2 100644
--- a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc
@@ -53,13 +53,89 @@ void test01()
VERIFY( wsbuf.sgetn(buf, 5) == 5 );
VERIFY( !wmemcmp(buf, w_lit + 3, 5) );
VERIFY( getwc(fin) == w_lit[8] );
- VERIFY( wsbuf.sungetc() == WEOF );
fclose(fin);
}
+// libstdc++/12048
+void test02()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test03()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test04()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+// libstdc++/12048
+void test05()
+{
+ bool test = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
int main ()
{
test01();
+ test02();
+ test03();
+ test04();
+ test05();
+
return 0;
}