| 1 |
// Copyright (C) 2004-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// C++98 27.6.1.3 unformatted input functions |
| 19 |
|
| 20 |
// { dg-require-fileio "" } |
| 21 |
// { dg-additional-files "istream_unformatted-1.tst" } |
| 22 |
// { dg-additional-files "istream_unformatted-1.txt" } |
| 23 |
// Reading the .txt file should not alter it: |
| 24 |
// { dg-final { file-io-diff "istream_unformatted-1" } } |
| 25 |
|
| 26 |
#include <istream> |
| 27 |
#include <sstream> |
| 28 |
#include <fstream> |
| 29 |
#include <testsuite_hooks.h> |
| 30 |
|
| 31 |
//libstdc++/92: Bug in istream::get(basic_streambuf*) |
| 32 |
// bug reported by [email protected] |
| 33 |
// http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html |
| 34 |
void |
| 35 |
test07() |
| 36 |
{ |
| 37 |
const char* tfn = "istream_unformatted-1.txt"; |
| 38 |
std::wifstream infile; |
| 39 |
infile.open(tfn); |
| 40 |
VERIFY( !(!infile) ); |
| 41 |
while (infile) |
| 42 |
{ |
| 43 |
std::wstring line; |
| 44 |
std::wostringstream line_ss; |
| 45 |
while (infile.peek() == L'\n') |
| 46 |
infile.get(); |
| 47 |
infile.get(*(line_ss.rdbuf())); |
| 48 |
line = line_ss.str(); |
| 49 |
VERIFY( line == L"1234567890" || line == L"" ); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
int |
| 54 |
main() |
| 55 |
{ |
| 56 |
test07(); |
| 57 |
return 0; |
| 58 |
} |