From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../basic_ostream/inserters_other/wchar_t/1.cc | 78 +++++++++ .../basic_ostream/inserters_other/wchar_t/2.cc | 65 ++++++++ .../basic_ostream/inserters_other/wchar_t/3.cc | 44 +++++ .../basic_ostream/inserters_other/wchar_t/4.cc | 184 +++++++++++++++++++++ .../basic_ostream/inserters_other/wchar_t/5.cc | 96 +++++++++++ .../inserters_other/wchar_t/9318-out.cc | 63 +++++++ .../inserters_other/wchar_t/9424-out.cc | 105 ++++++++++++ .../inserters_other/wchar_t/9555-oo.cc | 59 +++++++ .../inserters_other/wchar_t/error_code.cc | 75 +++++++++ .../inserters_other/wchar_t/error_failbit.cc | 58 +++++++ .../wchar_t/exceptions_badbit_throw.cc | 70 ++++++++ .../wchar_t/exceptions_failbit_throw.cc | 80 +++++++++ .../inserters_other/wchar_t/exceptions_null.cc | 61 +++++++ 13 files changed, 1038 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9318-out.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9424-out.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9555-oo.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_failbit.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_badbit_throw.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_failbit_throw.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t') diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc new file mode 100644 index 000000000..6e12a65bf --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2005, 2009, 2010 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +#include +#include +#include +#include + +const int size = 1000; +const char name_01[] = "wostream_inserter_other-1.tst"; +const char name_02[] = "wostream_inserter_other-1.txt"; +const char name_03[] = "wostream_inserter_other-2.tst"; +const char name_04[] = "wostream_inserter_other-2.txt"; + +// fstream +void +test02() +{ + typedef std::ios_base::iostate iostate; + bool test __attribute__((unused)) = true; + + // basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sb) + // filebuf-> NULL + std::wifstream f_in1(name_01); + std::wofstream f_out1(name_02); + std::wstringbuf* strbuf01 = 0; + iostate state01 = f_in1.rdstate(); + f_in1 >> strbuf01; + iostate state02 = f_in1.rdstate(); + VERIFY( state01 != state02 ); + VERIFY( (state02 & std::ios_base::failbit) != 0 ); + state01 = f_out1.rdstate(); + f_out1 << strbuf01; + state02 = f_out1.rdstate(); + VERIFY( state01 != state02 ); + VERIFY( (state02 & std::ios_base::badbit) != 0 ); + + // filebuf->filebuf + std::wifstream f_in(name_01); + std::wofstream f_out(name_02); + f_out << f_in.rdbuf(); + f_in.close(); + f_out.close(); + + // filebuf->stringbuf->filebuf + std::wifstream f_in2(name_03); + std::wofstream f_out2(name_04); // should be different name + std::wstringbuf strbuf02; + f_in2 >> &strbuf02; + f_out2 << &strbuf02; + f_in2.close(); + f_out2.close(); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc new file mode 100644 index 000000000..bb12a7cc4 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 2009 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +#include +#include +#include + +// via Brent Verner +// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00005.html +void +test03(void) +{ + using namespace std; + + typedef wios::pos_type pos_type; + + const char* TEST_IN = "wostream_inserter_other_in.txt"; + const char* TEST_OUT = "wostream_inserter_other_out.txt"; + pos_type i_read, i_wrote, rs, ws; + double tf_size = BUFSIZ * 2.5; + ofstream testfile(TEST_IN); + + for (int i = 0; i < tf_size; ++i) + testfile.put(L'.'); + testfile.close(); + + wifstream in(TEST_IN); + wofstream out(TEST_OUT); + out << in.rdbuf(); + in.seekg(0, ios_base::beg); + out.seekp(0, ios_base::beg); + rs = in.tellg(); + ws = out.tellp(); + in.seekg(0, ios_base::end); + out.seekp(0, ios_base::end); + i_read = in.tellg() - rs; + i_wrote = out.tellp() - ws; + in.close(); + out.close(); +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/3.cc new file mode 100644 index 000000000..51e329b5d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/3.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005, 2009 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +// libstdc++/3272 +void test04() +{ + using namespace std; + bool test __attribute__((unused)) = true; + wistringstream istr(L"inside betty carter"); + wostringstream ostr; + ostr << istr.rdbuf() << endl; + + if (ostr.rdstate() & ios_base::eofbit) + test = false; + + VERIFY( test ); +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/4.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/4.cc new file mode 100644 index 000000000..3cd771c7f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/4.cc @@ -0,0 +1,184 @@ +// Copyright (C) 2005, 2009 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.4 basic_ostream character inserters + +#include +#include +#include + +class test_buffer_1 : public std::wstreambuf +{ +public: + test_buffer_1(const std::wstring& s) + : str(s), it(str.begin()) { } + +protected: + virtual int_type + underflow() + { return (it != str.end() ? *it : WEOF); } + + virtual int_type + uflow() + { return (it != str.end() ? *it++ : WEOF); } + +private: + const std::wstring str; + std::wstring::const_iterator it; +}; + + +class test_buffer_2 : public std::wstreambuf +{ +public: + test_buffer_2(const std::wstring& s) + : str(s), it(str.begin()) { } + +protected: + virtual int_type + underflow() + { return (it != str.end() ? *it : WEOF); } + + virtual int_type + uflow() + { return (it != str.end() ? *it++ : WEOF); } + + virtual std::streamsize + showmanyc() + { return std::distance(it, str.end()); } + +private: + const std::wstring str; + std::wstring::const_iterator it; +}; + + +class test_buffer_3 : public std::wstreambuf +{ +public: + test_buffer_3(const std::wstring& s) + : str(s), it(str.begin()) { } + +protected: + virtual int_type + underflow() + { return (it != str.end() ? *it : WEOF); } + + virtual int_type + uflow() + { return (it != str.end() ? *it++ : WEOF); } + + virtual std::streamsize + showmanyc() + { + std::streamsize ret = std::distance(it, str.end()); + return ret > 0 ? ret : -1; + } + +private: + const std::wstring str; + std::wstring::const_iterator it; +}; + +class test_buffer_4 : public std::wstreambuf +{ +public: + test_buffer_4(const std::wstring& s) + : str(s), it(str.begin()) + { + if (it != str.end()) + { + buf[0] = *it++; + setg(buf, buf, buf+1); + } + } + +protected: + virtual int_type + underflow() + { return (it != str.end() ? *it : WEOF); } + + virtual int_type + uflow() + { return (it != str.end() ? *it++ : WEOF); } + + virtual std::streamsize + showmanyc() + { + std::streamsize ret = std::distance(it, str.end()); + return ret > 0 ? ret : -1; + } + +private: + const std::wstring str; + std::wstring::const_iterator it; + wchar_t buf[1]; +}; + +void test(const std::wstring& str, std::wstreambuf& buf) +{ + bool test __attribute__((unused)) = true; + + std::wostringstream out; + std::wistream in(&buf); + + out << in.rdbuf(); + + if (out.str() != str) + VERIFY( false ); +} + +// libstdc++/6745 +// libstdc++/8071 +// libstdc++/8127 +// Jonathan Lennox +void test05() +{ + std::wstring string_a(L"Hello, world!"); + std::wstring string_b(L""); + + test_buffer_1 buf1a(string_a); + test_buffer_1 buf1b(string_b); + + test_buffer_2 buf2a(string_a); + test_buffer_2 buf2b(string_b); + + test_buffer_3 buf3a(string_a); + test_buffer_3 buf3b(string_b); + + test_buffer_4 buf4a(string_a); + test_buffer_4 buf4b(string_b); + + test(string_a, buf1a); + test(string_b, buf1b); + + test(string_a, buf2a); + test(string_b, buf2b); + + test(string_a, buf3a); + test(string_b, buf3b); + + test(string_a, buf4a); + test(string_b, buf4b); +} + +int +main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/5.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/5.cc new file mode 100644 index 000000000..e8818f542 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/5.cc @@ -0,0 +1,96 @@ +// Copyright (C) 2005, 2009 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +// 27.6.2.5.3 basic_ostream manipulator inserters +// +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// DR 60. What is a formatted input function? +// Inserters for manipulators do not behave as formatted output functions. + +#include +#include +#include +#include + +std::wostream& func1(std::wostream&) +{ throw std::runtime_error(""); } + +std::wios& func2(std::wios&) +{ throw std::runtime_error(""); } + +std::ios_base& func3(std::ios_base&) +{ throw std::runtime_error(""); } + +template +void test(T& (*f)(T&)) +{ + bool test __attribute__((unused)) = true; + + __gnu_test::sync_wstreambuf buf; + std::wostream os(&buf); + + __gnu_test::sync_wstreambuf buf_tie; + std::wostream os_tie(&buf_tie); + + // No sentry should be constructed so os.tie()->flush() should not be + // called. + os.tie(&os_tie); + + try + { + os << f; + // Exceptions thrown by f should not be caught + VERIFY( false ); + } + catch (std::runtime_error&) + { + } + + // Exceptions thrown by f should not cause badbit to be set + VERIFY( os.good() ); + VERIFY( !buf_tie.sync_called() ); + + // The manipulator should be called even if !os.good(). + os.setstate(std::ios_base::eofbit); + + try + { + os << f; + // Exceptions thrown by f should not be caught + VERIFY( false ); + } + catch (std::runtime_error&) + { + } + + // Exceptions thrown by f should not cause badbit to be set + VERIFY( os.rdstate() == std::ios_base::eofbit ); + VERIFY( !buf_tie.sync_called() ); +} + +void test05() +{ + test(&func1); + test(&func2); + test(&func3); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9318-out.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9318-out.cc new file mode 100644 index 000000000..a02ed488b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9318-out.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + + +// 27.5.2 template class basic_streambuf + +#include +#include +#include +#include + +// libstdc++/9318 +class Outbuf : public std::wstreambuf +{ +public: + typedef std::wstreambuf::traits_type traits_type; + + std::wstring result() const { return str; } + +protected: + virtual int_type + overflow(int_type c = traits_type::eof()) + { + if (!traits_type::eq_int_type(c, traits_type::eof())) + str.push_back(traits_type::to_char_type(c)); + return traits_type::not_eof(c); + } + +private: + std::wstring str; +}; + +void test10() +{ + bool test __attribute__((unused)) = true; + + std::wstringbuf sbuf(L"Bad Moon Rising", std::wios::in); + Outbuf buf; + std::wostream stream(&buf); + stream << &sbuf; + + VERIFY( buf.result() == L"Bad Moon Rising" ); +} + +int main() +{ + test10(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9424-out.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9424-out.cc new file mode 100644 index 000000000..7b89d26df --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9424-out.cc @@ -0,0 +1,105 @@ +// 1999-10-11 bkoz + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009 +// 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 3, 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 COPYING3. If not see +// . + + +// 27.5.2 template class basic_streambuf + +#include +#include +#include +#include +#include + +// libstdc++/9424 +class Outbuf_2 : public std::wstreambuf +{ + wchar_t 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::wstreambuf +{ + static const wchar_t buf[]; + const wchar_t* current; + int size; + +public: + Inbuf_2() + { + current = buf; + size = std::wcslen(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 wchar_t Inbuf_2::buf[] = L"Atteivlis"; + +void test12() +{ + bool test __attribute__((unused)) = true; + + Outbuf_2 outbuf2; + std::wostream os (&outbuf2); + Inbuf_2 inbuf2; + os << &inbuf2; + VERIFY( inbuf2.sgetc() == L't' ); + VERIFY( os.good() ); +} + +int main() +{ + test12(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9555-oo.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9555-oo.cc new file mode 100644 index 000000000..89a5d361e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/9555-oo.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include + +struct buf: std::wstreambuf +{ + virtual int_type overflow(int_type) + { throw 0; } +}; + +template +void testthrow(T arg) +{ + bool test __attribute__((unused)) = true; + buf b; + std::wostream os(&b); + os.exceptions(std::wios::badbit); + + try + { + os << arg; + } + catch(int) + { + // Expected return is zero. + VERIFY( os.bad() ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + buf b; + + testthrow(&b); + + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc new file mode 100644 index 000000000..16f9108a3 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-swprintf "" } + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation +// +// 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 3, 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 COPYING3. If not see +// . + +#include +#include +#include +#include +#include +#include + +// Effects: os << ec.category().name() << ':' << ec.value(); +void test() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wchar_t buf[64]; + error_code e1; + error_code e2(make_error_code(errc::bad_address)); + wstring s, s1, s2; + + { + wostringstream ostr; + ostr << e1 << endl; + s1 = ostr.str(); + + if (ostr.rdstate() & ios_base::eofbit) + test = false; + } + VERIFY( test ); + VERIFY( find(s1.begin(), s1.end(), L':') != s1.end() ); + + swprintf(buf, 64, L"%i", e1.value()); + s = buf; + VERIFY( s1.find(s) != string::npos); + + { + wostringstream ostr; + ostr << e2 << endl; + s2 = ostr.str(); + + if (ostr.rdstate() & ios_base::eofbit) + test = false; + } + VERIFY( test ); + VERIFY( find(s2.begin(), s2.end(), L':') != s2.end() ); + + swprintf(buf, 64, L"%i", e2.value()); + s = buf; + VERIFY( s2.find(s) != string::npos); +} + +int +main() +{ + test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_failbit.cc new file mode 100644 index 000000000..3df90b873 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_failbit.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include +#include +#include + +using namespace std; + +void test5() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bob; + wostream stream(&bob); + wstringbuf sbuf(L"Foo, bar, qux", ios_base::in); + + stream << &sbuf; + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +void test7() +{ + bool test __attribute__((unused)) = true; + wostringstream stream; + __gnu_test::fail_wstreambuf bib; + + stream << &bib; + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +// libstdc++/9371 +int main() +{ + test5(); + test7(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_badbit_throw.cc new file mode 100644 index 000000000..954d56790 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_badbit_throw.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include +#include +#include + +using namespace std; + +void test13() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bob; + wostream stream(&bob); + stream.exceptions(ios_base::badbit); + wstringbuf sbuf(L"Foo, bar, qux", ios_base::in); + + try + { + stream << &sbuf; + } + catch (...) + { VERIFY(false); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +void test15() +{ + bool test __attribute__((unused)) = true; + wostringstream stream; + stream.exceptions(ios_base::badbit); + __gnu_test::fail_wstreambuf bib; + + try + { + stream << &bib; + } + catch (...) + { VERIFY(false); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +// libstdc++/9371 +int main() +{ + test13(); + test15(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_failbit_throw.cc new file mode 100644 index 000000000..789d3cc3c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_failbit_throw.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2005, 2009 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include +#include +#include + +using namespace std; + +void test9() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bob; + wostream stream(&bob); + stream.exceptions(ios_base::failbit); + wstringbuf sbuf(L"Foo, bar, qux", ios_base::in); + + try + { + stream << &sbuf; + VERIFY( false ); + } + catch (ios_base::failure&) + { VERIFY( false ); } + catch (__gnu_test::overflow_error&) + { } + catch (...) + { VERIFY( false ); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +void test11() +{ + bool test __attribute__((unused)) = true; + wostringstream stream; + stream.exceptions(ios_base::failbit); + __gnu_test::fail_wstreambuf bib; + + try + { + stream << &bib; + VERIFY( false ); + } + catch (ios_base::failure&) + { VERIFY( false ); } + catch (__gnu_test::underflow_error&) + { } + catch (...) + { VERIFY( false ); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +// libstdc++/9371 +int main() +{ + test9(); + test11(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc new file mode 100644 index 000000000..076aece64 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2005, 2009, 2010 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 3, 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 COPYING3. If not see +// . + + +#include +#include +#include +#include +#include + +void test1() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wostringstream stream; + stream << static_cast(0); + VERIFY( stream.rdstate() & ios_base::badbit ); +} + +void test3() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wostringstream stream; + stream.exceptions(ios_base::badbit); + + try + { + stream << static_cast(0); + VERIFY( false ); + } + catch (ios_base::failure&) + { + } + + VERIFY( stream.rdstate() & ios_base::badbit ); +} + +// libstdc++/9371 +int main() +{ + test1(); + test3(); + return 0; +} -- cgit v1.2.3