[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / set / count.pass.cpp
blob06ddf78b9684641fcfe6bbedd4e737f67a6c650a
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 // <set>
11 // class set
13 // size_type count(const key_type& k) const;
15 #include <set>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 #include "private_constructor.h"
22 int main(int, char**)
25 typedef int V;
26 typedef std::set<int> M;
27 typedef M::size_type R;
28 V ar[] =
35 10,
36 11,
39 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
40 R r = m.count(5);
41 assert(r == 1);
42 r = m.count(6);
43 assert(r == 1);
44 r = m.count(7);
45 assert(r == 1);
46 r = m.count(8);
47 assert(r == 1);
48 r = m.count(9);
49 assert(r == 1);
50 r = m.count(10);
51 assert(r == 1);
52 r = m.count(11);
53 assert(r == 1);
54 r = m.count(12);
55 assert(r == 1);
56 r = m.count(4);
57 assert(r == 0);
59 #if TEST_STD_VER >= 11
61 typedef int V;
62 typedef std::set<int, std::less<int>, min_allocator<int>> M;
63 typedef M::size_type R;
64 V ar[] =
71 10,
72 11,
75 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
76 R r = m.count(5);
77 assert(r == 1);
78 r = m.count(6);
79 assert(r == 1);
80 r = m.count(7);
81 assert(r == 1);
82 r = m.count(8);
83 assert(r == 1);
84 r = m.count(9);
85 assert(r == 1);
86 r = m.count(10);
87 assert(r == 1);
88 r = m.count(11);
89 assert(r == 1);
90 r = m.count(12);
91 assert(r == 1);
92 r = m.count(4);
93 assert(r == 0);
95 #endif
96 #if TEST_STD_VER > 11
98 typedef int V;
99 typedef std::set<int, std::less<>> M;
100 typedef M::size_type R;
101 V ar[] =
112 const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
113 R r = m.count(5);
114 assert(r == 1);
115 r = m.count(6);
116 assert(r == 1);
117 r = m.count(7);
118 assert(r == 1);
119 r = m.count(8);
120 assert(r == 1);
121 r = m.count(9);
122 assert(r == 1);
123 r = m.count(10);
124 assert(r == 1);
125 r = m.count(11);
126 assert(r == 1);
127 r = m.count(12);
128 assert(r == 1);
129 r = m.count(4);
130 assert(r == 0);
133 typedef PrivateConstructor V;
134 typedef std::set<V, std::less<>> M;
135 typedef M::size_type R;
137 M m;
138 m.insert ( V::make ( 5 ));
139 m.insert ( V::make ( 6 ));
140 m.insert ( V::make ( 7 ));
141 m.insert ( V::make ( 8 ));
142 m.insert ( V::make ( 9 ));
143 m.insert ( V::make ( 10 ));
144 m.insert ( V::make ( 11 ));
145 m.insert ( V::make ( 12 ));
147 const M& mc = m;
149 R r = mc.count(5);
150 assert(r == 1);
151 r = mc.count(6);
152 assert(r == 1);
153 r = mc.count(7);
154 assert(r == 1);
155 r = mc.count(8);
156 assert(r == 1);
157 r = mc.count(9);
158 assert(r == 1);
159 r = mc.count(10);
160 assert(r == 1);
161 r = mc.count(11);
162 assert(r == 1);
163 r = mc.count(12);
164 assert(r == 1);
165 r = mc.count(4);
166 assert(r == 0);
168 #endif
171 return 0;