]>
Commit | Line | Data |
---|---|---|
23cac885 BK |
1 | // 1999-08-11 bkoz |
2 | ||
a5544970 | 3 | // Copyright (C) 1999-2019 Free Software Foundation, Inc. |
23cac885 BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
23cac885 BK |
9 | // any later version. |
10 | ||
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. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
23cac885 BK |
19 | |
20 | // 27.6.1.3 unformatted input functions | |
23cac885 BK |
21 | |
22 | #include <cstring> // for strncmp,... | |
23 | #include <istream> | |
24 | #include <sstream> | |
23cac885 BK |
25 | #include <testsuite_hooks.h> |
26 | ||
27 | void | |
28 | test01() | |
29 | { | |
23cac885 | 30 | const std::string str_02("soul eyes: john coltrane quartet"); |
23cac885 BK |
31 | |
32 | std::stringbuf isbuf_03(str_02, std::ios_base::in); | |
33 | std::stringbuf isbuf_04(str_02, std::ios_base::in); | |
34 | ||
8fc81078 | 35 | std::istream is_00(0); |
23cac885 BK |
36 | std::istream is_03(&isbuf_03); |
37 | std::istream is_04(&isbuf_04); | |
38 | std::ios_base::iostate state1, state2, statefail, stateeof; | |
39 | statefail = std::ios_base::failbit; | |
40 | stateeof = std::ios_base::eofbit; | |
41 | ||
42 | // istream& read(char_type* s, streamsize n) | |
43 | char carray[60] = ""; | |
44 | state1 = is_04.rdstate(); | |
45 | is_04.read(carray, 0); | |
46 | state2 = is_04.rdstate(); | |
47 | VERIFY( state1 == state2 ); | |
48 | ||
49 | state1 = is_04.rdstate(); | |
50 | is_04.read(carray, 9); | |
51 | state2 = is_04.rdstate(); | |
52 | VERIFY( state1 == state2 ); | |
53 | VERIFY( !std::strncmp(carray, "soul eyes", 9) ); | |
54 | VERIFY( is_04.peek() == ':' ); | |
55 | ||
56 | state1 = is_03.rdstate(); | |
57 | is_03.read(carray, 60); | |
58 | state2 = is_03.rdstate(); | |
59 | VERIFY( state1 != state2 ); | |
60 | VERIFY( static_cast<bool>(state2 & stateeof) ); | |
61 | VERIFY( static_cast<bool>(state2 & statefail) ); | |
62 | VERIFY( !std::strncmp(carray, "soul eyes: john coltrane quartet", 35) ); | |
63 | } | |
64 | ||
65 | int | |
66 | main() | |
67 | { | |
68 | test01(); | |
69 | return 0; | |
70 | } |