diff options
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t')
11 files changed, 780 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc new file mode 100644 index 000000000..eab6650b1 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc @@ -0,0 +1,137 @@ +// Copyright (C) 2004, 2005, 2006, 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 +// <http://www.gnu.org/licenses/>. + +// 27.6.1.2.3 basic_istream::operator>> + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// stringbufs. +void test01() +{ + typedef std::wios::traits_type ctraits_type; + + bool test __attribute__((unused)) = true; + const std::wstring str_01; + const std::wstring str_02(L"art taylor kickin it on DAKAR"); + std::wstring strtmp; + + std::wstringbuf isbuf_00(std::ios_base::in); + std::wstringbuf isbuf_01(std::ios_base::in | std::ios_base::out); + std::wstringbuf isbuf_02(str_01, std::ios_base::in); + std::wstringbuf isbuf_03(str_01, std::ios_base::in | std::ios_base::out); + std::wstringbuf isbuf_04(str_02, std::ios_base::in); + std::wstringbuf isbuf_05(str_02, std::ios_base::in | std::ios_base::out); + + std::wistream is_00(0); + std::wistream is_01(&isbuf_01); + std::wistream is_02(&isbuf_02); + std::wistream is_03(&isbuf_03); + std::wistream is_04(&isbuf_04); + std::wistream is_05(&isbuf_05); + std::ios_base::iostate state1, state2, statefail, stateeof; + statefail = std::ios_base::failbit; + stateeof = std::ios_base::eofbit; + + + // template<_CharT, _Traits> + // basic_istream& operator>>(basic_streambuf*) + + // null istream to empty in_buf + state1 = is_00.rdstate(); + is_00 >> &isbuf_00; + state2 = is_00.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_00.str() == str_01 ); + + // null istream to empty in_out_buf + is_00.clear(std::ios_base::goodbit); + state1 = is_00.rdstate(); + is_00 >> &isbuf_01; + state2 = is_00.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_01.str() == str_01 ); + + // null istream to full in_buf + is_00.clear(std::ios_base::goodbit); + state1 = is_00.rdstate(); + is_00 >> &isbuf_04; + state2 = is_00.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_04.str() == str_02 ); + + // null istream to full in_out_buf + is_00.clear(std::ios_base::goodbit); + state1 = is_00.rdstate(); + is_00 >> &isbuf_05; + state2 = is_00.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_05.str() == str_02 ); + + // empty but non-null istream to full in_buf + state1 = is_02.rdstate(); + is_02 >> &isbuf_04; + state2 = is_02.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_04.str() == str_02 ); // as only an "in" buffer + VERIFY( isbuf_04.sgetc() == L'a' ); + + // empty but non-null istream to full in_out_buf + is_02.clear(std::ios_base::goodbit); + state1 = is_02.rdstate(); + is_02 >> &isbuf_05; + state2 = is_02.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_05.str() == str_02 ); // as only an "in" buffer + VERIFY( isbuf_05.sgetc() == L'a' ); + + // full istream to empty in_buf (need out_buf, you know?) + state1 = is_04.rdstate(); + is_04 >> &isbuf_02; + state2 = is_04.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( static_cast<bool>(state2 & statefail) ); + VERIFY( isbuf_02.str() == str_01 ); // as only an "in" buffer + VERIFY( isbuf_02.sgetc() == ctraits_type::eof() ); + VERIFY( is_04.peek() == ctraits_type::eof() ); // as failed + + // full istream to empty in_out_buf + is_04.clear(std::ios_base::goodbit); + state1 = is_04.rdstate(); + is_04 >> &isbuf_03; + state2 = is_04.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( !static_cast<bool>(state2 & statefail) ); + VERIFY( state2 == stateeof ); + strtmp = isbuf_03.str(); + VERIFY( strtmp == str_02 ); // as only an "in" buffer + VERIFY( isbuf_03.sgetc() == L'a' ); + VERIFY( is_04.peek() == ctraits_type::eof() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc new file mode 100644 index 000000000..b4f3c9a60 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + +// 27.6.1.2.3 basic_istream::operator>> +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +#include <istream> +#include <fstream> +#include <testsuite_hooks.h> + +// filebufs. +void test02() +{ + bool test __attribute__((unused)) = true; + const char name_01[] = "wistream_extractor_other-1.txt"; //read + const char name_02[] = "wistream_extractor_other-2.txt"; //write + + std::wfilebuf fbin, fbout; + fbin.open(name_01, std::ios_base::in); + fbout.open(name_02, std::ios_base::out | std::ios_base::trunc); + VERIFY( fbin.is_open() ); + VERIFY( fbout.is_open() ); + + if (test) + { + std::wistream is(&fbin); + is.unsetf(std::ios_base::skipws); + is >> &fbout; + } + + fbout.close(); + fbin.close(); + VERIFY( !fbin.is_open() ); + VERIFY( !fbout.is_open() ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc new file mode 100644 index 000000000..4e54e2296 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2006, 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 +// <http://www.gnu.org/licenses/>. + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/26181 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef wistringstream::pos_type pos_type; + + wistringstream iss(L"Territoires de l'Oubli"); + wostringstream oss; + + VERIFY( iss.tellg() == pos_type(0) ); + + iss >> oss.rdbuf(); + VERIFY( iss.rdstate() == iss.eofbit ); + + iss.clear(); + VERIFY( iss.tellg() == pos_type(22) ); + + iss.get(); + VERIFY( iss.tellg() == pos_type(-1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc new file mode 100644 index 000000000..1918f9bb6 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/3.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + +// 27.6.1.2.3 basic_istream::operator>> + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +void test03() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // template<_CharT, _Traits> + // basic_istream& operator>>(ios_base& (*pf) (ios_base&)) + { + int i = 0; + std::wistringstream iss(L" 43"); + iss >> std::noskipws >> i; + VERIFY ( !iss ); //should set failbit + } + + // template<_CharT, _Traits> + // basic_istream& operator>>(basic_ios& (*pf) (basic_ios&)) + + // template<_CharT, _Traits> + // basic_istream& operator>>(basic_istream& (*pf) (basic_istream&)) +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc new file mode 100644 index 000000000..c2925f24c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9318-in.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +// 27.5.2 template class basic_streambuf + +#include <sstream> +#include <istream> +#include <testsuite_hooks.h> + +// 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 test09() +{ + bool test __attribute__((unused)) = true; + + std::wistringstream stream(L"Bad Moon Rising"); + Outbuf buf; + stream >> &buf; + + VERIFY( buf.result() == L"Bad Moon Rising" ); +} + +int main() +{ + test09(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc new file mode 100644 index 000000000..38b345715 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9424-in.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +// 27.5.2 template class basic_streambuf + +#include <cstring> +#include <cwchar> +#include <streambuf> +#include <sstream> +#include <ostream> +#include <testsuite_hooks.h> + +// 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 test11() +{ + bool test __attribute__((unused)) = true; + + Inbuf_2 inbuf1; + std::wistream is(&inbuf1); + Outbuf_2 outbuf1; + is >> &outbuf1; + VERIFY( inbuf1.sgetc() == L't' ); + VERIFY( is.good() ); +} + +int main() +{ + test11(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc new file mode 100644 index 000000000..a46c2b91f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/9555-io.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +#include <istream> +#include <streambuf> +#include <testsuite_hooks.h> + +struct buf: std::wstreambuf +{ + virtual int_type overflow(int_type) + { throw 0; } +}; + +template<typename T> +void testthrow(T arg) +{ + bool test __attribute__((unused)) = true; + buf b; + std::wistream is(&b); + is.exceptions(std::wios::badbit); + + try + { + is >> arg; + } + catch(int) + { + // Expected return is zero. + VERIFY( is.bad() ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + buf b; + + testthrow(&b); + + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc new file mode 100644 index 000000000..bbac2413d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/error_failbit.cc @@ -0,0 +1,58 @@ +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + + +#include <istream> +#include <streambuf> +#include <sstream> +#include <testsuite_hooks.h> +#include <testsuite_io.h> + +using namespace std; + +void test6() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bib; + wistream stream(&bib); + wstringbuf sbuf(L"", ios_base::out); + + stream >> &sbuf; + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +void test8() +{ + bool test __attribute__((unused)) = true; + wistringstream stream(L"foo, bar, qux"); + __gnu_test::fail_wstreambuf bob; + + stream >> &bob; + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +// libstdc++/9371 +int main() +{ + test6(); + test8(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc new file mode 100644 index 000000000..d7e16905b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_badbit_throw.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +#include <istream> +#include <streambuf> +#include <sstream> +#include <testsuite_hooks.h> +#include <testsuite_io.h> + +using namespace std; + +void test14() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bib; + wistream stream(&bib); + stream.exceptions(ios_base::badbit); + wstringbuf sbuf(L"", ios_base::out); + + try + { + stream >> &sbuf; + } + catch (...) + { VERIFY( false ); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +void test16() +{ + bool test __attribute__((unused)) = true; + wistringstream stream(L"foo, bar, qux"); + stream.exceptions(ios_base::badbit); + __gnu_test::fail_wstreambuf bob; + + try + { + stream >> &bob; + } + catch (...) + { VERIFY( false ); } + + VERIFY( stream.rdstate() & ios_base::failbit ); + VERIFY( (stream.rdstate() & ios_base::badbit) == 0 ); +} + +// libstdc++/9371 +int main() +{ + test14(); + test16(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc new file mode 100644 index 000000000..a9f4b9734 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_failbit_throw.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +#include <istream> +#include <streambuf> +#include <sstream> +#include <testsuite_hooks.h> +#include <testsuite_io.h> + +using namespace std; + +void test10() +{ + bool test __attribute__((unused)) = true; + __gnu_test::fail_wstreambuf bib; + wistream stream(&bib); + stream.exceptions(ios_base::failbit); + wstringbuf sbuf(L"", ios_base::out); + + try + { + stream >> &sbuf; + 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 ); +} + +void test12() +{ + bool test __attribute__((unused)) = true; + wistringstream stream(L"foo, bar, qux"); + stream.exceptions(ios_base::failbit); + __gnu_test::fail_wstreambuf bob; + + try + { + stream >> &bob; + 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 ); +} + +// libstdc++/9371 +int main() +{ + test10(); + test12(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc new file mode 100644 index 000000000..bc04b7d9b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2004, 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 +// <http://www.gnu.org/licenses/>. + + +#include <istream> +#include <ostream> +#include <streambuf> +#include <sstream> +#include <testsuite_hooks.h> + +using namespace std; + +void test2() +{ + bool test __attribute__((unused)) = true; + wistringstream stream; + stream >> static_cast<wstreambuf*>(0); + VERIFY( stream.rdstate() & ios_base::failbit ); +} + +void test4() +{ + bool test __attribute__((unused)) = true; + wistringstream stream; + stream.exceptions(ios_base::failbit); + + try + { + stream >> static_cast<wstreambuf*>(0); + VERIFY( false ); + } + catch (ios_base::failure&) + { + } + + VERIFY( stream.rdstate() & ios_base::failbit ); +} + +// libstdc++/9371 +int main() +{ + test2(); + test4(); + return 0; +} |