]>
Commit | Line | Data |
---|---|---|
ba4b172f PC |
1 | // Copyright (C) 2005 Free Software Foundation, Inc. |
2 | // | |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 2, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING. If not, write to the Free | |
83f51799 | 16 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
ba4b172f PC |
17 | // USA. |
18 | ||
19 | // 27.6.2.6 Unformatted output functions | |
20 | // | |
21 | // _GLIBCXX_RESOLVE_LIB_DEFECTS | |
22 | // DR 60. What is a formatted input function? | |
23 | // basic_ostream::flush() does not behave as an unformatted output function. | |
24 | ||
25 | #include <ostream> | |
26 | #include <testsuite_hooks.h> | |
27 | #include <testsuite_io.h> | |
28 | ||
29 | void test02() | |
30 | { | |
31 | bool test __attribute__((unused)) = true; | |
32 | ||
33 | __gnu_test::sync_wstreambuf buf; | |
34 | std::wostream os(&buf); | |
35 | ||
36 | __gnu_test::sync_wstreambuf buf_tie; | |
37 | std::wostream os_tie(&buf_tie); | |
38 | ||
39 | // No sentry should be constructed so os.tie()->flush() should not be | |
40 | // called. | |
41 | os.tie(&os_tie); | |
42 | ||
43 | os.flush(); | |
44 | ||
45 | VERIFY( os.good() ); | |
46 | VERIFY( buf.sync_called() ); | |
47 | VERIFY( !buf_tie.sync_called() ); | |
48 | ||
49 | // os.rdbuf()->pubsync() should be called even if !os.good(). | |
50 | os.setstate(std::ios_base::eofbit); | |
51 | ||
52 | os.flush(); | |
53 | ||
54 | VERIFY( os.rdstate() == std::ios_base::eofbit ); | |
55 | VERIFY( buf.sync_called() ); | |
56 | VERIFY( !buf_tie.sync_called() ); | |
57 | } | |
58 | ||
59 | int main() | |
60 | { | |
61 | test02(); | |
62 | return 0; | |
63 | } | |
64 |