]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/1.cc
4 // Copyright (C) 1999-2016 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 27.6.2.5.4 basic_ostream character inserters
22 // @require@ %-*.tst %-*.txt
23 // @diff@ %-*.tst %-*.txt
25 // { dg-require-fileio "" }
30 #include <testsuite_hooks.h>
32 const int size
= 1000;
33 const char name_01
[] = "ostream_inserter_other-1.tst";
34 const char name_02
[] = "ostream_inserter_other-1.txt";
35 const char name_03
[] = "ostream_inserter_other-2.tst";
36 const char name_04
[] = "ostream_inserter_other-2.txt";
42 typedef std::ios_base::iostate iostate
;
43 bool test
__attribute__((unused
)) = true;
45 // basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sb)
47 std::ifstream
f_in1(name_01
);
48 std::ofstream
f_out1(name_02
);
49 std::stringbuf
* strbuf01
= 0;
50 iostate state01
= f_in1
.rdstate();
52 iostate state02
= f_in1
.rdstate();
53 VERIFY( state01
!= state02
);
54 VERIFY( (state02
& std::ios_base::failbit
) != 0 );
55 state01
= f_out1
.rdstate();
57 state02
= f_out1
.rdstate();
58 VERIFY( state01
!= state02
);
59 VERIFY( (state02
& std::ios_base::badbit
) != 0 );
62 std::ifstream
f_in(name_01
);
63 std::ofstream
f_out(name_02
);
64 f_out
<< f_in
.rdbuf();
68 // filebuf->stringbuf->filebuf
69 std::ifstream
f_in2(name_03
);
70 std::ofstream
f_out2(name_04
); // should be different name
71 std::stringbuf strbuf02
;