]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/ios_ctor.cc
*.cc: Remove spaces, make sure testcases return zero.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / ios_ctor.cc
CommitLineData
b2dad0e3
BK
1// 1999-07-23 bkoz
2
3// Copyright (C) 1999 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.
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 COPYING. If not, write to the Free
18// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19// USA.
20
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.
29
30// 27.4.4.1 basic_ios constructors
31
32#include <ios>
33#include <sstream>
aa1b2f7d 34#include <debug_assert.h>
b2dad0e3
BK
35
36void test01()
37{
38 bool test = 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, flag03;
47 const std::locale glocale = std::locale();
48
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);
54
55 // basic_ios()
56 // NB: This is protected so need to go through fstream
57
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.
aa1b2f7d
BV
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 );
b2dad0e3 65 flag02 = ios_00.flags();
aa1b2f7d
BV
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 );
b2dad0e3 71
aa1b2f7d
BV
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 );
b2dad0e3 76 flag02 = ios_01.flags();
aa1b2f7d
BV
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 );
b2dad0e3
BK
82
83#ifdef DEBUG_ASSERT
84 assert(test);
85#endif
86}
87
88int main() {
89 test01();
90 return 0;
91}