Sequoia
Loading...
Searching...
No Matches
RegularTestCore.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2018. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
16
17namespace sequoia::testing
18{
19 [[nodiscard]]
20 std::string regular_message(std::string_view description);
21
30 template<test_mode Mode>
32 {
33 public:
34 constexpr static test_mode mode{Mode};
35
36 regular_extender() = default;
37
39 template<pseudoregular T, class Self>
40 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y)
41 {
42 testing::check_semantics(regular_message(self.report(description)),
43 self.m_Logger,
44 x,
45 y,
46 optional_ref<const T>{},
47 optional_ref<const T>{});
48 }
49
55 template<pseudoregular T, class U, class Self>
56 requires equivalence_checkable_for_semantics<Mode, T, U>
57 void check_semantics(this Self& self,
58 const reporter& description,
59 const T& x,
60 const T& y,
61 const U& xEquivalent,
62 const U& yEquivalent)
63 {
64 testing::check_semantics(regular_message(self.report(description)),
65 self.m_Logger,
66 x,
67 y,
68 xEquivalent,
69 yEquivalent,
70 optional_ref<const T>{},
71 optional_ref<const T>{});
72 }
73
79 template<pseudoregular T, class U, class V, class Self>
80 requires equivalence_checkable_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
81 void check_semantics(this Self& self,
82 const reporter& description,
83 const T& x,
84 const T& y,
85 const U& xEquivalent,
86 const U& yEquivalent,
87 const V& movedFromPostConstruction,
88 const V& movedFromPostAssignment)
89 {
90 testing::check_semantics(regular_message(self.report(description)),
91 self.m_Logger,
92 x,
93 y,
94 xEquivalent,
95 yEquivalent,
96 optional_ref<const V>{movedFromPostConstruction},
97 optional_ref<const V>{movedFromPostAssignment});
98 }
99
101 template<pseudoregular T, class Self>
102 requires std::totally_ordered<T>
103 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y, std::weak_ordering order)
104 {
105 testing::check_semantics(regular_message(self.report(description)),
106 self.m_Logger,
107 x,
108 y,
109 optional_ref<const T>{},
110 optional_ref<const T>{},
111 order);
112 }
113
119 template<pseudoregular T, class U, class Self>
120 requires std::totally_ordered<T> && equivalence_checkable_for_semantics<Mode, T, U>
121 void check_semantics(this Self& self,
122 const reporter& description,
123 const T& x,
124 const T& y,
125 const U& xEquivalent,
126 const U& yEquivalent,
127 std::weak_ordering order)
128 {
129 testing::check_semantics(regular_message(self.report(description)),
130 self.m_Logger,
131 x,
132 y,
133 xEquivalent,
134 yEquivalent,
135 optional_ref<const T>{},
136 optional_ref<const T>{},
137 order);
138 }
139
145 template<pseudoregular T, class U, class V, class Self>
146 requires std::totally_ordered<T> && equivalence_checkable_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
147 void check_semantics(this Self& self,
148 const reporter& description,
149 const T& x,
150 const T& y,
151 const U& xEquivalent,
152 const U& yEquivalent,
153 const V& movedFromPostConstruction,
154 const V& movedFromPostAssignment,
155 std::weak_ordering order)
156 {
157 testing::check_semantics(regular_message(self.report(description)),
158 self.m_Logger,
159 x,
160 y,
161 xEquivalent,
162 yEquivalent,
163 optional_ref<const V>{movedFromPostConstruction},
164 optional_ref<const V>{movedFromPostAssignment},
165 order);
166 }
167
169 template<pseudoregular T, std::invocable<T&> Mutator, class Self>
170 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y, Mutator m)
171 {
172 testing::check_semantics(regular_message(self.report(description)),
173 self.m_Logger,
174 x,
175 y,
176 optional_ref<const T>{},
177 optional_ref<const T>{},
178 std::move(m));
179 }
180
186 template<pseudoregular T, class U, std::invocable<T&> Mutator, class Self>
187 requires equivalence_checkable_for_semantics<Mode, T, U>
188 void check_semantics(this Self& self,
189 const reporter& description,
190 const T& x,
191 const T& y,
192 const U& xEquivalent,
193 const U& yEquivalent,
194 Mutator m)
195 {
196 testing::check_semantics(regular_message(self.report(description)),
197 self.m_Logger,
198 x,
199 y,
200 xEquivalent,
201 yEquivalent,
202 optional_ref<const T>{},
203 optional_ref<const T>{},
204 std::move(m));
205 }
206
212 template<pseudoregular T, class U, class V, std::invocable<T&> Mutator, class Self>
213 requires equivalence_checkable_for_semantics<Mode, T, U>
214 void check_semantics(this Self& self,
215 const reporter& description,
216 const T& x,
217 const T& y,
218 const U& xEquivalent,
219 const U& yEquivalent,
220 const V& movedFromPostConstruction,
221 const V& movedFromPostAssignment,
222 Mutator m)
223 {
224 testing::check_semantics(regular_message(self.report(description)),
225 self.m_Logger,
226 x,
227 y,
228 xEquivalent,
229 yEquivalent,
230 optional_ref<const V>{movedFromPostConstruction},
231 optional_ref<const V>{movedFromPostAssignment},
232 std::move(m));
233 }
234
236 template<pseudoregular T, std::invocable<T&> Mutator, class Self>
237 requires std::totally_ordered<T>
238 void check_semantics(this Self& self, const reporter& description, const T& x, const T& y, std::weak_ordering order, Mutator m)
239 {
240 testing::check_semantics(regular_message(self.report(description)),
241 self.m_Logger,
242 x,
243 y,
244 optional_ref<const T>{},
245 optional_ref<const T>{},
246 order,
247 std::move(m));
248 }
249
255 template<pseudoregular T, class U, std::invocable<T&> Mutator, class Self>
256 requires std::totally_ordered<T> && equivalence_checkable_for_semantics<Mode, T, U>
257 void check_semantics(this Self& self,
258 const reporter& description,
259 const T& x,
260 const T& y,
261 const U& xEquivalent,
262 const U& yEquivalent,
263 std::weak_ordering order,
264 Mutator m)
265 {
266 testing::check_semantics(regular_message(self.report(description)),
267 self.m_Logger,
268 x,
269 y,
270 xEquivalent,
271 yEquivalent,
272 optional_ref<const T>{},
273 optional_ref<const T>{},
274 order,
275 std::move(m));
276 }
277
283 template<pseudoregular T, class U, class V, std::invocable<T&> Mutator, class Self>
284 requires equivalence_checkable_for_semantics<Mode, T, U>
285 void check_semantics(this Self& self,
286 const reporter& description,
287 const T& x,
288 const T& y,
289 const U& xEquivalent,
290 const U& yEquivalent,
291 const V& movedFromPostConstruction,
292 const V& movedFromPostAssignment,
293 std::weak_ordering order,
294 Mutator m)
295 {
296 testing::check_semantics(regular_message(self.report(description)),
297 self.m_Logger,
298 x,
299 y,
300 xEquivalent,
301 yEquivalent,
302 optional_ref<const V>{movedFromPostConstruction},
303 optional_ref<const V>{movedFromPostAssignment},
304 order,
305 std::move(m));
306 }
307 protected:
308 ~regular_extender() = default;
309
310 regular_extender(regular_extender&&) noexcept = default;
311 regular_extender& operator=(regular_extender&&) noexcept = default;
312 };
313
314 template<test_mode mode>
316
318 using regular_test = canonical_regular_test<test_mode::standard>;
319 using regular_false_positive_test = canonical_regular_test<test_mode::false_positive>;
320 using regular_false_negative_test = canonical_regular_test<test_mode::false_negative>;
321}
Core functionality for the testing framework.
Functions for checking regular semantics.
class template from which all concrete tests should derive.
Definition: FreeTestCore.hpp:144
Extender for testing classes exhibiting regular/std::totally_ordered semantics.
Definition: RegularTestCore.hpp:32
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, std::weak_ordering order, Mutator m)
Prerequisites: x != y, with values consistent with order.
Definition: RegularTestCore.hpp:238
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent)
Definition: RegularTestCore.hpp:57
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment, std::weak_ordering order, Mutator m)
Definition: RegularTestCore.hpp:285
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment, std::weak_ordering order)
Definition: RegularTestCore.hpp:147
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, Mutator m)
Prerequisite: x != y.
Definition: RegularTestCore.hpp:170
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, std::weak_ordering order)
Definition: RegularTestCore.hpp:121
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y)
Prerequisite: x != y.
Definition: RegularTestCore.hpp:40
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, std::weak_ordering order, Mutator m)
Definition: RegularTestCore.hpp:257
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment)
Definition: RegularTestCore.hpp:81
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment, Mutator m)
Definition: RegularTestCore.hpp:214
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, std::weak_ordering order)
Prerequisite: x != y, with values consistent with order.
Definition: RegularTestCore.hpp:103
void check_semantics(this Self &self, const reporter &description, const T &x, const T &y, const U &xEquivalent, const U &yEquivalent, Mutator m)
Definition: RegularTestCore.hpp:188
Definition: Output.hpp:186