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. --- .../27_io/basic_istream/ignore/wchar_t/1.cc | 75 +++++++++++++++++ .../27_io/basic_istream/ignore/wchar_t/2.cc | 87 ++++++++++++++++++++ .../27_io/basic_istream/ignore/wchar_t/3.cc | 94 ++++++++++++++++++++++ .../27_io/basic_istream/ignore/wchar_t/6360.cc | 45 +++++++++++ .../27_io/basic_istream/ignore/wchar_t/7220.cc | 65 +++++++++++++++ 5 files changed, 366 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/6360.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/7220.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t') 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 +// . + +// 27.6.1.3 unformatted input functions + +#include +#include +#include + +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 +// . + +// 27.6.1.3 unformatted input functions + +#include +#include +#include +#include +#include +#include + +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::max(), delim).good()) + { + index_new = str.find(delim, index); + VERIFY( static_cast(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 +// . + +// 27.6.1.3 unformatted input functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +#include +#include +#include +#include + +// 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::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 +// . + +// 27.6.1.3 unformatted input functions + +#include +#include +#include + +// 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 +// . + +// 27.6.1.3 unformatted input functions + +#include +#include +#include + +// 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; +} -- cgit v1.2.3