source: mainline/uspace/lib/cpp/include/__bits/test/tests.hpp@ 8fd0675f

Last change on this file since 8fd0675f was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2019 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LIBCPP_BITS_TEST_TESTS
8#define LIBCPP_BITS_TEST_TESTS
9
10#include <__bits/test/test.hpp>
11#include <cstdio>
12#include <vector>
13
14namespace std::test
15{
16 class test_set
17 {
18 public:
19 test_set() = default;
20
21 template<class T>
22 void add()
23 {
24 tests_.push_back(new T{});
25 }
26
27 bool run(bool report)
28 {
29 bool res{true};
30 unsigned int succeeded{};
31 unsigned int failed{};
32
33 for (auto test: tests_)
34 {
35 res &= test->run(report);
36 succeeded += test->get_succeeded();
37 failed += test->get_failed();
38 }
39
40 if (report)
41 {
42 std::printf("\n");
43 if (res)
44 std::printf("[TESTS SUCCEEDED!]");
45 else
46 std::printf("[TESTS FAILED]");
47 std::printf("[%u OK][%u FAIL][%u TOTAL]\n",
48 succeeded, failed, (succeeded + failed));
49 }
50
51 return res;
52 }
53
54 ~test_set()
55 {
56 for (auto ptr: tests_)
57 delete ptr;
58 }
59 private:
60 std::vector<test_suite*> tests_{};
61 };
62
63 class array_test: public test_suite
64 {
65 public:
66 bool run(bool) override;
67 const char* name() override;
68
69 array_test() = default;
70 ~array_test() = default;
71 };
72
73 class vector_test: public test_suite
74 {
75 public:
76 bool run(bool) override;
77 const char* name() override;
78
79 vector_test() = default;
80 ~vector_test() = default;
81
82 private:
83 void test_construction_and_assignment();
84 void test_insert();
85 void test_erase();
86 };
87
88 class string_test: public test_suite
89 {
90 public:
91 bool run(bool) override;
92 const char* name() override;
93
94 private:
95 void test_construction_and_assignment();
96 void test_append();
97 void test_insert();
98 void test_erase();
99 void test_replace();
100 void test_copy();
101 void test_find();
102 void test_substr();
103 void test_compare();
104 };
105
106 class bitset_test: public test_suite
107 {
108 public:
109 bool run(bool) override;
110 const char* name() override;
111
112 private:
113 void test_constructors_and_assignment();
114 void test_strings();
115 void test_operations();
116 };
117
118 class deque_test: public test_suite
119 {
120 public:
121 bool run(bool) override;
122 const char* name() override;
123
124 private:
125 void test_constructors_and_assignment();
126 void test_resizing();
127 void test_push_pop();
128 void test_operations();
129 };
130
131 class tuple_test: public test_suite
132 {
133 public:
134 bool run(bool) override;
135 const char* name() override;
136
137 private:
138 void test_constructors_and_assignment();
139 void test_creation();
140 void test_tie_and_structured_bindings();
141 void test_tuple_ops();
142 };
143
144 class map_test: public test_suite
145 {
146 public:
147 bool run(bool) override;
148 const char* name() override;
149
150 private:
151 void test_constructors_and_assignment();
152 void test_histogram();
153 void test_emplace_insert();
154 void test_bounds_and_ranges();
155 void test_multi();
156 void test_reverse_iterators();
157 void test_multi_bounds_and_ranges();
158 };
159
160 class set_test: public test_suite
161 {
162 public:
163 bool run(bool) override;
164 const char* name() override;
165
166 private:
167 void test_constructors_and_assignment();
168 void test_emplace_insert();
169 void test_bounds_and_ranges();
170 void test_multi();
171 void test_reverse_iterators();
172 void test_multi_bounds_and_ranges();
173 };
174
175 class unordered_map_test: public test_suite
176 {
177 public:
178 bool run(bool) override;
179 const char* name() override;
180
181 private:
182 void test_constructors_and_assignment();
183 void test_histogram();
184 void test_emplace_insert();
185 void test_multi();
186 };
187
188 class unordered_set_test: public test_suite
189 {
190 public:
191 bool run(bool) override;
192 const char* name() override;
193
194 private:
195 void test_constructors_and_assignment();
196 void test_emplace_insert();
197 void test_multi();
198 };
199
200 class numeric_test: public test_suite
201 {
202 public:
203 bool run(bool) override;
204 const char* name() override;
205
206 private:
207 void test_algorithms();
208 void test_complex();
209 };
210
211 class adaptors_test: public test_suite
212 {
213 public:
214 bool run(bool) override;
215 const char* name() override;
216
217 private:
218 void test_queue();
219 void test_priority_queue();
220 void test_stack();
221 };
222
223 class memory_test: public test_suite
224 {
225 public:
226 bool run(bool) override;
227 const char* name() override;
228
229 private:
230 void test_unique_ptr();
231 void test_shared_ptr();
232 void test_weak_ptr();
233 void test_allocators();
234 void test_pointers();
235 };
236
237 class list_test: public test_suite
238 {
239 public:
240 bool run(bool) override;
241 const char* name() override;
242
243 private:
244 void test_construction_and_assignment();
245 void test_modifiers();
246 };
247
248 class ratio_test: public test_suite
249 {
250 public:
251 bool run(bool) override;
252 const char* name() override;
253 };
254
255 class functional_test: public test_suite
256 {
257 public:
258 bool run(bool) override;
259 const char* name() override;
260 private:
261 void test_reference_wrapper();
262 void test_function();
263 void test_bind();
264 };
265
266 class algorithm_test: public test_suite
267 {
268 public:
269 bool run(bool) override;
270 const char* name() override;
271 private:
272 void test_non_modifying();
273 void test_mutating();
274 };
275
276 class future_test: public test_suite
277 {
278 public:
279 bool run(bool) override;
280 const char* name() override;
281 private:
282 void test_future();
283 void test_promise();
284 void test_future_promise();
285 void test_async();
286 void test_packaged_task();
287 void test_shared_future();
288 };
289}
290
291#endif
Note: See TracBrowser for help on using the repository browser.