1 |
19 |
jlechner |
// Copyright (C) 2004 Free Software Foundation
|
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 2, 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 COPYING. If not, write to the Free
|
16 |
|
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
17 |
|
|
// USA.
|
18 |
|
|
|
19 |
|
|
// 27.6.1.3 unformatted input functions
|
20 |
|
|
|
21 |
|
|
#include <istream>
|
22 |
|
|
#include <sstream>
|
23 |
|
|
#include <testsuite_hooks.h>
|
24 |
|
|
|
25 |
|
|
void
|
26 |
|
|
test03()
|
27 |
|
|
{
|
28 |
|
|
typedef std::char_traits<wchar_t> traits_type;
|
29 |
|
|
|
30 |
|
|
bool test __attribute__((unused)) = true;
|
31 |
|
|
const wchar_t str_lit01[] =
|
32 |
|
|
L" sun*ra \n\t\t\t & his arkestra, featuring john gilmore: \n"
|
33 |
|
|
L" "
|
34 |
|
|
L"jazz in silhouette: images and forecasts of tomorrow";
|
35 |
|
|
|
36 |
|
|
std::wstring str01(str_lit01);
|
37 |
|
|
std::wstring strtmp;
|
38 |
|
|
|
39 |
|
|
std::wstringbuf sbuf_03;
|
40 |
|
|
std::wstringbuf sbuf_04(str01, std::ios_base::in);
|
41 |
|
|
std::wstringbuf sbuf_05(str01, std::ios_base::in);
|
42 |
|
|
|
43 |
|
|
std::wistream is_00(NULL);
|
44 |
|
|
std::wistream is_04(&sbuf_04);
|
45 |
|
|
std::wistream is_05(&sbuf_05);
|
46 |
|
|
std::ios_base::iostate statefail, stateeof;
|
47 |
|
|
statefail = std::ios_base::failbit;
|
48 |
|
|
stateeof = std::ios_base::eofbit;
|
49 |
|
|
wchar_t carray1[400] = L"";
|
50 |
|
|
|
51 |
|
|
// int_type get()
|
52 |
|
|
// istream& get(wchar_t*, streamsize, wchar_t delim)
|
53 |
|
|
// istream& get(wchar_t*, streamsize)
|
54 |
|
|
// istream& get(streambuf&, wchar_t delim)
|
55 |
|
|
// istream& get(streambuf&)
|
56 |
|
|
is_00.get(carray1, 2);
|
57 |
|
|
VERIFY( static_cast<bool>(is_00.rdstate() & statefail) );
|
58 |
|
|
VERIFY( is_00.gcount() == 0 );
|
59 |
|
|
|
60 |
|
|
is_04.get(carray1, 4);
|
61 |
|
|
VERIFY( !(is_04.rdstate() & statefail) );
|
62 |
|
|
VERIFY( !traits_type::compare(carray1, L" ", 4) );
|
63 |
|
|
VERIFY( is_04.gcount() == 3 );
|
64 |
|
|
|
65 |
|
|
is_04.clear();
|
66 |
|
|
is_04.get(carray1 + 3, 200);
|
67 |
|
|
VERIFY( !(is_04.rdstate() & statefail) );
|
68 |
|
|
VERIFY( !(is_04.rdstate() & stateeof) );
|
69 |
|
|
VERIFY( !traits_type::compare(carray1, str_lit01, 10) );
|
70 |
|
|
VERIFY( is_04.gcount() == 7 );
|
71 |
|
|
|
72 |
|
|
is_04.clear();
|
73 |
|
|
is_04.get(carray1, 200);
|
74 |
|
|
VERIFY( !(is_04.rdstate() & stateeof) );
|
75 |
|
|
VERIFY( static_cast<bool>(is_04.rdstate() & statefail) ); // delimiter
|
76 |
|
|
VERIFY( is_04.gcount() == 0 );
|
77 |
|
|
is_04.clear();
|
78 |
|
|
is_04.get(carray1, 200, L'[');
|
79 |
|
|
VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
|
80 |
|
|
VERIFY( !(is_04.rdstate() & statefail) );
|
81 |
|
|
VERIFY( is_04.gcount() == 125 );
|
82 |
|
|
is_04.clear();
|
83 |
|
|
is_04.get(carray1, 200);
|
84 |
|
|
VERIFY( static_cast<bool>(is_04.rdstate() & stateeof) );
|
85 |
|
|
VERIFY( static_cast<bool>(is_04.rdstate() & statefail) );
|
86 |
|
|
VERIFY( is_04.gcount() == 0 );
|
87 |
|
|
|
88 |
|
|
std::wstringbuf sbuf_02(std::ios_base::in);
|
89 |
|
|
is_05.clear();
|
90 |
|
|
is_05.get(sbuf_02);
|
91 |
|
|
VERIFY( is_05.gcount() == 0 );
|
92 |
|
|
VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
|
93 |
|
|
VERIFY( !(is_05.rdstate() & stateeof) );
|
94 |
|
|
|
95 |
|
|
is_05.clear();
|
96 |
|
|
is_05.get(sbuf_03);
|
97 |
|
|
VERIFY( is_05.gcount() == 10 );
|
98 |
|
|
VERIFY( sbuf_03.str() == L" sun*ra " );
|
99 |
|
|
VERIFY( !(is_05.rdstate() & statefail) );
|
100 |
|
|
VERIFY( !(is_05.rdstate() & stateeof) );
|
101 |
|
|
|
102 |
|
|
is_05.clear();
|
103 |
|
|
is_05.get(sbuf_03, L'|');
|
104 |
|
|
VERIFY( is_05.gcount() == 125 );
|
105 |
|
|
VERIFY( sbuf_03.str() == str_lit01 );
|
106 |
|
|
VERIFY( !(is_05.rdstate() & statefail) );
|
107 |
|
|
VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
|
108 |
|
|
|
109 |
|
|
is_05.clear();
|
110 |
|
|
is_05.get(sbuf_03, L'|');
|
111 |
|
|
VERIFY( is_05.gcount() == 0 );
|
112 |
|
|
VERIFY( static_cast<bool>(is_05.rdstate() & stateeof) );
|
113 |
|
|
VERIFY( static_cast<bool>(is_05.rdstate() & statefail) );
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
int
|
117 |
|
|
main()
|
118 |
|
|
{
|
119 |
|
|
test03();
|
120 |
|
|
return 0;
|
121 |
|
|
}
|