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// <unordered_set>
10
11// template <class Key, class Hash, class Pred, class Alloc>
12// bool
13// operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
14// const unordered_set<Key, Hash, Pred, Alloc>& y);
15//
16// template <class Key, class Hash, class Pred, class Alloc>
17// bool
18// operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
19// const unordered_set<Key, Hash, Pred, Alloc>& y);
20
21#include <unordered_set>
22#include <cassert>
23
24#include "test_macros.h"
25#include "min_allocator.h"
26
27int main(int, char**)
28{
29 {
30 typedef std::unordered_set<int> C;
31 typedef int P;
32 P a[] =
33 {
34 P(10),
35 P(20),
36 P(30),
37 P(40),
38 P(50),
39 P(60),
40 P(70),
41 P(80)
42 };
43 const C c1(std::begin(arr&: a), std::end(arr&: a));
44 const C c2;
45 assert(!(c1 == c2));
46 assert( (c1 != c2));
47 }
48 {
49 typedef std::unordered_set<int> C;
50 typedef int P;
51 P a[] =
52 {
53 P(10),
54 P(20),
55 P(30),
56 P(40),
57 P(50),
58 P(60),
59 P(70),
60 P(80)
61 };
62 const C c1(std::begin(arr&: a), std::end(arr&: a));
63 const C c2 = c1;
64 assert( (c1 == c2));
65 assert(!(c1 != c2));
66 }
67 {
68 typedef std::unordered_set<int> C;
69 typedef int P;
70 P a[] =
71 {
72 P(10),
73 P(20),
74 P(30),
75 P(40),
76 P(50),
77 P(60),
78 P(70),
79 P(80)
80 };
81 C c1(std::begin(arr&: a), std::end(arr&: a));
82 C c2 = c1;
83 c2.rehash(n: 30);
84 assert( (c1 == c2));
85 assert(!(c1 != c2));
86 c2.insert(x: P(90));
87 assert(!(c1 == c2));
88 assert( (c1 != c2));
89 c1.insert(x: P(90));
90 assert( (c1 == c2));
91 assert(!(c1 != c2));
92 }
93#if TEST_STD_VER >= 11
94 {
95 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
96 typedef int P;
97 P a[] =
98 {
99 P(10),
100 P(20),
101 P(30),
102 P(40),
103 P(50),
104 P(60),
105 P(70),
106 P(80)
107 };
108 const C c1(std::begin(a), std::end(a));
109 const C c2;
110 assert(!(c1 == c2));
111 assert( (c1 != c2));
112 }
113 {
114 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
115 typedef int P;
116 P a[] =
117 {
118 P(10),
119 P(20),
120 P(30),
121 P(40),
122 P(50),
123 P(60),
124 P(70),
125 P(80)
126 };
127 const C c1(std::begin(a), std::end(a));
128 const C c2 = c1;
129 assert( (c1 == c2));
130 assert(!(c1 != c2));
131 }
132 {
133 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
134 typedef int P;
135 P a[] =
136 {
137 P(10),
138 P(20),
139 P(30),
140 P(40),
141 P(50),
142 P(60),
143 P(70),
144 P(80)
145 };
146 C c1(std::begin(a), std::end(a));
147 C c2 = c1;
148 c2.rehash(30);
149 assert( (c1 == c2));
150 assert(!(c1 != c2));
151 c2.insert(P(90));
152 assert(!(c1 == c2));
153 assert( (c1 != c2));
154 c1.insert(P(90));
155 assert( (c1 == c2));
156 assert(!(c1 != c2));
157 }
158#endif
159
160 return 0;
161}
162

source code of libcxx/test/std/containers/unord/unord.set/eq.pass.cpp