[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / support / test_transparent_unordered.h
blob7bcbc19c05a864b253244f340e20d66e8640cf41
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 #ifndef TEST_TRANSPARENT_UNORDERED_H
10 #define TEST_TRANSPARENT_UNORDERED_H
12 #include "test_macros.h"
13 #include "is_transparent.h"
15 #include <cassert>
17 // testing transparent unordered containers
18 #if TEST_STD_VER > 17
20 template <template <typename...> class UnorderedSet, typename Hash,
21 typename Equal>
22 using unord_set_type = UnorderedSet<StoredType<int>, Hash, Equal>;
24 template <template <typename...> class UnorderedMap, typename Hash,
25 typename Equal>
26 using unord_map_type = UnorderedMap<StoredType<int>, int, Hash, Equal>;
28 template <typename Container, typename... Args>
29 void test_transparent_find(Args&&... args) {
30 Container c{std::forward<Args>(args)...};
31 int conversions = 0;
32 assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
33 assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
34 assert(conversions == 0);
35 assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
36 assert(conversions == 0);
39 template <typename Container, typename... Args>
40 void test_non_transparent_find(Args&&... args) {
41 Container c{std::forward<Args>(args)...};
42 int conversions = 0;
43 assert(c.find(SearchedType<int>(1, &conversions)) != c.end());
44 assert(conversions > 0);
45 conversions = 0;
46 assert(c.find(SearchedType<int>(2, &conversions)) != c.end());
47 assert(conversions > 0);
48 conversions = 0;
49 assert(c.find(SearchedType<int>(3, &conversions)) == c.end());
50 assert(conversions > 0);
53 template <typename Container, typename... Args>
54 void test_transparent_count(Args&&... args) {
55 Container c{std::forward<Args>(args)...};
56 int conversions = 0;
57 assert(c.count(SearchedType<int>(1, &conversions)) > 0);
58 assert(c.count(SearchedType<int>(2, &conversions)) > 0);
59 assert(conversions == 0);
60 assert(c.count(SearchedType<int>(3, &conversions)) == 0);
61 assert(conversions == 0);
64 template <typename Container, typename... Args>
65 void test_non_transparent_count(Args&&... args) {
66 Container c{std::forward<Args>(args)...};
67 int conversions = 0;
68 assert(c.count(SearchedType<int>(1, &conversions)) > 0);
69 assert(conversions > 0);
70 conversions = 0;
71 assert(c.count(SearchedType<int>(2, &conversions)) > 0);
72 assert(conversions > 0);
73 conversions = 0;
74 assert(c.count(SearchedType<int>(3, &conversions)) == 0);
75 assert(conversions > 0);
78 template <typename Container, typename... Args>
79 void test_transparent_contains(Args&&... args) {
80 Container c{std::forward<Args>(args)...};
81 int conversions = 0;
82 assert(c.contains(SearchedType<int>(1, &conversions)));
83 assert(c.contains(SearchedType<int>(2, &conversions)));
84 assert(conversions == 0);
85 assert(!c.contains(SearchedType<int>(3, &conversions)));
86 assert(conversions == 0);
89 template <typename Container, typename... Args>
90 void test_non_transparent_contains(Args&&... args) {
91 Container c{std::forward<Args>(args)...};
92 int conversions = 0;
93 assert(c.contains(SearchedType<int>(1, &conversions)));
94 assert(conversions > 0);
95 conversions = 0;
96 assert(c.contains(SearchedType<int>(2, &conversions)));
97 assert(conversions > 0);
98 conversions = 0;
99 assert(!c.contains(SearchedType<int>(3, &conversions)));
100 assert(conversions > 0);
103 template <typename Container, typename... Args>
104 void test_transparent_equal_range(Args&&... args) {
105 Container c{std::forward<Args>(args)...};
106 int conversions = 0;
107 auto iters = c.equal_range(SearchedType<int>(1, &conversions));
108 assert(std::distance(iters.first, iters.second) > 0);
109 iters = c.equal_range(SearchedType<int>(2, &conversions));
110 assert(std::distance(iters.first, iters.second) > 0);
111 assert(conversions == 0);
112 iters = c.equal_range(SearchedType<int>(3, &conversions));
113 assert(std::distance(iters.first, iters.second) == 0);
114 assert(conversions == 0);
117 template <typename Container, typename... Args>
118 void test_non_transparent_equal_range(Args&&... args) {
119 Container c{std::forward<Args>(args)...};
120 int conversions = 0;
121 auto iters = c.equal_range(SearchedType<int>(1, &conversions));
122 assert(std::distance(iters.first, iters.second) > 0);
123 assert(conversions > 0);
124 conversions = 0;
125 iters = c.equal_range(SearchedType<int>(2, &conversions));
126 assert(std::distance(iters.first, iters.second) > 0);
127 assert(conversions > 0);
128 conversions = 0;
129 iters = c.equal_range(SearchedType<int>(3, &conversions));
130 assert(std::distance(iters.first, iters.second) == 0);
131 assert(conversions > 0);
134 #endif // TEST_STD_VER > 17
136 #endif // TEST_TRANSPARENT_UNORDERED_H