]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_istringstream/str/wchar_t/1.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_istringstream / str / wchar_t / 1.cc
1 // Copyright (C) 2004-2014 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // 27.7.2.2 member functions (istringstream_members)
19
20 #include <sstream>
21 #include <testsuite_hooks.h>
22
23 void test01()
24 {
25 bool test __attribute__((unused)) = true;
26 std::wistringstream is01;
27 const std::wstring str00;
28 const std::wstring str01 = L"123";
29 std::wstring str02;
30 const int i01 = 123;
31 int a = 0, b = 0;
32
33 std::ios_base::iostate state1, state2, stateeof;
34 stateeof = std::ios_base::eofbit;
35
36 // string str() const
37 str02 = is01.str();
38 VERIFY( str00 == str02 );
39
40 // void str(const basic_string&)
41 is01.str(str01);
42 str02 = is01.str();
43 VERIFY( str01 == str02 );
44 state1 = is01.rdstate();
45 is01 >> a;
46 state2 = is01.rdstate();
47 VERIFY( a == i01 );
48 // 22.2.2.1.2 num_get virtual functions
49 // p 13
50 // in any case, if stage 2 processing was terminated by the test for
51 // in == end then err != ios_base::eofbit is performed.
52 VERIFY( state1 != state2 );
53 VERIFY( state2 == stateeof );
54
55 is01.str(str01);
56 is01 >> b;
57 VERIFY( b != a );
58 // as is01.good() is false, istream::sentry blocks extraction.
59
60 is01.clear();
61 state1 = is01.rdstate();
62 is01 >> b;
63 state2 = is01.rdstate();
64 VERIFY( b == a );
65 VERIFY( state1 != state2 );
66 VERIFY( state2 == stateeof );
67 }
68
69 int main()
70 {
71 test01();
72 return 0;
73 }