]>
Commit | Line | Data |
---|---|---|
aa33d725 PC |
1 | // 2004-06-20 Paolo Carlini <pcarlini@suse.de> |
2 | ||
3 | // Copyright (C) 2004 Free Software Foundation | |
4 | // | |
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) | |
9 | // any later version. | |
10 | ||
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. | |
15 | ||
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 | |
83f51799 | 18 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
aa33d725 PC |
19 | // USA. |
20 | ||
21 | // 27.6.1.3 unformatted input functions | |
22 | // @require@ %-*.tst %-*.txt | |
23 | // @diff@ %-*.tst %-*.txt | |
24 | ||
0c20e4ec NS |
25 | // { dg-require-fileio "" } |
26 | ||
aa33d725 PC |
27 | #include <istream> |
28 | #include <fstream> | |
29 | #include <limits> | |
30 | #include <testsuite_hooks.h> | |
31 | ||
32 | // istream& ignore(streamsize n) | |
33 | void | |
34 | test01() | |
35 | { | |
36 | using namespace std; | |
37 | bool test __attribute__((unused)) = true; | |
38 | ||
39 | const char filename[] ="istream_unformatted-1.txt"; | |
40 | ios_base::iostate state1, state2; | |
41 | ||
42 | ifstream ifstrm; | |
43 | ifstrm.open(filename); | |
44 | ||
45 | state1 = ifstrm.rdstate(); | |
46 | VERIFY( state1 == ios_base::goodbit ); | |
47 | VERIFY( ifstrm.peek() == '1' ); | |
48 | state2 = ifstrm.rdstate(); | |
49 | VERIFY( state1 == state2 ); | |
50 | ||
51 | state1 = ifstrm.rdstate(); | |
52 | ifstrm.ignore(1); | |
53 | VERIFY( ifstrm.gcount() == 1 ); | |
54 | state2 = ifstrm.rdstate(); | |
55 | VERIFY( state1 == state2 ); | |
56 | VERIFY( ifstrm.peek() == '2' ); | |
57 | ||
58 | state1 = ifstrm.rdstate(); | |
59 | ifstrm.ignore(10); | |
60 | VERIFY( ifstrm.gcount() == 10 ); | |
61 | state2 = ifstrm.rdstate(); | |
62 | VERIFY( state1 == state2 ); | |
63 | VERIFY( ifstrm.peek() == '1' ); | |
64 | ||
65 | state1 = ifstrm.rdstate(); | |
66 | ifstrm.ignore(100); | |
67 | VERIFY( ifstrm.gcount() == 100 ); | |
68 | state2 = ifstrm.rdstate(); | |
69 | VERIFY( state1 == state2 ); | |
70 | VERIFY( ifstrm.peek() == '2' ); | |
71 | ||
72 | state1 = ifstrm.rdstate(); | |
73 | ifstrm.ignore(1000); | |
74 | VERIFY( ifstrm.gcount() == 1000 ); | |
75 | state2 = ifstrm.rdstate(); | |
76 | VERIFY( state1 == state2 ); | |
77 | VERIFY( ifstrm.peek() == '1' ); | |
78 | ||
79 | state1 = ifstrm.rdstate(); | |
80 | ifstrm.ignore(10000); | |
81 | VERIFY( ifstrm.gcount() == 10000 ); | |
82 | state2 = ifstrm.rdstate(); | |
83 | VERIFY( state1 == state2 ); | |
84 | VERIFY( ifstrm.peek() == '2' ); | |
85 | ||
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 ); | |
92 | } | |
93 | ||
94 | int | |
95 | main() | |
96 | { | |
97 | test01(); | |
98 | return 0; | |
99 | } |