]>
Commit | Line | Data |
---|---|---|
23cac885 BK |
1 | // 1999-08-16 bkoz |
2 | // 1999-11-01 bkoz | |
3 | ||
8fc81078 PC |
4 | // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010 |
5 | // Free Software Foundation | |
23cac885 BK |
6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
748086b7 | 10 | // Free Software Foundation; either version 3, or (at your option) |
23cac885 BK |
11 | // any later version. |
12 | ||
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
23cac885 BK |
21 | |
22 | // 27.6.2.5.4 basic_ostream character inserters | |
23 | // @require@ %-*.tst %-*.txt | |
24 | // @diff@ %-*.tst %-*.txt | |
25 | ||
0c20e4ec NS |
26 | // { dg-require-fileio "" } |
27 | ||
23cac885 BK |
28 | #include <ostream> |
29 | #include <sstream> | |
30 | #include <fstream> | |
31 | #include <testsuite_hooks.h> | |
32 | ||
33 | const int size = 1000; | |
34 | const char name_01[] = "ostream_inserter_other-1.tst"; | |
35 | const char name_02[] = "ostream_inserter_other-1.txt"; | |
36 | const char name_03[] = "ostream_inserter_other-2.tst"; | |
37 | const char name_04[] = "ostream_inserter_other-2.txt"; | |
38 | ||
39 | // fstream | |
40 | void | |
41 | test02() | |
42 | { | |
43 | typedef std::ios_base::iostate iostate; | |
11f10e6b | 44 | bool test __attribute__((unused)) = true; |
23cac885 BK |
45 | |
46 | // basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sb) | |
47 | // filebuf-> NULL | |
48 | std::ifstream f_in1(name_01); | |
49 | std::ofstream f_out1(name_02); | |
8fc81078 | 50 | std::stringbuf* strbuf01 = 0; |
23cac885 BK |
51 | iostate state01 = f_in1.rdstate(); |
52 | f_in1 >> strbuf01; | |
53 | iostate state02 = f_in1.rdstate(); | |
54 | VERIFY( state01 != state02 ); | |
55 | VERIFY( (state02 & std::ios_base::failbit) != 0 ); | |
56 | state01 = f_out1.rdstate(); | |
57 | f_out1 << strbuf01; | |
58 | state02 = f_out1.rdstate(); | |
59 | VERIFY( state01 != state02 ); | |
60 | VERIFY( (state02 & std::ios_base::badbit) != 0 ); | |
61 | ||
62 | // filebuf->filebuf | |
63 | std::ifstream f_in(name_01); | |
64 | std::ofstream f_out(name_02); | |
65 | f_out << f_in.rdbuf(); | |
66 | f_in.close(); | |
67 | f_out.close(); | |
68 | ||
69 | // filebuf->stringbuf->filebuf | |
70 | std::ifstream f_in2(name_03); | |
71 | std::ofstream f_out2(name_04); // should be different name | |
72 | std::stringbuf strbuf02; | |
73 | f_in2 >> &strbuf02; | |
74 | f_out2 << &strbuf02; | |
75 | f_in2.close(); | |
76 | f_out2.close(); | |
77 | } | |
78 | ||
79 | int | |
80 | main() | |
81 | { | |
82 | test02(); | |
83 | return 0; | |
84 | } |