]>
Commit | Line | Data |
---|---|---|
b2dad0e3 BK |
1 | // 1999-06-28 bkoz |
2 | ||
a5544970 | 3 | // Copyright (C) 1999-2019 Free Software Foundation, Inc. |
b2dad0e3 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) |
b2dad0e3 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/>. | |
b2dad0e3 BK |
19 | |
20 | // 24.5.3 template class istreambuf_iterator | |
21 | ||
22 | #include <sstream> | |
23 | #include <iterator> | |
fe413112 | 24 | #include <testsuite_hooks.h> |
b2dad0e3 | 25 | |
2437d31d | 26 | void test02(void) |
b2dad0e3 | 27 | { |
b2dad0e3 | 28 | typedef std::istreambuf_iterator<char> cistreambuf_iter; |
b2dad0e3 BK |
29 | const char slit01[] = "playa hermosa, liberia, guanacaste"; |
30 | std::string str01(slit01); | |
31 | std::istringstream istrs00(str01); | |
32 | std::istringstream istrs01(str01); | |
33 | ||
34 | // ctor sanity checks | |
35 | cistreambuf_iter istrb_it01(istrs00); | |
4e914524 PO |
36 | cistreambuf_iter istrb_eos; |
37 | VERIFY( istrb_it01 != istrb_eos ); | |
38 | ||
39 | std::string tmp(istrb_it01, istrb_eos); | |
aa1b2f7d | 40 | VERIFY( tmp == str01 ); |
b2dad0e3 | 41 | |
4e914524 PO |
42 | VERIFY( istrb_it01 == istrb_eos ); |
43 | ||
b2dad0e3 BK |
44 | cistreambuf_iter istrb_it03(0); |
45 | cistreambuf_iter istrb_it04; | |
aa1b2f7d | 46 | VERIFY( istrb_it03 == istrb_it04 ); |
b2dad0e3 BK |
47 | |
48 | cistreambuf_iter istrb_it05(istrs01); | |
49 | cistreambuf_iter istrb_it06(istrs01.rdbuf()); | |
aa1b2f7d | 50 | VERIFY( istrb_it05 == istrb_it06 ); |
b2dad0e3 BK |
51 | |
52 | // bool equal(istreambuf_iter& b) | |
53 | cistreambuf_iter istrb_it07(0); | |
54 | cistreambuf_iter istrb_it08; | |
aa1b2f7d | 55 | VERIFY( istrb_it07.equal(istrb_it08) ); |
b2dad0e3 BK |
56 | cistreambuf_iter istrb_it09(0); |
57 | cistreambuf_iter istrb_it10; | |
aa1b2f7d | 58 | VERIFY( istrb_it10.equal(istrb_it09) ); |
b2dad0e3 BK |
59 | |
60 | cistreambuf_iter istrb_it11(istrs01); | |
61 | cistreambuf_iter istrb_it12(istrs01.rdbuf()); | |
aa1b2f7d | 62 | VERIFY( istrb_it11.equal(istrb_it12) ); |
b2dad0e3 BK |
63 | cistreambuf_iter istrb_it13(istrs01); |
64 | cistreambuf_iter istrb_it14(istrs01.rdbuf()); | |
aa1b2f7d | 65 | VERIFY( istrb_it14.equal(istrb_it13) ); |
b2dad0e3 BK |
66 | |
67 | cistreambuf_iter istrb_it15(istrs01); | |
68 | cistreambuf_iter istrb_it16; | |
aa1b2f7d | 69 | VERIFY( !(istrb_it15.equal(istrb_it16)) ); |
b2dad0e3 BK |
70 | cistreambuf_iter istrb_it17(istrs01); |
71 | cistreambuf_iter istrb_it18; | |
aa1b2f7d | 72 | VERIFY( !(istrb_it18.equal(istrb_it17)) ); |
b2dad0e3 BK |
73 | |
74 | // bool operator==(const istreambuf_iterator&a, const istreambuf_iterator& b) | |
75 | // bool operator!=(const istreambuf_iterator&a, const istreambuf_iterator& b) | |
76 | cistreambuf_iter istrb_it19(0); | |
77 | cistreambuf_iter istrb_it20; | |
aa1b2f7d | 78 | VERIFY( istrb_it19 == istrb_it20 ); |
b2dad0e3 BK |
79 | |
80 | cistreambuf_iter istrb_it21(istrs01); | |
81 | cistreambuf_iter istrb_it22(istrs01.rdbuf()); | |
aa1b2f7d | 82 | VERIFY( istrb_it22 == istrb_it21 ); |
b2dad0e3 BK |
83 | |
84 | cistreambuf_iter istrb_it23(istrs01); | |
85 | cistreambuf_iter istrb_it24; | |
aa1b2f7d | 86 | VERIFY( istrb_it23 != istrb_it24 ); |
b2dad0e3 BK |
87 | |
88 | cistreambuf_iter istrb_it25(0); | |
89 | cistreambuf_iter istrb_it26(istrs01.rdbuf()); | |
aa1b2f7d | 90 | VERIFY( istrb_it25 != istrb_it26 ); |
b2dad0e3 BK |
91 | |
92 | // charT operator*() const | |
93 | // istreambuf_iterator& operator++(); | |
94 | // istreambuf_iterator& operator++(int); | |
95 | cistreambuf_iter istrb_it27(istrs01.rdbuf()); | |
96 | char c; | |
11f10e6b | 97 | for (std::size_t i = 0; i < sizeof(slit01) - 2; ++i) |
b2dad0e3 BK |
98 | { |
99 | c = *istrb_it27++; | |
aa1b2f7d | 100 | VERIFY( c == slit01[i] ); |
b2dad0e3 BK |
101 | } |
102 | ||
103 | std::istringstream istrs02(str01); | |
104 | cistreambuf_iter istrb_it28(istrs02); | |
11f10e6b | 105 | for (std::size_t i = 0; i < sizeof(slit01) - 2;) |
b2dad0e3 BK |
106 | { |
107 | c = *++istrb_it28; | |
aa1b2f7d | 108 | VERIFY( c == slit01[++i] ); |
b2dad0e3 | 109 | } |
b2dad0e3 BK |
110 | } |
111 | ||
112 | int main() | |
113 | { | |
a85afd69 | 114 | test02(); |
b2dad0e3 BK |
115 | return 0; |
116 | } |