1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Key, class T, class Hash, class Pred, class Alloc>
13 // operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
14 // const unordered_map<Key, T, Hash, Pred, Alloc>& y);
16 // template <class Key, class T, class Hash, class Pred, class Alloc>
18 // operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
19 // const unordered_map<Key, T, Hash, Pred, Alloc>& y);
21 #include <unordered_map>
26 #include "test_macros.h"
27 #include "min_allocator.h"
29 #include "test_comparisons.h"
34 typedef std::unordered_map
<int, std::string
> C
;
35 typedef std::pair
<int, std::string
> P
;
47 const C
c1(std::begin(a
), std::end(a
));
49 assert(testEquality(c1
, c2
, false));
52 typedef std::unordered_map
<int, std::string
> C
;
53 typedef std::pair
<int, std::string
> P
;
65 const C
c1(std::begin(a
), std::end(a
));
67 assert(testEquality(c1
, c2
, true));
70 typedef std::unordered_map
<int, std::string
> C
;
71 typedef std::pair
<int, std::string
> P
;
83 C
c1(std::begin(a
), std::end(a
));
86 assert(testEquality(c1
, c2
, true));
87 c2
.insert(P(90, "ninety"));
88 assert(testEquality(c1
, c2
, false));
89 c1
.insert(P(90, "ninety"));
90 assert(testEquality(c1
, c2
, true));
93 typedef std::unordered_map
<int, std::string
> C
;
94 typedef std::pair
<int, std::string
> P
;
106 C
c1(std::begin(a
), std::end(a
));
108 assert(testEquality(c1
, c2
, true));
109 c1
.insert(P(90, "ninety"));
110 c2
.insert(P(100, "onehundred"));
111 assert(testEquality(c1
, c2
, false));
113 #if TEST_STD_VER >= 11
115 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
116 min_allocator
<std::pair
<const int, std::string
>>> C
;
117 typedef std::pair
<int, std::string
> P
;
129 const C
c1(std::begin(a
), std::end(a
));
131 assert(testEquality(c1
, c2
, false));
134 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
135 min_allocator
<std::pair
<const int, std::string
>>> C
;
136 typedef std::pair
<int, std::string
> P
;
148 const C
c1(std::begin(a
), std::end(a
));
150 assert(testEquality(c1
, c2
, true));
153 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
154 min_allocator
<std::pair
<const int, std::string
>>> C
;
155 typedef std::pair
<int, std::string
> P
;
167 C
c1(std::begin(a
), std::end(a
));
170 assert(testEquality(c1
, c2
, true));
171 c2
.insert(P(90, "ninety"));
172 assert(testEquality(c1
, c2
, false));
173 c1
.insert(P(90, "ninety"));
174 assert(testEquality(c1
, c2
, true));
177 typedef std::unordered_map
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
178 min_allocator
<std::pair
<const int, std::string
>>> C
;
179 typedef std::pair
<int, std::string
> P
;
191 C
c1(std::begin(a
), std::end(a
));
193 assert(testEquality(c1
, c2
, true));
194 c1
.insert(P(90, "ninety"));
195 c2
.insert(P(100, "onehundred"));
196 assert(testEquality(c1
, c2
, false));