OLD | NEW |
| (Empty) |
1 // 1999-07-23 bkoz | |
2 | |
3 // Copyright (C) 1999, 2003, 2009 Free Software Foundation, Inc. | |
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 | |
8 // Free Software Foundation; either version 3, or (at your option) | |
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 | |
17 // with this library; see the file COPYING3. If not see | |
18 // <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 // 27.4.4.1 basic_ios constructors | |
22 | |
23 #include <ios> | |
24 #include <sstream> | |
25 #include <testsuite_hooks.h> | |
26 | |
27 void test01() | |
28 { | |
29 bool test __attribute__((unused)) = true; | |
30 std::string str_01("jade cove, big sur"); | |
31 std::string str_05; | |
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 | | |
36 std::ios_base::dec; | |
37 std::ios_base::fmtflags flag02; | |
38 const std::locale glocale = std::locale(); | |
39 | |
40 // explicit basic_ios(streambuf* sb) | |
41 std::ios ios_00(0); | |
42 std::ios ios_01(&strb_01); | |
43 std::ios ios_02(&strb_02); | |
44 std::ios ios_03(&strb_03); | |
45 | |
46 // basic_ios() | |
47 // NB: This is protected so need to go through fstream | |
48 | |
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 ); | |
62 | |
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 ); | |
73 } | |
74 | |
75 int main() | |
76 { | |
77 test01(); | |
78 return 0; | |
79 } | |
OLD | NEW |