3 // Copyright (C) 1999-2024 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 std::string
str_01("jade cove, big sur");
31 std::stringbuf strb_01
;
32 std::stringbuf
strb_02(str_01
, std::ios_base::in
);
33 std::stringbuf
strb_03(str_01
, std::ios_base::out
);
34 const std::ios_base::fmtflags flag01
= std::ios_base::skipws
|
36 std::ios_base::fmtflags flag02
;
37 const std::locale glocale
= std::locale();
39 // explicit basic_ios(streambuf* sb)
41 std::ios
ios_01(&strb_01
);
42 std::ios
ios_02(&strb_02
);
43 std::ios
ios_03(&strb_03
);
46 // NB: This is protected so need to go through fstream
48 // void init(sreambuf* sb)
49 // NB: This is protected so need to go through fstream/stringstream
50 // Can double-check the accuracy of the above initializations though.
51 VERIFY( ios_00
.rdbuf() == 0 );
52 VERIFY( ios_00
.tie() == 0 );
53 VERIFY( ios_00
.rdstate() == std::ios_base::badbit
);
54 VERIFY( ios_00
.exceptions() == std::ios_base::goodbit
);
55 flag02
= ios_00
.flags();
56 VERIFY( flag02
== flag01
);
57 VERIFY( ios_00
.width() == 0 );
58 VERIFY( ios_00
.precision() == 6 );
59 VERIFY( ios_00
.fill() == ios_00
.widen(' ') );
60 VERIFY( ios_00
.getloc() == glocale
);
62 VERIFY( ios_01
.rdbuf() == &strb_01
);
63 VERIFY( ios_01
.tie() == 0 );
64 VERIFY( ios_01
.rdstate() == std::ios_base::goodbit
);
65 VERIFY( ios_01
.exceptions() == std::ios_base::goodbit
);
66 flag02
= ios_01
.flags();
67 VERIFY( flag02
== flag01
);
68 VERIFY( ios_01
.width() == 0 );
69 VERIFY( ios_01
.precision() == 6 );
70 VERIFY( ios_01
.fill() == ios_01
.widen(' ') );
71 VERIFY( ios_01
.getloc() == glocale
);