]>
Commit | Line | Data |
---|---|---|
51ff8149 BK |
1 | // 2003-05-03 Petur Runolfsson <peturr02@ru.is> |
2 | ||
a945c346 | 3 | // Copyright (C) 2003-2024 Free Software Foundation, Inc. |
51ff8149 BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
51ff8149 BK |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
51ff8149 BK |
19 | |
20 | // 27.8.1.4 Overridden virtual functions | |
21 | ||
0c20e4ec | 22 | // { dg-require-fileio "" } |
687dc787 | 23 | // { dg-additional-files "filebuf_virtuals-1.txt" } |
0c20e4ec | 24 | |
51ff8149 BK |
25 | #include <fstream> |
26 | #include <string> | |
27 | #include <testsuite_hooks.h> | |
28 | ||
29 | class MyTraits : public std::char_traits<char> | |
30 | { | |
31 | }; | |
32 | ||
33 | // libstdc++/10096 | |
34 | void test01() | |
35 | { | |
36 | using namespace std; | |
37 | ||
38 | const char* name = "filebuf_virtuals-1.txt"; | |
39 | ||
40 | string str; | |
41 | filebuf fb1; | |
42 | fb1.open(name, ios_base::in); | |
43 | ||
44 | filebuf::int_type c1; | |
45 | while ((c1 = fb1.sbumpc()) != filebuf::traits_type::eof()) | |
46 | str.push_back(filebuf::traits_type::to_char_type(c1)); | |
47 | fb1.close(); | |
48 | ||
49 | basic_filebuf<char, MyTraits> fb; | |
50 | VERIFY( fb.sgetc() == MyTraits::eof() ); | |
51 | ||
52 | fb.open(name, ios_base::in); | |
53 | VERIFY( fb.is_open() ); | |
54 | ||
55 | for (string::iterator i = str.begin(); i != str.end(); ++i) | |
56 | { | |
57 | MyTraits::int_type c2 = fb.sbumpc(); | |
58 | VERIFY( c2 != MyTraits::eof() ); | |
59 | VERIFY( c2 == MyTraits::to_int_type(*i) ); | |
60 | } | |
61 | ||
62 | VERIFY( fb.sgetc() == MyTraits::eof() ); | |
63 | fb.close(); | |
64 | VERIFY( !fb.is_open() ); | |
65 | VERIFY( fb.sgetc() == MyTraits::eof() ); | |
66 | } | |
67 | ||
68 | int main() | |
69 | { | |
70 | test01(); | |
71 | return 0; | |
72 | } |