4 // Copyright (C) 1999, 2000, 2001 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // 27.6.2.5.4 basic_ostream character inserters
23 // @require@ %-*.tst %-*.txt
24 // @diff@ %-*.tst %-*.txt
29 #include <testsuite_hooks.h>
31 const int size
= 1000;
32 const char name_01
[] = "ostream_inserter_other-1.tst";
33 const char name_02
[] = "ostream_inserter_other-1.txt";
34 const char name_03
[] = "ostream_inserter_other-2.tst";
35 const char name_04
[] = "ostream_inserter_other-2.txt";
53 typedef std::ios_base::iostate iostate
;
56 // basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sb)
58 std::ifstream
f_in1(name_01
);
59 std::ofstream
f_out1(name_02
);
60 std::stringbuf
* strbuf01
= NULL
;
61 iostate state01
= f_in1
.rdstate();
63 iostate state02
= f_in1
.rdstate();
64 VERIFY( state01
!= state02
);
65 VERIFY( (state02
& std::ios_base::failbit
) != 0 );
66 state01
= f_out1
.rdstate();
68 state02
= f_out1
.rdstate();
69 VERIFY( state01
!= state02
);
70 VERIFY( (state02
& std::ios_base::failbit
) != 0 );
73 std::ifstream
f_in(name_01
);
74 std::ofstream
f_out(name_02
);
75 f_out
<< f_in
.rdbuf();
79 // filebuf->stringbuf->filebuf
80 std::ifstream
f_in2(name_03
);
81 std::ofstream
f_out2(name_04
); // should be different name
82 std::stringbuf strbuf02
;
88 // no characters inserted
97 // via Brent Verner <brent@rcfile.org>
98 // http://gcc.gnu.org/ml/libstdc++/2000-06/msg00005.html
104 typedef ios::pos_type pos_type
;
106 const char* TEST_IN
= "ostream_inserter_other_in";
107 const char* TEST_OUT
= "ostream_inserter_other_out";
108 pos_type i_read
, i_wrote
, rs
, ws
;
109 double tf_size
= BUFSIZ
* 2.5;
110 ofstream
testfile(TEST_IN
);
112 for (int i
= 0; i
< tf_size
; ++i
)
116 ifstream
in(TEST_IN
);
117 ofstream
out(TEST_OUT
);
119 in
.seekg(0,ios_base::beg
);
120 out
.seekp(0,ios_base::beg
);
123 in
.seekg(0,ios_base::end
);
124 out
.seekp(0,ios_base::end
);
125 i_read
= in
.tellg() - rs
;
126 i_wrote
= out
.tellp() - ws
;
131 assert(i_read
== i_wrote
);
142 istringstream
istr("inside betty carter");
144 ostr
<< istr
.rdbuf() << endl
;
146 if (ostr
.rdstate() & ios_base::eofbit
)