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