diff options
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/ignore')
10 files changed, 743 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc new file mode 100644 index 000000000..4e0ce25aa --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/1.cc @@ -0,0 +1,78 @@ +// 1999-08-11 bkoz + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + typedef std::ios::traits_type traits_type; + + bool test __attribute__((unused)) = true; + const std::string str_01; + const std::string str_02("soul eyes: john coltrane quartet"); + std::string strtmp; + + std::stringbuf isbuf_03(str_02, std::ios_base::in); + std::stringbuf isbuf_04(str_02, std::ios_base::in); + + std::istream is_00(0); + std::istream is_03(&isbuf_03); + std::istream is_04(&isbuf_04); + std::ios_base::iostate state1, state2; + + // istream& read(char_type* s, streamsize n) + char carray[60] = ""; + is_04.read(carray, 9); + VERIFY( is_04.peek() == ':' ); + + // istream& ignore(streamsize n = 1, int_type delim = traits::eof()) + state1 = is_04.rdstate(); + is_04.ignore(); + VERIFY( is_04.gcount() == 1 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == ' ' ); + + state1 = is_04.rdstate(); + is_04.ignore(0); + VERIFY( is_04.gcount() == 0 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == ' ' ); + + state1 = is_04.rdstate(); + is_04.ignore(5, traits_type::to_int_type(' ')); + VERIFY( is_04.gcount() == 1 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == 'j' ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc new file mode 100644 index 000000000..05236fd57 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/2.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004, 2005, 2006, 2007, 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.3 unformatted input functions + +// { dg-require-fileio "" } + +#include <istream> +#include <string> +#include <fstream> +#include <limits> +#include <cstdlib> +#include <testsuite_hooks.h> + +using namespace std; + +string prepare(string::size_type len, unsigned nchunks, char delim) +{ + string ret; + for (unsigned i = 0; i < nchunks; ++i) + { + for (string::size_type j = 0; j < len; ++j) + ret.push_back('a' + rand() % 26); + len *= 2; + ret.push_back(delim); + } + return ret; +} + +void check(istream& stream, const string& str, unsigned nchunks, char delim) +{ + bool test __attribute__((unused)) = true; + + string::size_type index = 0, index_new = 0; + unsigned n = 0; + + while (stream.ignore(numeric_limits<streamsize>::max(), delim).good()) + { + index_new = str.find(delim, index); + VERIFY( static_cast<string::size_type>(stream.gcount()) == + index_new - index + 1 ); + index = index_new + 1; + ++n; + } + VERIFY( stream.gcount() == 0 ); + VERIFY( !stream.fail() ); + VERIFY( n == nchunks ); +} + +void test01() +{ + const char filename[] = "istream_ignore.txt"; + + const char delim = '|'; + const unsigned nchunks = 10; + const string data = prepare(555, nchunks, delim); + + ofstream ofstrm; + ofstrm.open(filename); + ofstrm.write(data.data(), data.size()); + ofstrm.close(); + + ifstream ifstrm; + ifstrm.open(filename); + check(ifstrm, data, nchunks, delim); + ifstrm.close(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc new file mode 100644 index 000000000..218a21b54 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc @@ -0,0 +1,98 @@ +// 2004-06-20 Paolo Carlini <pcarlini@suse.de> + +// 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.3 unformatted input functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +// { dg-require-fileio "" } + +#include <istream> +#include <fstream> +#include <limits> +#include <testsuite_hooks.h> + +// istream& ignore(streamsize n) +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const char filename[] ="istream_unformatted-1.txt"; + ios_base::iostate state1, state2; + + ifstream ifstrm; + ifstrm.open(filename); + + state1 = ifstrm.rdstate(); + VERIFY( state1 == ios_base::goodbit ); + VERIFY( ifstrm.peek() == '1' ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(1); + VERIFY( ifstrm.gcount() == 1 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == '2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(10); + VERIFY( ifstrm.gcount() == 10 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == '1' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(100); + VERIFY( ifstrm.gcount() == 100 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == '2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(1000); + VERIFY( ifstrm.gcount() == 1000 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == '1' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(10000); + VERIFY( ifstrm.gcount() == 10000 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == '2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(numeric_limits<streamsize>::max()); + VERIFY( ifstrm.gcount() == 5389 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( state2 == ios_base::eofbit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc new file mode 100644 index 000000000..04f72a6b1 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/6360.cc @@ -0,0 +1,47 @@ +// 1999-08-11 bkoz + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// 2002-04-19 PR libstdc++ 6360 +void +test08() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + stringstream ss("abcd" "\xFF" "1234ina donna coolbrith"); + char c; + ss >> c; + VERIFY( c == 'a' ); + ss.ignore(8); + ss >> c; + VERIFY( c == 'i' ); +} + +int +main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc new file mode 100644 index 000000000..141832692 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/7220.cc @@ -0,0 +1,67 @@ +// 1999-08-11 bkoz + +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/70220 +void +test10() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef string string_type; + typedef stringbuf stringbuf_type; + typedef istream istream_type; + + streamsize n; + string_type input("abcdefg\n"); + stringbuf_type sbuf(input); + istream_type istr(&sbuf); + + istr.ignore(0); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(0, 'b'); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(); // Advance to next position. + istr.ignore(0, 'b'); + if ((n=istr.gcount()) != 0) + test = false; + VERIFY( test ); + + if (istr.peek() != 'b') + test = false; + VERIFY( test ); +} + +int +main() +{ + test10(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc new file mode 100644 index 000000000..c4a7a33d0 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2004, 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + typedef std::ios::traits_type traits_type; + + bool test __attribute__((unused)) = true; + const std::wstring str_01; + const std::wstring str_02(L"soul eyes: john coltrane quartet"); + std::wstring strtmp; + + std::wstringbuf isbuf_03(str_02, std::ios_base::in); + std::wstringbuf isbuf_04(str_02, std::ios_base::in); + + std::wistream is_00(0); + std::wistream is_03(&isbuf_03); + std::wistream is_04(&isbuf_04); + std::ios_base::iostate state1, state2; + + // istream& read(char_type* s, streamsize n) + wchar_t carray[60] = L""; + is_04.read(carray, 9); + VERIFY( is_04.peek() == L':' ); + + // istream& ignore(streamsize n = 1, int_type delim = traits::eof()) + state1 = is_04.rdstate(); + is_04.ignore(); + VERIFY( is_04.gcount() == 1 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == L' ' ); + + state1 = is_04.rdstate(); + is_04.ignore(0); + VERIFY( is_04.gcount() == 0 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == L' ' ); + + state1 = is_04.rdstate(); + is_04.ignore(5, traits_type::to_int_type(' ')); + VERIFY( is_04.gcount() == 1 ); + state2 = is_04.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( is_04.peek() == L'j' ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc new file mode 100644 index 000000000..8a2421041 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc @@ -0,0 +1,87 @@ +// Copyright (C) 2004, 2005, 2006, 2007, 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.3 unformatted input functions + +#include <istream> +#include <string> +#include <fstream> +#include <limits> +#include <cstdlib> +#include <testsuite_hooks.h> + +using namespace std; + +wstring +prepare(wstring::size_type len, unsigned nchunks, wchar_t delim) +{ + wstring ret; + for (unsigned i = 0; i < nchunks; ++i) + { + for (wstring::size_type j = 0; j < len; ++j) + ret.push_back(L'a' + rand() % 26); + len *= 2; + ret.push_back(delim); + } + return ret; +} + +void +check(wistream& stream, const wstring& str, unsigned nchunks, wchar_t delim) +{ + bool test __attribute__((unused)) = true; + + wstring::size_type index = 0, index_new = 0; + unsigned n = 0; + + while (stream.ignore(numeric_limits<streamsize>::max(), delim).good()) + { + index_new = str.find(delim, index); + VERIFY( static_cast<string::size_type>(stream.gcount()) == + index_new - index + 1 ); + index = index_new + 1; + ++n; + } + VERIFY( stream.gcount() == 0 ); + VERIFY( !stream.fail() ); + VERIFY( n == nchunks ); +} + +void test01() +{ + const char filename[] = "wistream_ignore.txt"; + + const wchar_t delim = L'|'; + const unsigned nchunks = 10; + const wstring data = prepare(555, nchunks, delim); + + wofstream ofstrm; + ofstrm.open(filename); + ofstrm.write(data.data(), data.size()); + ofstrm.close(); + + wifstream ifstrm; + ifstrm.open(filename); + check(ifstrm, data, nchunks, delim); + ifstrm.close(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc new file mode 100644 index 000000000..edd822df4 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc @@ -0,0 +1,94 @@ +// 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.3 unformatted input functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +#include <istream> +#include <fstream> +#include <limits> +#include <testsuite_hooks.h> + +// istream& ignore(streamsize n) +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const char filename[] ="istream_unformatted-1.txt"; + ios_base::iostate state1, state2; + + wifstream ifstrm; + ifstrm.open(filename); + + state1 = ifstrm.rdstate(); + VERIFY( state1 == ios_base::goodbit ); + VERIFY( ifstrm.peek() == L'1' ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(1); + VERIFY( ifstrm.gcount() == 1 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == L'2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(10); + VERIFY( ifstrm.gcount() == 10 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == L'1' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(100); + VERIFY( ifstrm.gcount() == 100 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == L'2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(1000); + VERIFY( ifstrm.gcount() == 1000 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == L'1' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(10000); + VERIFY( ifstrm.gcount() == 10000 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 == state2 ); + VERIFY( ifstrm.peek() == L'2' ); + + state1 = ifstrm.rdstate(); + ifstrm.ignore(numeric_limits<streamsize>::max()); + VERIFY( ifstrm.gcount() == 5389 ); + state2 = ifstrm.rdstate(); + VERIFY( state1 != state2 ); + VERIFY( state2 == ios_base::eofbit ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc new file mode 100644 index 000000000..3e837e8b7 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc @@ -0,0 +1,45 @@ +// 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// 2002-04-19 PR libstdc++ 6360 +void +test08() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + wstringstream ss(L"abcd" L"\xFF" L"1234ina donna coolbrith"); + wchar_t c; + ss >> c; + VERIFY( c == L'a' ); + ss.ignore(8); + ss >> c; + VERIFY( c == L'i' ); +} + +int +main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc new file mode 100644 index 000000000..d3d7f1ec0 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc @@ -0,0 +1,65 @@ +// 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.3 unformatted input functions + +#include <istream> +#include <sstream> +#include <testsuite_hooks.h> + +// libstdc++/70220 +void +test10() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef wstring string_type; + typedef wstringbuf stringbuf_type; + typedef wistream istream_type; + + streamsize n; + string_type input(L"abcdefg\n"); + stringbuf_type sbuf(input); + istream_type istr(&sbuf); + + istr.ignore(0); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(0, L'b'); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(); // Advance to next position. + istr.ignore(0, L'b'); + if ((n=istr.gcount()) != 0) + test = false; + VERIFY( test ); + + if (istr.peek() != L'b') + test = false; + VERIFY( test ); +} + +int +main() +{ + test10(); + return 0; +} |