Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / eq.pass.cpp
bloba0ea30fae070558a7cbdcde339d890c47713175d
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 //===----------------------------------------------------------------------===//
9 // <unordered_set>
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);
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);
21 #include <unordered_set>
22 #include <cassert>
24 #include "test_macros.h"
25 #include "min_allocator.h"
27 int main(int, char**)
30 typedef std::unordered_set<int> C;
31 typedef int P;
32 P a[] =
34 P(10),
35 P(20),
36 P(30),
37 P(40),
38 P(50),
39 P(60),
40 P(70),
41 P(80)
43 const C c1(std::begin(a), std::end(a));
44 const C c2;
45 assert(!(c1 == c2));
46 assert( (c1 != c2));
49 typedef std::unordered_set<int> C;
50 typedef int P;
51 P a[] =
53 P(10),
54 P(20),
55 P(30),
56 P(40),
57 P(50),
58 P(60),
59 P(70),
60 P(80)
62 const C c1(std::begin(a), std::end(a));
63 const C c2 = c1;
64 assert( (c1 == c2));
65 assert(!(c1 != c2));
68 typedef std::unordered_set<int> C;
69 typedef int P;
70 P a[] =
72 P(10),
73 P(20),
74 P(30),
75 P(40),
76 P(50),
77 P(60),
78 P(70),
79 P(80)
81 C c1(std::begin(a), std::end(a));
82 C c2 = c1;
83 c2.rehash(30);
84 assert( (c1 == c2));
85 assert(!(c1 != c2));
86 c2.insert(P(90));
87 assert(!(c1 == c2));
88 assert( (c1 != c2));
89 c1.insert(P(90));
90 assert( (c1 == c2));
91 assert(!(c1 != c2));
93 #if TEST_STD_VER >= 11
95 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
96 typedef int P;
97 P a[] =
99 P(10),
100 P(20),
101 P(30),
102 P(40),
103 P(50),
104 P(60),
105 P(70),
106 P(80)
108 const C c1(std::begin(a), std::end(a));
109 const C c2;
110 assert(!(c1 == c2));
111 assert( (c1 != c2));
114 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
115 typedef int P;
116 P a[] =
118 P(10),
119 P(20),
120 P(30),
121 P(40),
122 P(50),
123 P(60),
124 P(70),
125 P(80)
127 const C c1(std::begin(a), std::end(a));
128 const C c2 = c1;
129 assert( (c1 == c2));
130 assert(!(c1 != c2));
133 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
134 typedef int P;
135 P a[] =
137 P(10),
138 P(20),
139 P(30),
140 P(40),
141 P(50),
142 P(60),
143 P(70),
144 P(80)
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));
158 #endif
160 return 0;