]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/1.cc
898c12bb654ae379240a82274121b7c147313a44
1 // Copyright (C) 2004-2013 Free Software Foundation, Inc.
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)
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.
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/>.
18 // 27.6.1.3 unformatted input functions
22 #include <testsuite_hooks.h>
27 typedef std::char_traits
<wchar_t> traits_type
;
29 bool test
__attribute__((unused
)) = true;
30 const wchar_t str_lit01
[] =
31 L
" sun*ra \n\t\t\t & his arkestra, featuring john gilmore: \n"
33 L
"jazz in silhouette: images and forecasts of tomorrow";
35 std::wstring
str01(str_lit01
);
38 std::wstringbuf sbuf_03
;
39 std::wstringbuf
sbuf_04(str01
, std::ios_base::in
);
40 std::wstringbuf
sbuf_05(str01
, std::ios_base::in
);
42 std::wistream
is_00(0);
43 std::wistream
is_04(&sbuf_04
);
44 std::wistream
is_05(&sbuf_05
);
45 std::ios_base::iostate statefail
, stateeof
;
46 statefail
= std::ios_base::failbit
;
47 stateeof
= std::ios_base::eofbit
;
48 wchar_t carray1
[400] = L
"";
51 // istream& get(wchar_t*, streamsize, wchar_t delim)
52 // istream& get(wchar_t*, streamsize)
53 // istream& get(streambuf&, wchar_t delim)
54 // istream& get(streambuf&)
55 is_00
.get(carray1
, 2);
56 VERIFY( static_cast<bool>(is_00
.rdstate() & statefail
) );
57 VERIFY( is_00
.gcount() == 0 );
59 is_04
.get(carray1
, 4);
60 VERIFY( !(is_04
.rdstate() & statefail
) );
61 VERIFY( !traits_type::compare(carray1
, L
" ", 4) );
62 VERIFY( is_04
.gcount() == 3 );
65 is_04
.get(carray1
+ 3, 200);
66 VERIFY( !(is_04
.rdstate() & statefail
) );
67 VERIFY( !(is_04
.rdstate() & stateeof
) );
68 VERIFY( !traits_type::compare(carray1
, str_lit01
, 10) );
69 VERIFY( is_04
.gcount() == 7 );
72 is_04
.get(carray1
, 200);
73 VERIFY( !(is_04
.rdstate() & stateeof
) );
74 VERIFY( static_cast<bool>(is_04
.rdstate() & statefail
) ); // delimiter
75 VERIFY( is_04
.gcount() == 0 );
77 is_04
.get(carray1
, 200, L
'[');
78 VERIFY( static_cast<bool>(is_04
.rdstate() & stateeof
) );
79 VERIFY( !(is_04
.rdstate() & statefail
) );
80 VERIFY( is_04
.gcount() == 125 );
82 is_04
.get(carray1
, 200);
83 VERIFY( static_cast<bool>(is_04
.rdstate() & stateeof
) );
84 VERIFY( static_cast<bool>(is_04
.rdstate() & statefail
) );
85 VERIFY( is_04
.gcount() == 0 );
87 std::wstringbuf
sbuf_02(std::ios_base::in
);
90 VERIFY( is_05
.gcount() == 0 );
91 VERIFY( static_cast<bool>(is_05
.rdstate() & statefail
) );
92 VERIFY( !(is_05
.rdstate() & stateeof
) );
96 VERIFY( is_05
.gcount() == 10 );
97 VERIFY( sbuf_03
.str() == L
" sun*ra " );
98 VERIFY( !(is_05
.rdstate() & statefail
) );
99 VERIFY( !(is_05
.rdstate() & stateeof
) );
102 is_05
.get(sbuf_03
, L
'|');
103 VERIFY( is_05
.gcount() == 125 );
104 VERIFY( sbuf_03
.str() == str_lit01
);
105 VERIFY( !(is_05
.rdstate() & statefail
) );
106 VERIFY( static_cast<bool>(is_05
.rdstate() & stateeof
) );
109 is_05
.get(sbuf_03
, L
'|');
110 VERIFY( is_05
.gcount() == 0 );
111 VERIFY( static_cast<bool>(is_05
.rdstate() & stateeof
) );
112 VERIFY( static_cast<bool>(is_05
.rdstate() & statefail
) );