Sequoia
Loading...
Searching...
No Matches
MoveOnlyTestCore.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2020. //
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
19
21
22namespace sequoia::testing
23{
24 [[nodiscard]]
25 std::string move_only_message(std::string description);
26
33 template<test_mode Mode>
35 {
36 public:
37 constexpr static test_mode mode{Mode};
38
39 move_only_extender() = default;
40
46 template<moveonly T, class U, class V, class Self>
47 requires checkable_against_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
48 bool check_semantics(this Self& self,
49 const reporter& description,
50 T&& x,
51 T&& y,
52 const U& xEquivalent,
53 const U& yEquivalent,
54 const V& movedFromPostConstruction,
55 const V& movedFromPostAssignment)
56 {
57 return testing::check_semantics(
58 move_only_message(self.report(description)),
59 self.m_Logger,
60 std::forward<T>(x),
61 std::forward<T>(y),
62 xEquivalent,
63 yEquivalent,
64 optional_ref<const V>{movedFromPostConstruction},
65 optional_ref<const V>{movedFromPostAssignment}
66 );
67 }
68
74 template<moveonly T, class U, class Self>
75 requires checkable_against_for_semantics<Mode, T, U>
76 bool check_semantics(this Self& self, const reporter& description, T&& x, T&& y, const U& xEquivalent, const U& yEquivalent)
77 {
78 return testing::check_semantics(
79 move_only_message(self.report(description)),
80 self.m_Logger,
81 std::forward<T>(x),
82 std::forward<T>(y),
83 xEquivalent,
84 yEquivalent,
85 optional_ref<const U>{},
86 optional_ref<const U>{}
87 );
88 }
89
91 template
92 <
93 std::regular_invocable xMaker,
94 moveonly T=std::invoke_result_t<xMaker>,
96 class U,
97 class Self
98 >
99 requires checkable_against_for_semantics<Mode, T, U>
100 bool check_semantics(this Self& self,
101 const reporter& description,
102 xMaker xFn,
103 yMaker yFn,
104 const U& movedFromPostConstruction,
105 const U& movedFromPostAssignment)
106 {
107 return self.check_semantics(
108 description,
109 xFn(),
110 yFn(),
111 xFn(),
112 yFn(),
113 movedFromPostConstruction,
114 movedFromPostAssignment);
115 }
116
118 template
119 <
120 std::regular_invocable xMaker,
121 moveonly T=std::invoke_result_t<xMaker>,
123 class Self
124 >
125 bool check_semantics(this Self& self, const reporter& description, xMaker xFn, yMaker yFn)
126 {
127 return self.check_semantics(description, xFn(), yFn(), xFn(), yFn());
128 }
129
135 template<moveonly T, class U, class V, class Self>
136 requires std::totally_ordered<T> && checkable_against_for_semantics<Mode, T, U> && checkable_against_for_semantics<Mode, T, V>
137 bool check_semantics(this Self& self,
138 const reporter& description,
139 T&& x,
140 T&& y,
141 const U& xEquivalent,
142 const U& yEquivalent,
143 const V& movedFromPostConstruction,
144 const V& movedFromPostAssignment,
145 std::weak_ordering order)
146 {
147 return testing::check_semantics(
148 move_only_message(self.report(description)),
149 self.m_Logger,
150 std::forward<T>(x),
151 std::forward<T>(y),
152 xEquivalent,
153 yEquivalent,
154 optional_ref<const V>{movedFromPostConstruction},
155 optional_ref<const V>{movedFromPostAssignment},
156 order
157 );
158 }
159
165 template<moveonly T, class U, class Self>
166 requires std::totally_ordered<T> && checkable_against_for_semantics<Mode, T, U>
167 bool check_semantics(this Self& self,
168 const reporter& description,
169 T&& x,
170 T&& y,
171 const U& xEquivalent,
172 const U& yEquivalent,
173 std::weak_ordering order)
174 {
175 return testing::check_semantics(
176 move_only_message(self.report(description)),
177 self.m_Logger,
178 std::forward<T>(x),
179 std::forward<T>(y),
180 xEquivalent,
181 yEquivalent,
182 optional_ref<const U>{},
183 optional_ref<const U>{},
184 order
185 );
186 }
187
193 template
194 <
195 std::regular_invocable xMaker,
196 moveonly T=std::invoke_result_t<xMaker>,
198 class U,
199 class Self
200 >
201 requires std::totally_ordered<T> && checkable_against_for_semantics<Mode, T, U>
202 bool check_semantics(this Self& self,
203 const reporter& description,
204 xMaker xFn,
205 yMaker yFn,
206 const U& movedFromPostConstruction,
207 const U& movedFromPostAssignment,
208 std::weak_ordering order)
209 {
210 return self.check_semantics(
211 description,
212 xFn(),
213 yFn(),
214 xFn(),
215 yFn(),
216 movedFromPostConstruction,
217 movedFromPostAssignment,
218 order
219 );
220 }
221
223 template
224 <
225 class Self,
226 std::regular_invocable xMaker,
227 moveonly T=std::invoke_result_t<xMaker>,
229 >
230 requires std::totally_ordered<T>
231 bool check_semantics(this Self& self, const reporter& description, xMaker xFn, yMaker yFn, std::weak_ordering order)
232 {
233 return self.check_semantics(description, xFn(), yFn(), xFn(), yFn(), order);
234 }
235
236 protected:
237 ~move_only_extender() = default;
238
239 move_only_extender(move_only_extender&&) noexcept = default;
240 move_only_extender& operator=(move_only_extender&&) noexcept = default;
241 };
242
243 template<test_mode mode>
245
247 using move_only_test = canonical_move_only_test<test_mode::standard>;
248 using move_only_false_positive_test = canonical_move_only_test<test_mode::false_positive>;
249 using move_only_false_negative_test = canonical_move_only_test<test_mode::false_negative>;
250}
Core functionality for the testing framework.
Functions for checking semantics of types lacking copy semantics but which are otherwise regular.
Meta-programming utilities.
class template from which all concrete tests should derive.
Definition: FreeTestCore.hpp:144
class template for plugging into the checker class template to provide allocation checks for move-onl...
Definition: MoveOnlyTestCore.hpp:35
bool check_semantics(this Self &self, const reporter &description, T &&x, T &&y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment)
Definition: MoveOnlyTestCore.hpp:48
bool check_semantics(this Self &self, const reporter &description, xMaker xFn, yMaker yFn, std::weak_ordering order)
Prerequisite: xMaker() != yMaker(), with values consistent with order.
Definition: MoveOnlyTestCore.hpp:231
bool check_semantics(this Self &self, const reporter &description, T &&x, T &&y, const U &xEquivalent, const U &yEquivalent, std::weak_ordering order)
Definition: MoveOnlyTestCore.hpp:167
bool check_semantics(this Self &self, const reporter &description, xMaker xFn, yMaker yFn, const U &movedFromPostConstruction, const U &movedFromPostAssignment, std::weak_ordering order)
Definition: MoveOnlyTestCore.hpp:202
bool check_semantics(this Self &self, const reporter &description, T &&x, T &&y, const U &xEquivalent, const U &yEquivalent)
Definition: MoveOnlyTestCore.hpp:76
bool check_semantics(this Self &self, const reporter &description, T &&x, T &&y, const U &xEquivalent, const U &yEquivalent, const V &movedFromPostConstruction, const V &movedFromPostAssignment, std::weak_ordering order)
Definition: MoveOnlyTestCore.hpp:137
bool check_semantics(this Self &self, const reporter &description, xMaker xFn, yMaker yFn)
Prerequisite: xMaker() != yMaker()
Definition: MoveOnlyTestCore.hpp:125
bool check_semantics(this Self &self, const reporter &description, xMaker xFn, yMaker yFn, const U &movedFromPostConstruction, const U &movedFromPostAssignment)
Prerequisite: xMaker() != yMaker()
Definition: MoveOnlyTestCore.hpp:100
Definition: Output.hpp:186
The move-only version of sequoia::pseudoregular.
Definition: Concepts.hpp:43
Supplements std::regular_invocable.
Definition: Concepts.hpp:31