@micro-os-plus/micro-test-plus 3.2.2 → 3.3.0
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/.cmake-format.yaml +11 -0
- package/CHANGELOG.md +417 -2
- package/CMakeLists.txt +33 -30
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/{xcdl.json → config/xcdl-build.json} +6 -6
- package/include/micro-os-plus/micro-test-plus/detail.h +1908 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
- package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
- package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +476 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
- package/include/micro-os-plus/micro-test-plus/math.h +217 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
- package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter-basic.h +289 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter-tap.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter.h +846 -0
- package/include/micro-os-plus/micro-test-plus/test-runner.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-suite.h +492 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
- package/include/micro-os-plus/micro-test-plus.h +172 -552
- package/meson.build +7 -5
- package/package.json +29 -34
- package/src/micro-test-plus.cpp +134 -37
- package/src/test-reporter-basic.cpp +466 -0
- package/src/test-reporter-tap.cpp +530 -0
- package/src/test-reporter.cpp +207 -240
- package/src/test-runner.cpp +135 -23
- package/src/test-suite.cpp +182 -10
- package/include/micro-os-plus/detail.h +0 -765
- package/include/micro-os-plus/inlines.h +0 -209
- package/include/micro-os-plus/literals.h +0 -512
- package/include/micro-os-plus/math.h +0 -204
- package/include/micro-os-plus/reflection.h +0 -139
- package/include/micro-os-plus/test-reporter-inlines.h +0 -230
- package/include/micro-os-plus/test-reporter.h +0 -356
- package/include/micro-os-plus/test-runner.h +0 -132
- package/include/micro-os-plus/test-suite.h +0 -306
- package/include/micro-os-plus/type-traits.h +0 -389
package/src/test-reporter.cpp
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
|
|
3
|
-
* Copyright (c) 2021 Liviu Ionescu. All rights reserved.
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
4
|
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software
|
|
6
|
-
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose is hereby granted, under the terms of the MIT license.
|
|
7
7
|
*
|
|
8
|
-
* If a copy of the license was not distributed with this file, it can
|
|
9
|
-
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can be
|
|
9
|
+
* obtained from https://opensource.org/licenses/mit.
|
|
10
10
|
*
|
|
11
11
|
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
12
|
* released under the terms of the Boost Version 1.0 Software License,
|
|
@@ -15,6 +15,34 @@
|
|
|
15
15
|
|
|
16
16
|
// ----------------------------------------------------------------------------
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* @brief C++ source file with implementations for the µTest++ test reporter
|
|
21
|
+
* methods.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This source file contains the core implementations for the test reporting
|
|
25
|
+
* facilities of the µTest++ framework. It provides the logic for formatting
|
|
26
|
+
* and outputting test results, including operator overloads for a wide range
|
|
27
|
+
* of value types, containers, and comparison expressions, as well as
|
|
28
|
+
* structured output for logical and exception-related assertions.
|
|
29
|
+
*
|
|
30
|
+
* The test reporter is responsible for presenting test outcomes in a clear,
|
|
31
|
+
* consistent, and expressive manner, supporting both value and pointer
|
|
32
|
+
* semantics, and providing detailed diagnostics for both successful and failed
|
|
33
|
+
* test cases. Special attention is given to formatting, colour highlighting,
|
|
34
|
+
* and extensibility, enabling professional and readable test reports suitable
|
|
35
|
+
* for embedded and general C++ development.
|
|
36
|
+
*
|
|
37
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus`
|
|
38
|
+
* namespace, ensuring clear separation from user code and minimising the risk
|
|
39
|
+
* of naming conflicts.
|
|
40
|
+
*
|
|
41
|
+
* This file must be included when building the µTest++ library.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
18
46
|
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
19
47
|
#include <micro-os-plus/config.h>
|
|
20
48
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
@@ -25,6 +53,7 @@
|
|
|
25
53
|
|
|
26
54
|
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
27
55
|
#if defined(__clang__)
|
|
56
|
+
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
|
28
57
|
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
29
58
|
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
30
59
|
#endif
|
|
@@ -33,83 +62,34 @@ namespace micro_os_plus::micro_test_plus
|
|
|
33
62
|
{
|
|
34
63
|
// --------------------------------------------------------------------------
|
|
35
64
|
|
|
36
|
-
test_reporter
|
|
37
|
-
endl (test_reporter& stream)
|
|
38
|
-
{
|
|
39
|
-
reporter.endline ();
|
|
40
|
-
return stream;
|
|
41
|
-
}
|
|
65
|
+
test_reporter::~test_reporter () = default;
|
|
42
66
|
|
|
43
67
|
// --------------------------------------------------------------------------
|
|
44
68
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!message.empty ())
|
|
56
|
-
{
|
|
57
|
-
*this << message.c_str ();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
void
|
|
62
|
-
test_reporter::output_pass_suffix_ (void)
|
|
63
|
-
{
|
|
64
|
-
*this << endl;
|
|
65
|
-
|
|
66
|
-
flush ();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
void
|
|
70
|
-
test_reporter::output_fail_prefix_ (
|
|
71
|
-
std::string& message, const reflection::source_location& location)
|
|
72
|
-
{
|
|
73
|
-
*this << colors_.fail;
|
|
74
|
-
if (is_in_test_case_)
|
|
75
|
-
{
|
|
76
|
-
*this << " ";
|
|
77
|
-
}
|
|
78
|
-
*this << " ✗ ";
|
|
79
|
-
*this << colors_.none;
|
|
80
|
-
if (!message.empty ())
|
|
81
|
-
{
|
|
82
|
-
*this << message.c_str ();
|
|
83
|
-
*this << " ";
|
|
84
|
-
}
|
|
85
|
-
*this << colors_.fail << "FAILED" << colors_.none;
|
|
86
|
-
#pragma GCC diagnostic push
|
|
87
|
-
#if defined(__clang__)
|
|
88
|
-
#pragma clang diagnostic ignored "-Wsign-conversion"
|
|
89
|
-
#elif defined(__GNUC__)
|
|
90
|
-
#pragma GCC diagnostic ignored "-Wnarrowing"
|
|
91
|
-
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
92
|
-
#endif
|
|
93
|
-
*this << " (" << reflection::short_name (location.file_name ()) << ":"
|
|
94
|
-
<< type_traits::genuine_integral_value<unsigned int>{
|
|
95
|
-
location.line ()
|
|
96
|
-
};
|
|
97
|
-
#pragma GCC diagnostic pop
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
void
|
|
101
|
-
test_reporter::output_fail_suffix_ (bool abort)
|
|
69
|
+
/**
|
|
70
|
+
* @details
|
|
71
|
+
* The `endl` function inserts a newline character into the specified
|
|
72
|
+
* `test_reporter` stream and flushes its output buffer. This operation
|
|
73
|
+
* ensures that each test output line is clearly separated and immediately
|
|
74
|
+
* visible, facilitating the readability and clarity of test results across
|
|
75
|
+
* all test cases and folders within the µTest++ framework.
|
|
76
|
+
*/
|
|
77
|
+
test_reporter&
|
|
78
|
+
endl (test_reporter& stream)
|
|
102
79
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
*this << " aborted...";
|
|
107
|
-
}
|
|
108
|
-
*this << endl;
|
|
109
|
-
|
|
110
|
-
flush ();
|
|
80
|
+
reporter->endline ();
|
|
81
|
+
return stream;
|
|
111
82
|
}
|
|
112
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @details
|
|
86
|
+
* This operator overload enables manipulators, such as `endl`, to be used
|
|
87
|
+
* with the `test_reporter` stream in a manner similar to standard C++
|
|
88
|
+
* streams. When a manipulator function is passed, it is invoked with the
|
|
89
|
+
* current `test_reporter` instance, allowing for seamless integration of
|
|
90
|
+
* stream operations and improved readability of test output across all test
|
|
91
|
+
* cases and folders.
|
|
92
|
+
*/
|
|
113
93
|
test_reporter&
|
|
114
94
|
test_reporter::operator<< (test_reporter& (*func) (test_reporter&))
|
|
115
95
|
{
|
|
@@ -118,19 +98,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
118
98
|
return *this;
|
|
119
99
|
}
|
|
120
100
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
test_reporter::flush (void)
|
|
130
|
-
{
|
|
131
|
-
fflush (stdout); // Sync STDOUT.
|
|
132
|
-
}
|
|
133
|
-
|
|
101
|
+
/**
|
|
102
|
+
* @details
|
|
103
|
+
* This operator overload appends the contents of the provided
|
|
104
|
+
* `std::string_view` to the internal output buffer of the `test_reporter`.
|
|
105
|
+
* It enables seamless streaming of string data into the reporter, supporting
|
|
106
|
+
* clear and efficient formatting of test output across all test cases and
|
|
107
|
+
* folders.
|
|
108
|
+
*/
|
|
134
109
|
test_reporter&
|
|
135
110
|
test_reporter::operator<< (std::string_view sv)
|
|
136
111
|
{
|
|
@@ -138,6 +113,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
138
113
|
return *this;
|
|
139
114
|
}
|
|
140
115
|
|
|
116
|
+
/**
|
|
117
|
+
* @details
|
|
118
|
+
* This operator overload appends the specified character to the internal
|
|
119
|
+
* output buffer of the `test_reporter`. It enables efficient streaming of
|
|
120
|
+
* individual characters into the reporter, supporting precise and flexible
|
|
121
|
+
* formatting of test output across all test cases and folders.
|
|
122
|
+
*/
|
|
141
123
|
test_reporter&
|
|
142
124
|
test_reporter::operator<< (char c)
|
|
143
125
|
{
|
|
@@ -145,6 +127,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
145
127
|
return *this;
|
|
146
128
|
}
|
|
147
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @details
|
|
132
|
+
* This operator overload appends the contents of the provided C-style string
|
|
133
|
+
* to the internal output buffer of the `test_reporter`. It enables efficient
|
|
134
|
+
* streaming of string literals and character arrays into the reporter,
|
|
135
|
+
* supporting clear and flexible formatting of test output across all test
|
|
136
|
+
* cases and folders.
|
|
137
|
+
*/
|
|
148
138
|
test_reporter&
|
|
149
139
|
test_reporter::operator<< (const char* s)
|
|
150
140
|
{
|
|
@@ -152,6 +142,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
152
142
|
return *this;
|
|
153
143
|
}
|
|
154
144
|
|
|
145
|
+
/**
|
|
146
|
+
* @details
|
|
147
|
+
* This operator overload appends the contents of the provided modifiable
|
|
148
|
+
* C-style string to the internal output buffer of the `test_reporter`. It
|
|
149
|
+
* enables efficient streaming of mutable string data into the reporter,
|
|
150
|
+
* supporting clear and flexible formatting of test output across all test
|
|
151
|
+
* cases and folders.
|
|
152
|
+
*/
|
|
155
153
|
test_reporter&
|
|
156
154
|
test_reporter::operator<< (char* s)
|
|
157
155
|
{
|
|
@@ -159,6 +157,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
159
157
|
return *this;
|
|
160
158
|
}
|
|
161
159
|
|
|
160
|
+
/**
|
|
161
|
+
* @details
|
|
162
|
+
* This operator overload appends the string representation of the specified
|
|
163
|
+
* boolean value to the internal output buffer of the `test_reporter`. It
|
|
164
|
+
* enables clear and direct streaming of boolean results into the reporter,
|
|
165
|
+
* supporting precise and readable formatting of test output across all test
|
|
166
|
+
* cases and folders.
|
|
167
|
+
*/
|
|
162
168
|
test_reporter&
|
|
163
169
|
test_reporter::operator<< (bool v)
|
|
164
170
|
{
|
|
@@ -166,6 +172,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
166
172
|
return *this;
|
|
167
173
|
}
|
|
168
174
|
|
|
175
|
+
/**
|
|
176
|
+
* @details
|
|
177
|
+
* This operator overload appends the string "nullptr" to the internal output
|
|
178
|
+
* buffer of the `test_reporter`. It enables clear and explicit streaming of
|
|
179
|
+
* null pointer values into the reporter, supporting precise and readable
|
|
180
|
+
* formatting of test output across all test cases and folders.
|
|
181
|
+
*/
|
|
169
182
|
test_reporter&
|
|
170
183
|
test_reporter::operator<< (std::nullptr_t)
|
|
171
184
|
{
|
|
@@ -173,6 +186,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
173
186
|
return *this;
|
|
174
187
|
}
|
|
175
188
|
|
|
189
|
+
/**
|
|
190
|
+
* @details
|
|
191
|
+
* This operator overload appends the string representation of the specified
|
|
192
|
+
* signed character to the internal output buffer of the `test_reporter`. It
|
|
193
|
+
* enables precise and readable streaming of character values into the
|
|
194
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
195
|
+
* and folders.
|
|
196
|
+
*/
|
|
176
197
|
test_reporter&
|
|
177
198
|
test_reporter::operator<< (signed char c)
|
|
178
199
|
{
|
|
@@ -181,6 +202,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
181
202
|
return *this;
|
|
182
203
|
}
|
|
183
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @details
|
|
207
|
+
* This operator overload appends the string representation of the specified
|
|
208
|
+
* unsigned character to the internal output buffer of the `test_reporter`.
|
|
209
|
+
* It enables precise and readable streaming of unsigned character values
|
|
210
|
+
* into the reporter, supporting clear formatting of test output across all
|
|
211
|
+
* test cases and folders.
|
|
212
|
+
*/
|
|
184
213
|
test_reporter&
|
|
185
214
|
test_reporter::operator<< (unsigned char c)
|
|
186
215
|
{
|
|
@@ -189,6 +218,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
189
218
|
return *this;
|
|
190
219
|
}
|
|
191
220
|
|
|
221
|
+
/**
|
|
222
|
+
* @details
|
|
223
|
+
* This operator overload appends the string representation of the specified
|
|
224
|
+
* signed short integer to the internal output buffer of the `test_reporter`.
|
|
225
|
+
* It enables precise and readable streaming of signed short values into the
|
|
226
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
227
|
+
* and folders.
|
|
228
|
+
*/
|
|
192
229
|
test_reporter&
|
|
193
230
|
test_reporter::operator<< (signed short v)
|
|
194
231
|
{
|
|
@@ -197,6 +234,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
197
234
|
return *this;
|
|
198
235
|
}
|
|
199
236
|
|
|
237
|
+
/**
|
|
238
|
+
* @details
|
|
239
|
+
* This operator overload appends the string representation of the specified
|
|
240
|
+
* unsigned short integer to the internal output buffer of the
|
|
241
|
+
* `test_reporter`. It enables precise and readable streaming of unsigned
|
|
242
|
+
* short values into the reporter, supporting clear formatting of test output
|
|
243
|
+
* across all test cases and folders.
|
|
244
|
+
*/
|
|
200
245
|
test_reporter&
|
|
201
246
|
test_reporter::operator<< (unsigned short v)
|
|
202
247
|
{
|
|
@@ -205,6 +250,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
205
250
|
return *this;
|
|
206
251
|
}
|
|
207
252
|
|
|
253
|
+
/**
|
|
254
|
+
* @details
|
|
255
|
+
* This operator overload appends the string representation of the specified
|
|
256
|
+
* signed integer to the internal output buffer of the `test_reporter`. It
|
|
257
|
+
* enables precise and readable streaming of signed integer values into the
|
|
258
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
259
|
+
* and folders.
|
|
260
|
+
*/
|
|
208
261
|
test_reporter&
|
|
209
262
|
test_reporter::operator<< (signed int v)
|
|
210
263
|
{
|
|
@@ -212,6 +265,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
212
265
|
return *this;
|
|
213
266
|
}
|
|
214
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @details
|
|
270
|
+
* This operator overload appends the string representation of the specified
|
|
271
|
+
* unsigned integer to the internal output buffer of the `test_reporter`. It
|
|
272
|
+
* enables precise and readable streaming of unsigned integer values into the
|
|
273
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
274
|
+
* and folders.
|
|
275
|
+
*/
|
|
215
276
|
test_reporter&
|
|
216
277
|
test_reporter::operator<< (unsigned int v)
|
|
217
278
|
{
|
|
@@ -220,6 +281,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
220
281
|
return *this;
|
|
221
282
|
}
|
|
222
283
|
|
|
284
|
+
/**
|
|
285
|
+
* @details
|
|
286
|
+
* This operator overload appends the string representation of the specified
|
|
287
|
+
* signed long integer to the internal output buffer of the `test_reporter`.
|
|
288
|
+
* It enables precise and readable streaming of signed long values into the
|
|
289
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
290
|
+
* and folders.
|
|
291
|
+
*/
|
|
223
292
|
test_reporter&
|
|
224
293
|
test_reporter::operator<< (signed long v)
|
|
225
294
|
{
|
|
@@ -228,6 +297,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
228
297
|
return *this;
|
|
229
298
|
}
|
|
230
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @details
|
|
302
|
+
* This operator overload appends the string representation of the specified
|
|
303
|
+
* unsigned long integer to the internal output buffer of the
|
|
304
|
+
* `test_reporter`. It enables precise and readable streaming of unsigned
|
|
305
|
+
* long values into the reporter, supporting clear formatting of test output
|
|
306
|
+
* across all test cases and folders.
|
|
307
|
+
*/
|
|
231
308
|
test_reporter&
|
|
232
309
|
test_reporter::operator<< (unsigned long v)
|
|
233
310
|
{
|
|
@@ -236,6 +313,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
236
313
|
return *this;
|
|
237
314
|
}
|
|
238
315
|
|
|
316
|
+
/**
|
|
317
|
+
* @details
|
|
318
|
+
* This operator overload appends the string representation of the specified
|
|
319
|
+
* signed long long integer to the internal output buffer of the
|
|
320
|
+
* `test_reporter`. It enables precise and readable streaming of signed long
|
|
321
|
+
* long values into the reporter, supporting clear formatting of test output
|
|
322
|
+
* across all test cases and folders.
|
|
323
|
+
*/
|
|
239
324
|
test_reporter&
|
|
240
325
|
test_reporter::operator<< (signed long long v)
|
|
241
326
|
{
|
|
@@ -244,6 +329,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
244
329
|
return *this;
|
|
245
330
|
}
|
|
246
331
|
|
|
332
|
+
/**
|
|
333
|
+
* @details
|
|
334
|
+
* This operator overload appends the string representation of the specified
|
|
335
|
+
* unsigned long long integer to the internal output buffer of the
|
|
336
|
+
* `test_reporter`. It enables precise and readable streaming of unsigned
|
|
337
|
+
* long long values into the reporter, supporting clear formatting of test
|
|
338
|
+
* output across all test cases and folders.
|
|
339
|
+
*/
|
|
247
340
|
test_reporter&
|
|
248
341
|
test_reporter::operator<< (unsigned long long v)
|
|
249
342
|
{
|
|
@@ -252,6 +345,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
252
345
|
return *this;
|
|
253
346
|
}
|
|
254
347
|
|
|
348
|
+
/**
|
|
349
|
+
* @details
|
|
350
|
+
* This operator overload appends the string representation of the specified
|
|
351
|
+
* floating-point value to the internal output buffer of the `test_reporter`,
|
|
352
|
+
* followed by the character 'f' to indicate a float type. It enables precise
|
|
353
|
+
* and readable streaming of float values into the reporter, supporting clear
|
|
354
|
+
* formatting of test output across all test cases and folders.
|
|
355
|
+
*/
|
|
255
356
|
test_reporter&
|
|
256
357
|
test_reporter::operator<< (float v)
|
|
257
358
|
{
|
|
@@ -260,6 +361,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
260
361
|
return *this;
|
|
261
362
|
}
|
|
262
363
|
|
|
364
|
+
/**
|
|
365
|
+
* @details
|
|
366
|
+
* This operator overload appends the string representation of the specified
|
|
367
|
+
* double-precision floating-point value to the internal output buffer of the
|
|
368
|
+
* `test_reporter`. It enables precise and readable streaming of double
|
|
369
|
+
* values into the reporter, supporting clear formatting of test output
|
|
370
|
+
* across all test cases and folders.
|
|
371
|
+
*/
|
|
263
372
|
test_reporter&
|
|
264
373
|
test_reporter::operator<< (double v)
|
|
265
374
|
{
|
|
@@ -267,6 +376,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
267
376
|
return *this;
|
|
268
377
|
}
|
|
269
378
|
|
|
379
|
+
/**
|
|
380
|
+
* @details
|
|
381
|
+
* This operator overload appends the string representation of the specified
|
|
382
|
+
* long double-precision floating-point value to the internal output buffer
|
|
383
|
+
* of the `test_reporter`, followed by the character 'l' to indicate a long
|
|
384
|
+
* double type. It enables precise and readable streaming of long double
|
|
385
|
+
* values into the reporter, supporting clear formatting of test output
|
|
386
|
+
* across all test cases and folders.
|
|
387
|
+
*/
|
|
270
388
|
test_reporter&
|
|
271
389
|
test_reporter::operator<< (long double v)
|
|
272
390
|
{
|
|
@@ -275,157 +393,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
275
393
|
return *this;
|
|
276
394
|
}
|
|
277
395
|
|
|
278
|
-
void
|
|
279
|
-
test_reporter::begin_test_case ([[maybe_unused]] const char* name)
|
|
280
|
-
{
|
|
281
|
-
is_in_test_case_ = true;
|
|
282
|
-
|
|
283
|
-
if (!out_.empty () && (verbosity == verbosity::verbose))
|
|
284
|
-
{
|
|
285
|
-
if (add_empty_line)
|
|
286
|
-
{
|
|
287
|
-
printf ("\n");
|
|
288
|
-
}
|
|
289
|
-
output ();
|
|
290
|
-
add_empty_line = true;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
out_.clear ();
|
|
294
|
-
|
|
295
|
-
flush ();
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
void
|
|
299
|
-
test_reporter::end_test_case ([[maybe_unused]] const char* name)
|
|
300
|
-
{
|
|
301
|
-
if (verbosity == verbosity::normal || verbosity == verbosity::verbose)
|
|
302
|
-
{
|
|
303
|
-
if (current_test_suite->current_test_case.failed_checks > 0)
|
|
304
|
-
{
|
|
305
|
-
if (true /* add_empty_line */)
|
|
306
|
-
{
|
|
307
|
-
printf ("\n");
|
|
308
|
-
}
|
|
309
|
-
printf (" • %s - test case started\n", name);
|
|
310
|
-
output ();
|
|
311
|
-
printf (
|
|
312
|
-
" %s✗%s %s - test case %sFAILED%s (%d %s passed, %d "
|
|
313
|
-
"failed)\n",
|
|
314
|
-
colors_.fail, colors_.none, name, colors_.fail, colors_.none,
|
|
315
|
-
current_test_suite->current_test_case.successful_checks,
|
|
316
|
-
current_test_suite->current_test_case.successful_checks == 1
|
|
317
|
-
? "check"
|
|
318
|
-
: "checks",
|
|
319
|
-
current_test_suite->current_test_case.failed_checks);
|
|
320
|
-
add_empty_line = true;
|
|
321
|
-
}
|
|
322
|
-
else
|
|
323
|
-
{
|
|
324
|
-
if (add_empty_line)
|
|
325
|
-
{
|
|
326
|
-
printf ("\n");
|
|
327
|
-
}
|
|
328
|
-
if (verbosity == verbosity::verbose)
|
|
329
|
-
{
|
|
330
|
-
printf (" • %s - test case started\n", name);
|
|
331
|
-
output ();
|
|
332
|
-
printf (
|
|
333
|
-
" %s✓%s %s - test case passed (%d %s)\n", colors_.pass,
|
|
334
|
-
colors_.none, name,
|
|
335
|
-
current_test_suite->current_test_case.successful_checks,
|
|
336
|
-
current_test_suite->current_test_case.successful_checks
|
|
337
|
-
== 1
|
|
338
|
-
? "check"
|
|
339
|
-
: "checks");
|
|
340
|
-
|
|
341
|
-
add_empty_line = true;
|
|
342
|
-
}
|
|
343
|
-
else
|
|
344
|
-
{
|
|
345
|
-
printf (
|
|
346
|
-
" %s✓%s %s - test case passed (%d %s)\n", colors_.pass,
|
|
347
|
-
colors_.none, name,
|
|
348
|
-
current_test_suite->current_test_case.successful_checks,
|
|
349
|
-
current_test_suite->current_test_case.successful_checks
|
|
350
|
-
== 1
|
|
351
|
-
? "check"
|
|
352
|
-
: "checks");
|
|
353
|
-
|
|
354
|
-
add_empty_line = false;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
out_.clear ();
|
|
360
|
-
flush ();
|
|
361
|
-
|
|
362
|
-
is_in_test_case_ = false;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
void
|
|
366
|
-
test_reporter::begin_test_suite (const char* name)
|
|
367
|
-
{
|
|
368
|
-
if (add_empty_line)
|
|
369
|
-
{
|
|
370
|
-
flush ();
|
|
371
|
-
printf ("\n");
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (verbosity == verbosity::silent || verbosity == verbosity::quiet)
|
|
375
|
-
{
|
|
376
|
-
add_empty_line = false;
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
printf ("• %s - test suite started\n", name);
|
|
381
|
-
|
|
382
|
-
add_empty_line = true;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
void
|
|
386
|
-
test_reporter::end_test_suite (test_suite_base& suite)
|
|
387
|
-
{
|
|
388
|
-
if (verbosity == verbosity::silent)
|
|
389
|
-
{
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (suite.test_cases () > 0 && verbosity != verbosity::quiet)
|
|
394
|
-
{
|
|
395
|
-
printf ("\n");
|
|
396
|
-
add_empty_line = true;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Also fail if none passed.
|
|
400
|
-
if (suite.failed_checks () == 0 && suite.successful_checks () != 0)
|
|
401
|
-
{
|
|
402
|
-
printf ("%s✓%s %s - test suite passed (%d %s in %d test %s)\n",
|
|
403
|
-
colors_.pass, colors_.none, suite.name (),
|
|
404
|
-
suite.successful_checks (),
|
|
405
|
-
suite.successful_checks () == 1 ? "check" : "checks",
|
|
406
|
-
suite.test_cases (),
|
|
407
|
-
suite.test_cases () == 1 ? "case" : "cases");
|
|
408
|
-
}
|
|
409
|
-
else
|
|
410
|
-
{
|
|
411
|
-
printf ("%s✗%s %s - test suite %sFAILED%s (%d %s passed, %d failed, "
|
|
412
|
-
"in %d test %s)\n",
|
|
413
|
-
colors_.fail, colors_.none, suite.name (), colors_.fail,
|
|
414
|
-
colors_.none, suite.successful_checks (),
|
|
415
|
-
suite.successful_checks () == 1 ? "check" : "checks",
|
|
416
|
-
suite.failed_checks (), suite.test_cases (),
|
|
417
|
-
suite.test_cases () == 1 ? "case" : "cases");
|
|
418
|
-
}
|
|
419
|
-
flush ();
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
void
|
|
423
|
-
test_reporter::output (void)
|
|
424
|
-
{
|
|
425
|
-
printf ("%s", out_.c_str ()); // No `\n` here.
|
|
426
|
-
out_.clear ();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
396
|
// --------------------------------------------------------------------------
|
|
430
397
|
} // namespace micro_os_plus::micro_test_plus
|
|
431
398
|
|