@@ -120,6 +120,16 @@ namespace v1 {
120
120
// / Stringifies a status.
121
121
const char * stringify (utest::v1::status_t status);
122
122
123
+ /* * POD version of the class control_t.
124
+ * It is used to instantiate const control_t objects as PODs
125
+ * and prevent them to be included in the final binary.
126
+ * @note: control_pod_t can be converted to control_t by copy construction.
127
+ */
128
+ struct base_control_t {
129
+ repeat_t repeat;
130
+ uint32_t timeout;
131
+ };
132
+
123
133
/* * Control class for specifying test case attributes
124
134
*
125
135
* This class encapsulated control information about test cases which, when returned from
@@ -148,18 +158,21 @@ namespace v1 {
148
158
*
149
159
* In the future, more control information may be added transparently and backwards compatible.
150
160
*/
151
- struct control_t
161
+ struct control_t : private base_control_t
152
162
{
153
- control_t () : repeat( REPEAT_UNDECLR), timeout( TIMEOUT_UNDECLR) {}
163
+ control_t () : base_control_t ( make_base_control_t ( REPEAT_UNDECLR, TIMEOUT_UNDECLR) ) {}
154
164
155
165
control_t (repeat_t repeat, uint32_t timeout_ms) :
156
- repeat ( repeat), timeout( timeout_ms) {}
166
+ base_control_t ( make_base_control_t ( repeat, timeout_ms) ) {}
157
167
158
168
control_t (repeat_t repeat) :
159
- repeat ( repeat), timeout( TIMEOUT_UNDECLR) {}
169
+ base_control_t ( make_base_control_t ( repeat, TIMEOUT_UNDECLR) ) {}
160
170
161
171
control_t (uint32_t timeout_ms) :
162
- repeat (REPEAT_UNDECLR), timeout(timeout_ms) {}
172
+ base_control_t (make_base_control_t (REPEAT_UNDECLR, timeout_ms)) {}
173
+
174
+ control_t (base_control_t other) :
175
+ base_control_t (other) {}
163
176
164
177
control_t
165
178
inline operator +(const control_t & rhs) const {
@@ -196,25 +209,31 @@ namespace v1 {
196
209
}
197
210
198
211
private:
199
- repeat_t repeat;
200
- uint32_t timeout;
212
+ static base_control_t make_base_control_t (repeat_t repeat, uint32_t timeout) {
213
+ base_control_t result = {
214
+ repeat,
215
+ timeout
216
+ };
217
+ return result;
218
+ }
219
+
201
220
friend class Harness ;
202
221
};
203
222
204
223
// / does not repeat this test case and immediately moves on to the next one without timeout
205
- extern const control_t CaseNext;
224
+ extern const base_control_t CaseNext;
206
225
207
226
// / does not repeat this test case, moves on to the next one
208
- extern const control_t CaseNoRepeat;
227
+ extern const base_control_t CaseNoRepeat;
209
228
// / repeats the test case handler with calling teardown and setup handlers
210
- extern const control_t CaseRepeatAll;
229
+ extern const base_control_t CaseRepeatAll;
211
230
// / repeats only the test case handler without calling teardown and setup handlers
212
- extern const control_t CaseRepeatHandler;
231
+ extern const base_control_t CaseRepeatHandler;
213
232
214
233
// / No timeout, immediately moves on to the next case, but allows repeats
215
- extern const control_t CaseNoTimeout;
234
+ extern const base_control_t CaseNoTimeout;
216
235
// / Awaits until the callback is validated and never times out. Use with caution!
217
- extern const control_t CaseAwait;
236
+ extern const base_control_t CaseAwait;
218
237
// / Alias class for asynchronous timeout control in milliseconds
219
238
inline control_t CaseTimeout (uint32_t ms) { return ms; }
220
239
@@ -342,10 +361,10 @@ namespace v1 {
342
361
343
362
// deprecations
344
363
__deprecated_message (" Use CaseRepeatAll instead." )
345
- extern const control_t CaseRepeat;
364
+ extern const base_control_t CaseRepeat;
346
365
347
366
__deprecated_message (" Use CaseRepeatHandler instead." )
348
- extern const control_t CaseRepeatHandlerOnly;
367
+ extern const base_control_t CaseRepeatHandlerOnly;
349
368
350
369
__deprecated_message (" Use REASON_NONE instead." ) const failure_reason_t FAILURE_NONE = REASON_NONE;
351
370
__deprecated_message (" Use REASON_UNKNOWN instead." ) const failure_reason_t FAILURE_UNKNOWN = REASON_UNKNOWN;
0 commit comments