1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <iterator> |
10 | |
11 | // istreambuf_iterator |
12 | |
13 | // bool equal(istreambuf_iterator<charT,traits>& b) const; |
14 | |
15 | #include <iterator> |
16 | #include <sstream> |
17 | #include <cassert> |
18 | |
19 | #include "test_macros.h" |
20 | |
21 | int main(int, char**) |
22 | { |
23 | { |
24 | std::istringstream inf1("abc" ); |
25 | std::istringstream inf2("def" ); |
26 | std::istreambuf_iterator<char> i1(inf1); |
27 | std::istreambuf_iterator<char> i2(inf2); |
28 | std::istreambuf_iterator<char> i3; |
29 | std::istreambuf_iterator<char> i4; |
30 | std::istreambuf_iterator<char> i5(nullptr); |
31 | |
32 | assert( i1.equal(i1)); |
33 | assert( i1.equal(i2)); |
34 | assert(!i1.equal(i3)); |
35 | assert(!i1.equal(i4)); |
36 | assert(!i1.equal(i5)); |
37 | |
38 | assert( i2.equal(i1)); |
39 | assert( i2.equal(i2)); |
40 | assert(!i2.equal(i3)); |
41 | assert(!i2.equal(i4)); |
42 | assert(!i2.equal(i5)); |
43 | |
44 | assert(!i3.equal(i1)); |
45 | assert(!i3.equal(i2)); |
46 | assert( i3.equal(i3)); |
47 | assert( i3.equal(i4)); |
48 | assert( i3.equal(i5)); |
49 | |
50 | assert(!i4.equal(i1)); |
51 | assert(!i4.equal(i2)); |
52 | assert( i4.equal(i3)); |
53 | assert( i4.equal(i4)); |
54 | assert( i4.equal(i5)); |
55 | |
56 | assert(!i5.equal(i1)); |
57 | assert(!i5.equal(i2)); |
58 | assert( i5.equal(i3)); |
59 | assert( i5.equal(i4)); |
60 | assert( i5.equal(i5)); |
61 | } |
62 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
63 | { |
64 | std::wistringstream inf1(L"abc" ); |
65 | std::wistringstream inf2(L"def" ); |
66 | std::istreambuf_iterator<wchar_t> i1(inf1); |
67 | std::istreambuf_iterator<wchar_t> i2(inf2); |
68 | std::istreambuf_iterator<wchar_t> i3; |
69 | std::istreambuf_iterator<wchar_t> i4; |
70 | std::istreambuf_iterator<wchar_t> i5(nullptr); |
71 | |
72 | assert( i1.equal(i1)); |
73 | assert( i1.equal(i2)); |
74 | assert(!i1.equal(i3)); |
75 | assert(!i1.equal(i4)); |
76 | assert(!i1.equal(i5)); |
77 | |
78 | assert( i2.equal(i1)); |
79 | assert( i2.equal(i2)); |
80 | assert(!i2.equal(i3)); |
81 | assert(!i2.equal(i4)); |
82 | assert(!i2.equal(i5)); |
83 | |
84 | assert(!i3.equal(i1)); |
85 | assert(!i3.equal(i2)); |
86 | assert( i3.equal(i3)); |
87 | assert( i3.equal(i4)); |
88 | assert( i3.equal(i5)); |
89 | |
90 | assert(!i4.equal(i1)); |
91 | assert(!i4.equal(i2)); |
92 | assert( i4.equal(i3)); |
93 | assert( i4.equal(i4)); |
94 | assert( i4.equal(i5)); |
95 | |
96 | assert(!i5.equal(i1)); |
97 | assert(!i5.equal(i2)); |
98 | assert( i5.equal(i3)); |
99 | assert( i5.equal(i4)); |
100 | assert( i5.equal(i5)); |
101 | } |
102 | #endif // TEST_HAS_NO_WIDE_CHARACTERS |
103 | |
104 | return 0; |
105 | } |
106 | |