2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_istream / ws / char / 1.cc
blob00f5798ef5a3be3a9d6a0b26eced8cd1b7dd7b44
1 // 1999-07-22 bkoz
3 // Copyright (C) 1994, 1999, 2001, 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 // 27.6.1.4 standard basic_istream manipulators
23 #include <istream>
24 #include <sstream>
25 #include <stdexcept>
26 #include <testsuite_hooks.h>
28 void test01(void)
30 bool test __attribute__((unused)) = true;
32 const char str_lit01[] = " venice ";
33 const std::string str01(" santa barbara ");
34 std::string str02(str_lit01);
35 std::string str04;
36 std::string str05;
37 std::ios_base::iostate flag3, flag4, flag5;
39 // template<_CharT, _Traits>
40 // basic_istream<_CharT, _Traits>& ws(basic_istream<_Char, _Traits>& is)
41 std::istringstream iss01(str01);
42 std::istringstream iss02(str01);
44 iss01 >> str04;
45 VERIFY( str04.size() != str01.size() );
46 VERIFY( str04 == "santa" );
48 iss02 >> std::ws;
49 iss02 >> str05;
50 VERIFY( str05.size() != str01.size() );
51 VERIFY( str05 == "santa" );
52 VERIFY( str05 == str04 );
54 iss01 >> str04;
55 VERIFY( str04.size() != str01.size() );
56 VERIFY( str04 == "barbara" );
58 iss02 >> std::ws;
59 iss02 >> str05;
60 VERIFY( str05.size() != str01.size() );
61 VERIFY( str05 == "barbara" );
62 VERIFY( str05 == str04 );
64 flag3 = std::ios_base::eofbit;
65 flag4 = std::ios_base::badbit;
66 flag5 = std::ios_base::failbit;
67 VERIFY( !iss01.fail() );
68 VERIFY( !iss02.fail() );
69 VERIFY( !iss01.eof() );
70 VERIFY( !iss02.eof() );
72 iss01 >> std::ws;
73 VERIFY( !iss01.fail() );
74 VERIFY( iss01.eof() );
77 int main()
79 test01();
80 return 0;