]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ios/cons/char/1.cc
3 // Copyright (C) 1999-2016 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // 27.4.4.1 basic_ios constructors
25 #include <testsuite_hooks.h>
29 bool test
__attribute__((unused
)) = true;
30 std::string
str_01("jade cove, big sur");
32 std::stringbuf strb_01
;
33 std::stringbuf
strb_02(str_01
, std::ios_base::in
);
34 std::stringbuf
strb_03(str_01
, std::ios_base::out
);
35 const std::ios_base::fmtflags flag01
= std::ios_base::skipws
|
37 std::ios_base::fmtflags flag02
;
38 const std::locale glocale
= std::locale();
40 // explicit basic_ios(streambuf* sb)
42 std::ios
ios_01(&strb_01
);
43 std::ios
ios_02(&strb_02
);
44 std::ios
ios_03(&strb_03
);
47 // NB: This is protected so need to go through fstream
49 // void init(sreambuf* sb)
50 // NB: This is protected so need to go through fstream/stringstream
51 // Can double-check the accuracy of the above initializations though.
52 VERIFY( ios_00
.rdbuf() == 0 );
53 VERIFY( ios_00
.tie() == 0 );
54 VERIFY( ios_00
.rdstate() == std::ios_base::badbit
);
55 VERIFY( ios_00
.exceptions() == std::ios_base::goodbit
);
56 flag02
= ios_00
.flags();
57 VERIFY( flag02
== flag01
);
58 VERIFY( ios_00
.width() == 0 );
59 VERIFY( ios_00
.precision() == 6 );
60 VERIFY( ios_00
.fill() == ios_00
.widen(' ') );
61 VERIFY( ios_00
.getloc() == glocale
);
63 VERIFY( ios_01
.rdbuf() == &strb_01
);
64 VERIFY( ios_01
.tie() == 0 );
65 VERIFY( ios_01
.rdstate() == std::ios_base::goodbit
);
66 VERIFY( ios_01
.exceptions() == std::ios_base::goodbit
);
67 flag02
= ios_01
.flags();
68 VERIFY( flag02
== flag01
);
69 VERIFY( ios_01
.width() == 0 );
70 VERIFY( ios_01
.precision() == 6 );
71 VERIFY( ios_01
.fill() == ios_01
.widen(' ') );
72 VERIFY( ios_01
.getloc() == glocale
);