@micro-os-plus/micro-test-plus 4.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/CMakeLists.txt +74 -24
- package/README.md +3 -2
- package/include/micro-os-plus/micro-test-plus/README.md +6 -0
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
- package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
- package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
- package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
- package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
- package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
- package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
- package/include/micro-os-plus/micro-test-plus/inlines/expression-formatter-inlines.h +510 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
- package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +4 -4
- package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
- package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -0
- package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +231 -45
- package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
- package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +202 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
- package/include/micro-os-plus/micro-test-plus/math.h +5 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
- package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
- package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
- package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
- package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
- package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
- package/include/micro-os-plus/micro-test-plus/test.h +450 -506
- package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
- package/include/micro-os-plus/micro-test-plus/type-traits.h +30 -52
- package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
- package/include/micro-os-plus/micro-test-plus.h +33 -24
- package/meson.build +1 -0
- package/package.json +11 -3
- package/src/deferred-reporter.cpp +21 -2
- package/src/expression-formatter.cpp +289 -0
- package/src/reflection.cpp +3 -1
- package/src/reporter-human.cpp +31 -37
- package/src/reporter-tap.cpp +25 -35
- package/src/reporter.cpp +36 -231
- package/src/runner-totals.cpp +6 -3
- package/src/runner.cpp +131 -25
- package/src/test.cpp +120 -113
- package/src/timings.cpp +6 -5
- package/src/utility.cpp +1 -1
|
@@ -65,290 +65,282 @@
|
|
|
65
65
|
#endif
|
|
66
66
|
#endif
|
|
67
67
|
|
|
68
|
-
//
|
|
68
|
+
// ============================================================================
|
|
69
69
|
|
|
70
70
|
namespace micro_os_plus::micro_test_plus
|
|
71
71
|
{
|
|
72
|
+
// --------------------------------------------------------------------------
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @brief A single point-in-time measurement, wrapping a `timespec` value.
|
|
77
|
-
*
|
|
78
|
-
* @details
|
|
79
|
-
* `timestamp` stores one `timespec` sample obtained from the system clock.
|
|
80
|
-
* It is default-constructible (zero-initialises the `timespec`),
|
|
81
|
-
* copy-constructible, and move-constructible, so that it can be used
|
|
82
|
-
* efficiently in `std::optional<timestamp>` containers.
|
|
83
|
-
*
|
|
84
|
-
* The `has_clock()` predicate allows callers to determine whether a
|
|
85
|
-
* real-time clock is available on the target platform before relying on
|
|
86
|
-
* the stored value.
|
|
87
|
-
*
|
|
88
|
-
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
89
|
-
*/
|
|
90
|
-
class timestamp
|
|
74
|
+
namespace detail
|
|
91
75
|
{
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @brief Default constructor. Zero-initialises the internal `timespec`.
|
|
95
|
-
*/
|
|
96
|
-
timestamp () noexcept;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @brief Constructs a timestamp from an existing `timespec` value.
|
|
100
|
-
*
|
|
101
|
-
* @param ts The `timespec` value to store.
|
|
102
|
-
*/
|
|
103
|
-
timestamp (const timespec& ts) noexcept : value_{ ts }
|
|
104
|
-
{
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// `timespec` is trivially copyable, so copy and move are safe to default.
|
|
108
|
-
// Defaulting these operations allows `timestamp` to be used in contexts
|
|
109
|
-
// that require copyability or movability (e.g. containers, algorithms).
|
|
110
|
-
/**
|
|
111
|
-
* @brief Defaulted copy constructor.
|
|
112
|
-
*/
|
|
113
|
-
timestamp (const timestamp&) = default;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @brief Defaulted move constructor.
|
|
117
|
-
*/
|
|
118
|
-
timestamp (timestamp&&) = default;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @brief Defaulted copy assignment operator.
|
|
122
|
-
*/
|
|
123
|
-
timestamp&
|
|
124
|
-
operator= (const timestamp&) = default;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @brief Defaulted move assignment operator.
|
|
128
|
-
*/
|
|
129
|
-
timestamp&
|
|
130
|
-
operator= (timestamp&&) = default;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @brief Defaulted destructor.
|
|
134
|
-
*/
|
|
135
|
-
~timestamp () = default;
|
|
76
|
+
// ========================================================================
|
|
136
77
|
|
|
137
78
|
/**
|
|
138
|
-
* @brief
|
|
79
|
+
* @brief A single point-in-time measurement, wrapping a `timespec` value.
|
|
139
80
|
*
|
|
140
|
-
* @
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
|
|
145
|
-
bool
|
|
146
|
-
has_clock (void) const noexcept;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @brief Returns a mutable reference to the underlying `timespec` value.
|
|
81
|
+
* @details
|
|
82
|
+
* `timestamp` stores one `timespec` sample obtained from the system clock.
|
|
83
|
+
* It is default-constructible (zero-initialises the `timespec`),
|
|
84
|
+
* copy-constructible, and move-constructible, so that it can be used
|
|
85
|
+
* efficiently in `std::optional<timestamp>` containers.
|
|
150
86
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*/
|
|
155
|
-
[[nodiscard]] timespec&
|
|
156
|
-
value () noexcept
|
|
157
|
-
{
|
|
158
|
-
return value_;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @brief Returns a const reference to the underlying `timespec` value.
|
|
87
|
+
* The `has_clock()` predicate allows callers to determine whether a
|
|
88
|
+
* real-time clock is available on the target platform before relying on
|
|
89
|
+
* the stored value.
|
|
163
90
|
*
|
|
164
|
-
* @
|
|
165
|
-
* None.
|
|
166
|
-
* @return A const reference to the stored `timespec`.
|
|
91
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
167
92
|
*/
|
|
168
|
-
|
|
169
|
-
value () const noexcept
|
|
93
|
+
class timestamp
|
|
170
94
|
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
95
|
+
public:
|
|
96
|
+
/**
|
|
97
|
+
* @brief Default constructor. Zero-initialises the internal `timespec`.
|
|
98
|
+
*/
|
|
99
|
+
timestamp () noexcept;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @brief Constructs a timestamp from an existing `timespec` value.
|
|
103
|
+
*
|
|
104
|
+
* @param ts The `timespec` value to store.
|
|
105
|
+
*/
|
|
106
|
+
timestamp (const timespec& ts) noexcept;
|
|
107
|
+
|
|
108
|
+
// `timespec` is trivially copyable, so copy and move are safe to
|
|
109
|
+
// default. Defaulting these operations allows `timestamp` to be used in
|
|
110
|
+
// contexts that require copyability or movability (e.g. containers,
|
|
111
|
+
// algorithms).
|
|
112
|
+
/**
|
|
113
|
+
* @brief Defaulted copy constructor.
|
|
114
|
+
*/
|
|
115
|
+
timestamp (const timestamp&) = default;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @brief Defaulted move constructor.
|
|
119
|
+
*/
|
|
120
|
+
timestamp (timestamp&&) = default;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @brief Defaulted copy assignment operator.
|
|
124
|
+
*/
|
|
125
|
+
timestamp&
|
|
126
|
+
operator= (const timestamp&)
|
|
127
|
+
= default;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @brief Defaulted move assignment operator.
|
|
131
|
+
*/
|
|
132
|
+
timestamp&
|
|
133
|
+
operator= (timestamp&&)
|
|
134
|
+
= default;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @brief Defaulted destructor.
|
|
138
|
+
*/
|
|
139
|
+
~timestamp () = default;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @brief Returns true if a monotonic clock is available on this target.
|
|
143
|
+
*
|
|
144
|
+
* @par Parameters
|
|
145
|
+
* None.
|
|
146
|
+
* @retval true A real-time clock is available and timestamps are valid.
|
|
147
|
+
* @retval false No clock is available; timing data should be ignored.
|
|
148
|
+
*/
|
|
149
|
+
bool
|
|
150
|
+
has_clock (void) const noexcept;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @brief Returns a mutable reference to the underlying `timespec` value.
|
|
154
|
+
*
|
|
155
|
+
* @par Parameters
|
|
156
|
+
* None.
|
|
157
|
+
* @return A reference to the stored `timespec`.
|
|
158
|
+
*/
|
|
159
|
+
[[nodiscard]] timespec&
|
|
160
|
+
value () noexcept;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @brief Returns a const reference to the underlying `timespec` value.
|
|
164
|
+
*
|
|
165
|
+
* @par Parameters
|
|
166
|
+
* None.
|
|
167
|
+
* @return A const reference to the stored `timespec`.
|
|
168
|
+
*/
|
|
169
|
+
[[nodiscard]] const timespec&
|
|
170
|
+
value () const noexcept;
|
|
171
|
+
|
|
172
|
+
protected:
|
|
173
|
+
/**
|
|
174
|
+
* @brief The underlying `timespec` value.
|
|
175
|
+
*/
|
|
176
|
+
timespec value_{};
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// ========================================================================
|
|
223
180
|
|
|
224
181
|
/**
|
|
225
|
-
* @brief
|
|
226
|
-
*/
|
|
227
|
-
timestamps&
|
|
228
|
-
operator= (const timestamps&) = delete;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* @brief Deleted move assignment operator to prevent moving.
|
|
232
|
-
*/
|
|
233
|
-
timestamps&
|
|
234
|
-
operator= (timestamps&&) = delete;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @brief Defaulted destructor.
|
|
238
|
-
*/
|
|
239
|
-
~timestamps () = default;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* @brief Records the begin timestamp using the current system clock.
|
|
182
|
+
* @brief A begin/end timestamp pair used to measure elapsed time.
|
|
243
183
|
*
|
|
244
|
-
* @
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*/
|
|
249
|
-
void
|
|
250
|
-
timestamp_begin (void) noexcept;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* @brief Records the begin timestamp from a caller-supplied value.
|
|
184
|
+
* @details
|
|
185
|
+
* `timestamps` stores an optional begin `timestamp` and an optional end
|
|
186
|
+
* `timestamp`. When both are available, `compute_elapsed_time()` derives
|
|
187
|
+
* the elapsed interval in milliseconds and microseconds.
|
|
254
188
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
timestamp_begin (const timespec& ts) noexcept;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @brief Records the end timestamp using the current system clock.
|
|
189
|
+
* Typical usage in the framework:
|
|
190
|
+
* 1. Call `timestamp_begin()` just before the test suite or session
|
|
191
|
+
* body executes.
|
|
192
|
+
* 2. Call `timestamp_end()` immediately after it completes.
|
|
193
|
+
* 3. Pass the elapsed values to the reporter.
|
|
264
194
|
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Nothing.
|
|
269
|
-
*/
|
|
270
|
-
void
|
|
271
|
-
timestamp_end (void) noexcept;
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* @brief Records the end timestamp from a caller-supplied value.
|
|
195
|
+
* If the platform does not provide a monotonic clock, the `std::optional`
|
|
196
|
+
* members remain empty and `has_timestamps()` returns `false`, so that the
|
|
197
|
+
* reporter can skip timing output.
|
|
275
198
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* Nothing.
|
|
279
|
-
*/
|
|
280
|
-
void
|
|
281
|
-
timestamp_end (const timespec& ts) noexcept;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* @brief Returns true if the begin timestamp has been recorded.
|
|
199
|
+
* The class is non-copyable and non-movable to prevent accidental sharing
|
|
200
|
+
* of live timing state.
|
|
285
201
|
*
|
|
286
|
-
* @
|
|
287
|
-
* None.
|
|
288
|
-
* @retval true `timestamp_begin()` has been called.
|
|
289
|
-
* @retval false `timestamp_begin()` has not been called.
|
|
202
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
290
203
|
*/
|
|
291
|
-
|
|
292
|
-
has_begin () const noexcept
|
|
204
|
+
class timestamps
|
|
293
205
|
{
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
206
|
+
public:
|
|
207
|
+
/**
|
|
208
|
+
* @brief Default constructor. Both timestamps are uninitialised.
|
|
209
|
+
*/
|
|
210
|
+
timestamps () = default;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @brief Deleted copy constructor to prevent copying.
|
|
214
|
+
*/
|
|
215
|
+
timestamps (const timestamps&) = delete;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @brief Deleted move constructor to prevent moving.
|
|
219
|
+
*/
|
|
220
|
+
timestamps (timestamps&&) = delete;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @brief Deleted copy assignment operator to prevent copying.
|
|
224
|
+
*/
|
|
225
|
+
timestamps&
|
|
226
|
+
operator= (const timestamps&)
|
|
227
|
+
= delete;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @brief Deleted move assignment operator to prevent moving.
|
|
231
|
+
*/
|
|
232
|
+
timestamps&
|
|
233
|
+
operator= (timestamps&&)
|
|
234
|
+
= delete;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @brief Defaulted destructor.
|
|
238
|
+
*/
|
|
239
|
+
~timestamps () = default;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @brief Records the begin timestamp using the current system clock.
|
|
243
|
+
*
|
|
244
|
+
* @par Parameters
|
|
245
|
+
* None.
|
|
246
|
+
* @par Returns
|
|
247
|
+
* Nothing.
|
|
248
|
+
*/
|
|
249
|
+
void
|
|
250
|
+
timestamp_begin (void) noexcept;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @brief Records the begin timestamp from a caller-supplied value.
|
|
254
|
+
*
|
|
255
|
+
* @param ts The `timespec` value to use as the begin timestamp.
|
|
256
|
+
* @par Returns
|
|
257
|
+
* Nothing.
|
|
258
|
+
*/
|
|
259
|
+
void
|
|
260
|
+
timestamp_begin (const timespec& ts) noexcept;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @brief Records the end timestamp using the current system clock.
|
|
264
|
+
*
|
|
265
|
+
* @par Parameters
|
|
266
|
+
* None.
|
|
267
|
+
* @par Returns
|
|
268
|
+
* Nothing.
|
|
269
|
+
*/
|
|
270
|
+
void
|
|
271
|
+
timestamp_end (void) noexcept;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @brief Records the end timestamp from a caller-supplied value.
|
|
275
|
+
*
|
|
276
|
+
* @param ts The `timespec` value to use as the end timestamp.
|
|
277
|
+
* @par Returns
|
|
278
|
+
* Nothing.
|
|
279
|
+
*/
|
|
280
|
+
void
|
|
281
|
+
timestamp_end (const timespec& ts) noexcept;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @brief Returns true if the begin timestamp has been recorded.
|
|
285
|
+
*
|
|
286
|
+
* @par Parameters
|
|
287
|
+
* None.
|
|
288
|
+
* @retval true `timestamp_begin()` has been called.
|
|
289
|
+
* @retval false `timestamp_begin()` has not been called.
|
|
290
|
+
*/
|
|
291
|
+
bool
|
|
292
|
+
has_begin () const noexcept;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @brief Returns true if the end timestamp has been recorded.
|
|
296
|
+
*
|
|
297
|
+
* @par Parameters
|
|
298
|
+
* None.
|
|
299
|
+
* @retval true `timestamp_end()` has been called.
|
|
300
|
+
* @retval false `timestamp_end()` has not been called.
|
|
301
|
+
*/
|
|
302
|
+
bool
|
|
303
|
+
has_end () const noexcept;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @brief Returns true if both begin and end timestamps are available.
|
|
307
|
+
*
|
|
308
|
+
* @par Parameters
|
|
309
|
+
* None.
|
|
310
|
+
* @retval true Both timestamps are present and elapsed time can be
|
|
311
|
+
* computed.
|
|
312
|
+
* @retval false At least one timestamp is absent; elapsed time is not
|
|
313
|
+
* available.
|
|
314
|
+
*/
|
|
315
|
+
bool
|
|
316
|
+
has_timestamps (void) const noexcept;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @brief Computes the elapsed time between begin and end timestamps.
|
|
320
|
+
*
|
|
321
|
+
* @param[out] milliseconds The elapsed time in whole milliseconds.
|
|
322
|
+
* @param[out] microseconds The sub-millisecond remainder in
|
|
323
|
+
* microseconds.
|
|
324
|
+
*/
|
|
325
|
+
void
|
|
326
|
+
compute_elapsed_time (uint32_t& milliseconds,
|
|
327
|
+
uint32_t& microseconds) const;
|
|
328
|
+
|
|
329
|
+
protected:
|
|
330
|
+
/**
|
|
331
|
+
* @brief The timestamp recorded at the beginning of the test suite.
|
|
332
|
+
*/
|
|
333
|
+
std::optional<timestamp> begin_time_;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @brief The timestamp recorded at the end of the test suite.
|
|
337
|
+
*/
|
|
338
|
+
std::optional<timestamp> end_time_;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// ------------------------------------------------------------------------
|
|
342
|
+
} // namespace detail
|
|
350
343
|
// ==========================================================================
|
|
351
|
-
|
|
352
344
|
} // namespace micro_os_plus::micro_test_plus
|
|
353
345
|
|
|
354
346
|
#if defined(__GNUC__)
|
|
@@ -359,6 +351,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
359
351
|
|
|
360
352
|
#endif // __cplusplus
|
|
361
353
|
|
|
354
|
+
// ============================================================================
|
|
355
|
+
// Templates & constexpr implementations.
|
|
356
|
+
|
|
357
|
+
#include "inlines/timings-inlines.h"
|
|
358
|
+
|
|
362
359
|
// ----------------------------------------------------------------------------
|
|
363
360
|
|
|
364
361
|
#endif // MICRO_TEST_PLUS_TIMINGS_H_
|