Debian Codegraph @

libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/2.cc

raw
1 // 1999-08-16 bkoz
2 // 1999-11-01 bkoz
3
4 // Copyright (C) 1999-2025 Free Software Foundation, Inc.
5 //
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)
10 // any later version.
11
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.
16
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/>.
20
21 // C++98 27.6.2.5.3 basic_ostream inserters
22
23 // { dg-final { file-io-diff "ostream_inserter_other_in" "ostream_inserter_other_out" } }
24
25 #include <ostream>
26 #include <fstream>
27 #include <testsuite_hooks.h>
28
29 // via Brent Verner <[email protected]>
30 // http://gcc.gnu.org/ml/libstdc++/2000-06/msg00005.html
31 void
32 test03(void)
33 {
34 using namespace std;
35
36 typedef ios::pos_type pos_type;
37
38 const char* TEST_IN = "ostream_inserter_other_in";
39 const char* TEST_OUT = "ostream_inserter_other_out";
40 pos_type i_read, i_wrote, rs, ws;
41 double tf_size = BUFSIZ * 2.5;
42 ofstream testfile(TEST_IN);
43
44 for (int i = 0; i < tf_size; ++i)
45 testfile.put('.');
46 testfile.close();
47
48 ifstream in(TEST_IN);
49 ofstream out(TEST_OUT);
50 out << in.rdbuf();
51 in.seekg(0, ios_base::beg);
52 out.seekp(0, ios_base::beg);
53 rs = in.tellg();
54 ws = out.tellp();
55 in.seekg(0, ios_base::end);
56 out.seekp(0, ios_base::end);
57 i_read = in.tellg() - rs;
58 i_wrote = out.tellp() - ws;
59 VERIFY( i_read == i_wrote );
60 in.close();
61 out.close();
62 }
63
64 int
65 main()
66 {
67 test03();
68 return 0;
69 }