]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/objects/wchar_t/5.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / objects / wchar_t / 5.cc
CommitLineData
51ff8149
BK
1// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
2
5624e564 3// Copyright (C) 2003-2015 Free Software Foundation, Inc.
51ff8149
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
51ff8149
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
51ff8149
BK
19
20// 27.3 Standard iostream objects
21
22// Check that standard streams can be used from constructors and
23// destructors of static objects, provided that an instance of
24// ios_base::Init has been constructed.
25
26void init_standard_streams();
27int use_standard_streams();
28
29struct Strange
30{
31 int i;
32
33 Strange()
34 {
35 init_standard_streams();
36 i = use_standard_streams();
37 }
38
39 ~Strange()
40 {
41 use_standard_streams();
42 init_standard_streams();
43 }
44};
45
46static Strange static_ob;
47
48#include <testsuite_hooks.h>
49#include <iostream>
50
51void init_standard_streams()
52{
53 std::ios_base::Init init;
54}
55
56int use_standard_streams()
57{
58 std::wcout << L"Hello, world!" << std::endl;
59 std::wcerr << L"World, hello!" << std::endl;
60
61 int ret = std::ios_base::xalloc();
62 std::wcin.iword(ret) = ret + 1;
63 std::wcout.iword(ret) = ret + 2;
64 std::wcerr.iword(ret) = ret + 3;
65 std::wclog.iword(ret) = ret + 4;
66 return ret;
67}
68
69void test05()
70{
11f10e6b 71 bool test __attribute__((unused)) = true;
51ff8149
BK
72 int i = static_ob.i;
73
74 VERIFY( std::wcin.iword(i) == i + 1 );
75 VERIFY( std::wcout.iword(i) == i + 2 );
76 VERIFY( std::wcerr.iword(i) == i + 3 );
77 VERIFY( std::wclog.iword(i) == i + 4 );
78}
79
80int main()
81{
82 test05();
83 return 0;
84}