1 // 2004-06-20 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2004 Free Software Foundation
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // 27.6.1.3 unformatted input functions
22 // @require@ %-*.tst %-*.txt
23 // @diff@ %-*.tst %-*.txt
25 // { dg-require-fileio "" }
30 #include <testsuite_hooks.h>
32 // istream& ignore(streamsize n)
37 bool test __attribute__((unused)) = true;
39 const char filename[] ="istream_unformatted-1.txt";
40 ios_base::iostate state1, state2;
43 ifstrm.open(filename);
45 state1 = ifstrm.rdstate();
46 VERIFY( state1 == ios_base::goodbit );
47 VERIFY( ifstrm.peek() == '1' );
48 state2 = ifstrm.rdstate();
49 VERIFY( state1 == state2 );
51 state1 = ifstrm.rdstate();
53 VERIFY( ifstrm.gcount() == 1 );
54 state2 = ifstrm.rdstate();
55 VERIFY( state1 == state2 );
56 VERIFY( ifstrm.peek() == '2' );
58 state1 = ifstrm.rdstate();
60 VERIFY( ifstrm.gcount() == 10 );
61 state2 = ifstrm.rdstate();
62 VERIFY( state1 == state2 );
63 VERIFY( ifstrm.peek() == '1' );
65 state1 = ifstrm.rdstate();
67 VERIFY( ifstrm.gcount() == 100 );
68 state2 = ifstrm.rdstate();
69 VERIFY( state1 == state2 );
70 VERIFY( ifstrm.peek() == '2' );
72 state1 = ifstrm.rdstate();
74 VERIFY( ifstrm.gcount() == 1000 );
75 state2 = ifstrm.rdstate();
76 VERIFY( state1 == state2 );
77 VERIFY( ifstrm.peek() == '1' );
79 state1 = ifstrm.rdstate();
81 VERIFY( ifstrm.gcount() == 10000 );
82 state2 = ifstrm.rdstate();
83 VERIFY( state1 == state2 );
84 VERIFY( ifstrm.peek() == '2' );
86 state1 = ifstrm.rdstate();
87 ifstrm.ignore(numeric_limits<streamsize>::max());
88 VERIFY( ifstrm.gcount() == 5389 );
89 state2 = ifstrm.rdstate();
90 VERIFY( state1 != state2 );
91 VERIFY( state2 == ios_base::eofbit );