summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-07 22:06:28 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-07 22:06:28 +0000
commitd972404cf94e69c36557ba4465894d1e27c6e007 (patch)
tree3af598b249b9920d009caed9e0797f741dabbc00 /libstdc++-v3/testsuite/27_io
parentbd9c340f19985166068e2408730c675b4f0ac550 (diff)
downloadgcc-d972404cf94e69c36557ba4465894d1e27c6e007.tar.gz
2003-03-07 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/9182 * include/bits/fstream.tcc (_M_really_overflow): Check for _M_convert_to_external possible failures. * include/std/std_fstream.h (sync): Check _M_really_overflow return value and return -1 in case of failure. * testsuite/27_io/filebuf_virtuals.cc (test13, test14): Add. 2003-03-07 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/9826 * include/bits/istream.tcc (operator>>(_CharT*), operator>>(basic_string&), ws): Pass a char_type to __ctype.is. * testsuite/27_io/stringstream.cc (test02): Add. * include/bits/istream.tcc (operator>>(_CharT*)): Assign a char_type to *__s. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63953 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/27_io')
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/stringstream.cc18
2 files changed, 75 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
index 660abd1752a..fd459636049 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
@@ -74,6 +74,7 @@ const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
+const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
@@ -704,6 +705,60 @@ void test12()
fbuf.close();
}
+class errorcvt : public std::codecvt<char, char, mbstate_t>
+{
+protected:
+ std::codecvt_base::result
+ do_out(mbstate_t&, const char* from, const char*,
+ const char*& from_next, char* to, char*,
+ char*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return std::codecvt<char, char, mbstate_t>::error;
+ }
+
+ virtual bool do_always_noconv() const throw()
+ {
+ return false;
+ }
+};
+
+// libstdc++/9182
+void test13()
+{
+ using namespace std;
+ bool test = true;
+
+ locale loc;
+ loc = locale(loc, new errorcvt);
+
+ filebuf fbuf1;
+ fbuf1.pubimbue(loc);
+ fbuf1.open(name_07, ios_base::out | ios_base::trunc);
+ fbuf1.sputn("ison", 4);
+ int r = fbuf1.pubsync();
+ VERIFY( r == -1 );
+ fbuf1.close();
+}
+
+void test14()
+{
+ using namespace std;
+ bool test = true;
+
+ locale loc;
+ loc = locale(loc, new errorcvt);
+
+ filebuf fbuf1;
+ fbuf1.pubimbue(loc);
+ fbuf1.pubsetbuf(0, 0);
+ fbuf1.open(name_07, ios_base::out | ios_base::trunc);
+ streamsize n = fbuf1.sputn("onne", 4);
+ VERIFY( n == 0 );
+ fbuf1.close();
+}
+
main()
{
test01();
@@ -720,5 +775,7 @@ main()
test10();
test11();
test12();
+ test13();
+ test14();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/stringstream.cc b/libstdc++-v3/testsuite/27_io/stringstream.cc
index 576b72d5282..a9778952d90 100644
--- a/libstdc++-v3/testsuite/27_io/stringstream.cc
+++ b/libstdc++-v3/testsuite/27_io/stringstream.cc
@@ -56,8 +56,26 @@ namespace test
template class basic_stringstream<pod_char, char_traits<pod_char> >;
} // test
+// libstdc++/9826
+void test02()
+{
+ using namespace std;
+ using __gnu_cxx_test::pod_char;
+
+ basic_stringstream<pod_char, char_traits<pod_char> > sstr;
+ // 1
+ basic_string<pod_char, char_traits<pod_char> > str;
+ sstr >> str;
+ // 2
+ pod_char* chr;
+ sstr >> chr;
+ // 3
+ sstr >> ws;
+}
+
int main()
{
test01();
+ test02();
return 0;
}