2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ios / cons / char / 1.cc
blobb3e0624a5debd5626b9f835bb6b0a2fb0ce3d489
1 // 1999-07-23 bkoz
3 // Copyright (C) 1999, 2003 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 2, or (at your option)
9 // any later version.
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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // 27.4.4.1 basic_ios constructors
32 #include <ios>
33 #include <sstream>
34 #include <testsuite_hooks.h>
36 void test01()
38 bool test __attribute__((unused)) = true;
39 std::string str_01("jade cove, big sur");
40 std::string str_05;
41 std::stringbuf strb_01;
42 std::stringbuf strb_02(str_01, std::ios_base::in);
43 std::stringbuf strb_03(str_01, std::ios_base::out);
44 const std::ios_base::fmtflags flag01 = std::ios_base::skipws |
45 std::ios_base::dec;
46 std::ios_base::fmtflags flag02;
47 const std::locale glocale = std::locale();
49 // explicit basic_ios(streambuf* sb)
50 std::ios ios_00(0);
51 std::ios ios_01(&strb_01);
52 std::ios ios_02(&strb_02);
53 std::ios ios_03(&strb_03);
55 // basic_ios()
56 // NB: This is protected so need to go through fstream
58 // void init(sreambuf* sb)
59 // NB: This is protected so need to go through fstream/stringstream
60 // Can double-check the accuracy of the above initializations though.
61 VERIFY( ios_00.rdbuf() == 0 );
62 VERIFY( ios_00.tie() == 0 );
63 VERIFY( ios_00.rdstate() == std::ios_base::badbit );
64 VERIFY( ios_00.exceptions() == std::ios_base::goodbit );
65 flag02 = ios_00.flags();
66 VERIFY( flag02 == flag01 );
67 VERIFY( ios_00.width() == 0 );
68 VERIFY( ios_00.precision() == 6 );
69 VERIFY( ios_00.fill() == ios_00.widen(' ') );
70 VERIFY( ios_00.getloc() == glocale );
72 VERIFY( ios_01.rdbuf() == &strb_01 );
73 VERIFY( ios_01.tie() == 0 );
74 VERIFY( ios_01.rdstate() == std::ios_base::goodbit );
75 VERIFY( ios_01.exceptions() == std::ios_base::goodbit );
76 flag02 = ios_01.flags();
77 VERIFY( flag02 == flag01 );
78 VERIFY( ios_01.width() == 0 );
79 VERIFY( ios_01.precision() == 6 );
80 VERIFY( ios_01.fill() == ios_01.widen(' ') );
81 VERIFY( ios_01.getloc() == glocale );
84 int main()
86 test01();
87 return 0;