@micro-os-plus/micro-test-plus 3.1.1 → 3.2.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/CHANGELOG.md +347 -1
- package/CMakeLists.txt +9 -11
- package/README.md +12 -1226
- package/include/micro-os-plus/detail.h +69 -36
- package/include/micro-os-plus/inlines.h +50 -7
- package/include/micro-os-plus/literals.h +257 -29
- package/include/micro-os-plus/micro-test-plus.h +257 -68
- package/include/micro-os-plus/reflection.h +10 -5
- package/include/micro-os-plus/test-reporter-inlines.h +2 -2
- package/include/micro-os-plus/test-reporter.h +14 -4
- package/include/micro-os-plus/test-runner.h +3 -2
- package/include/micro-os-plus/test-suite.h +72 -6
- package/include/micro-os-plus/type-traits.h +54 -10
- package/meson.build +23 -17
- package/package.json +25 -535
- package/src/micro-test-plus.cpp +45 -0
- package/src/test-reporter.cpp +11 -1
- package/src/test-runner.cpp +11 -4
|
@@ -41,12 +41,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
41
41
|
// --------------------------------------------------------------------------
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @brief
|
|
44
|
+
* @brief Namespace with implementation details, not part of the public API.
|
|
45
45
|
*/
|
|
46
46
|
namespace detail
|
|
47
47
|
{
|
|
48
48
|
/**
|
|
49
49
|
* @brief An object used to pass assertion parameters to the evaluator.
|
|
50
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
50
51
|
*/
|
|
51
52
|
template <class Expr_T>
|
|
52
53
|
struct assertion
|
|
@@ -87,7 +88,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
87
88
|
[[nodiscard]] constexpr auto
|
|
88
89
|
get (const T& t)
|
|
89
90
|
{
|
|
90
|
-
// Call the variadic function,
|
|
91
|
+
// Call the variadic function, basically to force it return `t`.
|
|
91
92
|
return get_impl (t, 0);
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -95,6 +96,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* @brief Equality comparator.
|
|
99
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
98
100
|
*/
|
|
99
101
|
template <class Lhs_T, class Rhs_T>
|
|
100
102
|
struct eq_ : type_traits::op
|
|
@@ -117,16 +119,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
117
119
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
118
120
|
#endif
|
|
119
121
|
#endif
|
|
120
|
-
if constexpr (type_traits::has_value_v<
|
|
121
|
-
|
|
122
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
123
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
122
124
|
{
|
|
123
125
|
// If both types have values (like numeric constants),
|
|
124
126
|
// compare them directly.
|
|
125
127
|
return Lhs_T::value == Rhs_T::value;
|
|
126
128
|
}
|
|
127
|
-
else if constexpr (
|
|
128
|
-
|
|
129
|
-
Lhs_T> and type_traits::has_epsilon_v<Rhs_T>)
|
|
129
|
+
else if constexpr (type_traits::has_epsilon_v<Lhs_T>
|
|
130
|
+
and type_traits::has_epsilon_v<Rhs_T>)
|
|
130
131
|
{
|
|
131
132
|
// If both values have precision, compare them using
|
|
132
133
|
// the smalles precision.
|
|
@@ -156,7 +157,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
156
157
|
{
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
[[nodiscard]] constexpr
|
|
160
|
+
[[nodiscard]] constexpr
|
|
161
|
+
operator bool () const
|
|
160
162
|
{
|
|
161
163
|
return value_;
|
|
162
164
|
}
|
|
@@ -180,6 +182,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
180
182
|
|
|
181
183
|
/**
|
|
182
184
|
* @brief Non-equality comparator.
|
|
185
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
183
186
|
*/
|
|
184
187
|
template <class Lhs_T, class Rhs_T>
|
|
185
188
|
struct ne_ : type_traits::op
|
|
@@ -201,14 +204,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
201
204
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
202
205
|
#endif
|
|
203
206
|
#endif
|
|
204
|
-
if constexpr (type_traits::has_value_v<
|
|
205
|
-
|
|
207
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
208
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
206
209
|
{
|
|
207
210
|
return Lhs_T::value != Rhs_T::value;
|
|
208
211
|
}
|
|
209
|
-
else if constexpr (
|
|
210
|
-
|
|
211
|
-
Lhs_T> and type_traits::has_epsilon_v<Rhs_T>)
|
|
212
|
+
else if constexpr (type_traits::has_epsilon_v<Lhs_T>
|
|
213
|
+
and type_traits::has_epsilon_v<Rhs_T>)
|
|
212
214
|
{
|
|
213
215
|
return math::abs (get (lhs_) - get (rhs_))
|
|
214
216
|
> math::min_value (Lhs_T::epsilon, Rhs_T::epsilon);
|
|
@@ -232,7 +234,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
232
234
|
{
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
[[nodiscard]] constexpr
|
|
237
|
+
[[nodiscard]] constexpr
|
|
238
|
+
operator bool () const
|
|
236
239
|
{
|
|
237
240
|
return value_;
|
|
238
241
|
}
|
|
@@ -254,6 +257,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
254
257
|
|
|
255
258
|
/**
|
|
256
259
|
* @brief Greater than comparator.
|
|
260
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
257
261
|
*/
|
|
258
262
|
template <class Lhs_T, class Rhs_T>
|
|
259
263
|
struct gt_ : type_traits::op
|
|
@@ -272,8 +276,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
272
276
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
273
277
|
#endif
|
|
274
278
|
#endif
|
|
275
|
-
if constexpr (type_traits::has_value_v<
|
|
276
|
-
|
|
279
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
280
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
277
281
|
{
|
|
278
282
|
return Lhs_T::value > Rhs_T::value;
|
|
279
283
|
}
|
|
@@ -288,7 +292,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
288
292
|
{
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
[[nodiscard]] constexpr
|
|
295
|
+
[[nodiscard]] constexpr
|
|
296
|
+
operator bool () const
|
|
292
297
|
{
|
|
293
298
|
return value_;
|
|
294
299
|
}
|
|
@@ -310,6 +315,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
310
315
|
|
|
311
316
|
/**
|
|
312
317
|
* @brief Greater than or equal comparator.
|
|
318
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
313
319
|
*/
|
|
314
320
|
template <class Lhs_T, class Rhs_T>
|
|
315
321
|
struct ge_ : type_traits::op
|
|
@@ -328,8 +334,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
328
334
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
329
335
|
#endif
|
|
330
336
|
#endif
|
|
331
|
-
if constexpr (type_traits::has_value_v<
|
|
332
|
-
|
|
337
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
338
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
333
339
|
{
|
|
334
340
|
return Lhs_T::value >= Rhs_T::value;
|
|
335
341
|
}
|
|
@@ -344,7 +350,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
344
350
|
{
|
|
345
351
|
}
|
|
346
352
|
|
|
347
|
-
[[nodiscard]] constexpr
|
|
353
|
+
[[nodiscard]] constexpr
|
|
354
|
+
operator bool () const
|
|
348
355
|
{
|
|
349
356
|
return value_;
|
|
350
357
|
}
|
|
@@ -366,6 +373,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
366
373
|
|
|
367
374
|
/**
|
|
368
375
|
* @brief Less than comparator.
|
|
376
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
369
377
|
*/
|
|
370
378
|
template <class Lhs_T, class Rhs_T>
|
|
371
379
|
struct lt_ : type_traits::op
|
|
@@ -384,8 +392,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
384
392
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
385
393
|
#endif
|
|
386
394
|
#endif
|
|
387
|
-
if constexpr (type_traits::has_value_v<
|
|
388
|
-
|
|
395
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
396
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
389
397
|
{
|
|
390
398
|
return Lhs_T::value < Rhs_T::value;
|
|
391
399
|
}
|
|
@@ -400,7 +408,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
400
408
|
{
|
|
401
409
|
}
|
|
402
410
|
|
|
403
|
-
[[nodiscard]] constexpr
|
|
411
|
+
[[nodiscard]] constexpr
|
|
412
|
+
operator bool () const
|
|
404
413
|
{
|
|
405
414
|
return value_;
|
|
406
415
|
}
|
|
@@ -423,6 +432,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
423
432
|
|
|
424
433
|
/**
|
|
425
434
|
* @brief Less than or equal comparator.
|
|
435
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
426
436
|
*/
|
|
427
437
|
template <class Lhs_T, class Rhs_T>
|
|
428
438
|
struct le_ : type_traits::op
|
|
@@ -441,8 +451,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
441
451
|
#pragma clang diagnostic ignored "-Wpedantic"
|
|
442
452
|
#endif
|
|
443
453
|
#endif
|
|
444
|
-
if constexpr (type_traits::has_value_v<
|
|
445
|
-
|
|
454
|
+
if constexpr (type_traits::has_value_v<Lhs_T>
|
|
455
|
+
and type_traits::has_value_v<Rhs_T>)
|
|
446
456
|
{
|
|
447
457
|
return Lhs_T::value <= Rhs_T::value;
|
|
448
458
|
}
|
|
@@ -457,7 +467,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
457
467
|
{
|
|
458
468
|
}
|
|
459
469
|
|
|
460
|
-
[[nodiscard]] constexpr
|
|
470
|
+
[[nodiscard]] constexpr
|
|
471
|
+
operator bool () const
|
|
461
472
|
{
|
|
462
473
|
return value_;
|
|
463
474
|
}
|
|
@@ -481,17 +492,19 @@ namespace micro_os_plus::micro_test_plus
|
|
|
481
492
|
|
|
482
493
|
/**
|
|
483
494
|
* @brief Logical and operator.
|
|
495
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
484
496
|
*/
|
|
485
497
|
template <class Lhs_T, class Rhs_T>
|
|
486
498
|
struct and_ : type_traits::op
|
|
487
499
|
{
|
|
488
500
|
constexpr and_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
|
|
489
|
-
: lhs_{ lhs }, rhs_{ rhs },
|
|
490
|
-
|
|
501
|
+
: lhs_{ lhs }, rhs_{ rhs },
|
|
502
|
+
value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
|
|
491
503
|
{
|
|
492
504
|
}
|
|
493
505
|
|
|
494
|
-
[[nodiscard]] constexpr
|
|
506
|
+
[[nodiscard]] constexpr
|
|
507
|
+
operator bool () const
|
|
495
508
|
{
|
|
496
509
|
return value_;
|
|
497
510
|
}
|
|
@@ -515,17 +528,19 @@ namespace micro_os_plus::micro_test_plus
|
|
|
515
528
|
|
|
516
529
|
/**
|
|
517
530
|
* @brief Logical or operator.
|
|
531
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
518
532
|
*/
|
|
519
533
|
template <class Lhs_T, class Rhs_T>
|
|
520
534
|
struct or_ : type_traits::op
|
|
521
535
|
{
|
|
522
536
|
constexpr or_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
|
|
523
|
-
: lhs_{ lhs }, rhs_{ rhs },
|
|
524
|
-
|
|
537
|
+
: lhs_{ lhs }, rhs_{ rhs },
|
|
538
|
+
value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
|
|
525
539
|
{
|
|
526
540
|
}
|
|
527
541
|
|
|
528
|
-
[[nodiscard]] constexpr
|
|
542
|
+
[[nodiscard]] constexpr
|
|
543
|
+
operator bool () const
|
|
529
544
|
{
|
|
530
545
|
return value_;
|
|
531
546
|
}
|
|
@@ -549,6 +564,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
549
564
|
|
|
550
565
|
/**
|
|
551
566
|
* @brief Logical not operator.
|
|
567
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
552
568
|
*/
|
|
553
569
|
template <class T>
|
|
554
570
|
struct not_ : type_traits::op
|
|
@@ -558,7 +574,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
558
574
|
{
|
|
559
575
|
}
|
|
560
576
|
|
|
561
|
-
[[nodiscard]] constexpr
|
|
577
|
+
[[nodiscard]] constexpr
|
|
578
|
+
operator bool () const
|
|
562
579
|
{
|
|
563
580
|
return value_;
|
|
564
581
|
}
|
|
@@ -576,6 +593,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
576
593
|
#if defined(__cpp_exceptions)
|
|
577
594
|
/**
|
|
578
595
|
* @brief Operator to check if the expression throws a specific exception.
|
|
596
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
579
597
|
*/
|
|
580
598
|
template <class Callable_T, class Exception_T = void>
|
|
581
599
|
struct throws_ : type_traits::op
|
|
@@ -599,7 +617,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
599
617
|
{
|
|
600
618
|
}
|
|
601
619
|
|
|
602
|
-
[[nodiscard]] constexpr
|
|
620
|
+
[[nodiscard]] constexpr
|
|
621
|
+
operator bool () const
|
|
603
622
|
{
|
|
604
623
|
return value_;
|
|
605
624
|
}
|
|
@@ -609,6 +628,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
609
628
|
|
|
610
629
|
/**
|
|
611
630
|
* @brief Operator to check if the expression throws any exception.
|
|
631
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
612
632
|
*/
|
|
613
633
|
template <class Callable_T>
|
|
614
634
|
struct throws_<Callable_T, void> : type_traits::op
|
|
@@ -628,7 +648,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
628
648
|
{
|
|
629
649
|
}
|
|
630
650
|
|
|
631
|
-
[[nodiscard]] constexpr
|
|
651
|
+
[[nodiscard]] constexpr
|
|
652
|
+
operator bool () const
|
|
632
653
|
{
|
|
633
654
|
return value_;
|
|
634
655
|
}
|
|
@@ -638,6 +659,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
638
659
|
|
|
639
660
|
/**
|
|
640
661
|
* @brief Operator to check if the expression does not throw any exception.
|
|
662
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
641
663
|
*/
|
|
642
664
|
template <class Callable_T>
|
|
643
665
|
struct nothrow_ : type_traits::op
|
|
@@ -657,7 +679,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
657
679
|
{
|
|
658
680
|
}
|
|
659
681
|
|
|
660
|
-
[[nodiscard]] constexpr
|
|
682
|
+
[[nodiscard]] constexpr
|
|
683
|
+
operator bool () const
|
|
661
684
|
{
|
|
662
685
|
return value_;
|
|
663
686
|
}
|
|
@@ -668,6 +691,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
668
691
|
|
|
669
692
|
// ------------------------------------------------------------------------
|
|
670
693
|
|
|
694
|
+
/**
|
|
695
|
+
* @brief Base class for a deferred reporter, that collects the
|
|
696
|
+
* messages into a string.
|
|
697
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
698
|
+
*/
|
|
671
699
|
class deferred_reporter_base
|
|
672
700
|
{
|
|
673
701
|
public:
|
|
@@ -698,6 +726,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
698
726
|
std::string message_{};
|
|
699
727
|
};
|
|
700
728
|
|
|
729
|
+
/**
|
|
730
|
+
* @brief Class template for a deferred reporter specific
|
|
731
|
+
* to an expression.
|
|
732
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
733
|
+
*/
|
|
701
734
|
template <class Expr_T>
|
|
702
735
|
class deferred_reporter : public deferred_reporter_base
|
|
703
736
|
{
|
|
@@ -40,8 +40,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
40
40
|
template <typename Callable_T, typename... Args_T>
|
|
41
41
|
test_suite::test_suite (const char* name, Callable_T&& callable,
|
|
42
42
|
Args_T&&... arguments)
|
|
43
|
-
: test_suite_base{ name },
|
|
44
|
-
|
|
43
|
+
: test_suite_base{ name },
|
|
44
|
+
callable_{ std::bind (callable, arguments...) }
|
|
45
45
|
{
|
|
46
46
|
#if defined(MICRO_TEST_PLUS_TRACE)
|
|
47
47
|
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
@@ -52,16 +52,46 @@ namespace micro_os_plus::micro_test_plus
|
|
|
52
52
|
|
|
53
53
|
// --------------------------------------------------------------------------
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @details
|
|
57
|
+
* A test case is a sequence of test conditions (or simply tests,
|
|
58
|
+
* or checks), which are expectations/assumptions, i.e. conditions
|
|
59
|
+
* expected to be true.
|
|
60
|
+
*
|
|
61
|
+
* Tests are based on logical expressions, which usually compute
|
|
62
|
+
* a result and compare it to an expected value.
|
|
63
|
+
* For C++ projects, it is also possible to check if, while
|
|
64
|
+
* evaluating an expression, exceptions are thrown or not.
|
|
65
|
+
* Each test either succeeds or fails.
|
|
66
|
+
* For expectations, the runner keeps counts of successful
|
|
67
|
+
* and failed tests.
|
|
68
|
+
*
|
|
69
|
+
* A test case has a name, a function which performs the checks, and
|
|
70
|
+
* possibly arguments.
|
|
71
|
+
*
|
|
72
|
+
* The `test_case` implementation invokes the function with
|
|
73
|
+
* the provided arguments, and reports the results.
|
|
74
|
+
*
|
|
75
|
+
* @par Example
|
|
76
|
+
*
|
|
77
|
+
* ```cpp
|
|
78
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
79
|
+
*
|
|
80
|
+
* mt::test_case ("Check answer with comparator", [] {
|
|
81
|
+
* mt::expect (mt::eq (compute_answer (), 42)) << "answer is 42";
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
55
85
|
template <typename Callable_T, typename... Args_T>
|
|
56
86
|
void
|
|
57
|
-
test_case (const char* name, Callable_T&&
|
|
87
|
+
test_case (const char* name, Callable_T&& callable, Args_T&&... arguments)
|
|
58
88
|
{
|
|
59
89
|
#if 0 // defined(MICRO_TEST_PLUS_TRACE)
|
|
60
90
|
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
61
91
|
#endif // MICRO_TEST_PLUS_TRACE
|
|
62
92
|
|
|
63
93
|
current_test_suite->begin_test_case (name);
|
|
64
|
-
std::invoke (std::forward<Callable_T> (
|
|
94
|
+
std::invoke (std::forward<Callable_T> (callable),
|
|
65
95
|
std::forward<Args_T> (arguments)...);
|
|
66
96
|
current_test_suite->end_test_case ();
|
|
67
97
|
}
|
|
@@ -92,9 +122,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
92
122
|
constexpr deferred_reporter<Expr_T>::deferred_reporter (
|
|
93
123
|
const Expr_T& expr, bool abort,
|
|
94
124
|
const reflection::source_location& location)
|
|
95
|
-
: deferred_reporter_base{ static_cast<bool> (expr), location },
|
|
96
|
-
|
|
97
|
-
}
|
|
125
|
+
: deferred_reporter_base{ static_cast<bool> (expr), location },
|
|
126
|
+
expr_{ expr }
|
|
98
127
|
{
|
|
99
128
|
#if 0 // defined(MICRO_TEST_PLUS_TRACE)
|
|
100
129
|
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
@@ -121,6 +150,20 @@ namespace micro_os_plus::micro_test_plus
|
|
|
121
150
|
// --------------------------------------------------------------------------
|
|
122
151
|
namespace utility
|
|
123
152
|
{
|
|
153
|
+
/**
|
|
154
|
+
* @details
|
|
155
|
+
* For tests handling strings, this function template allows
|
|
156
|
+
* to split a string into a vector of substrings, using a delimiter.
|
|
157
|
+
*
|
|
158
|
+
* @par Example
|
|
159
|
+
* ```cpp
|
|
160
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
161
|
+
*
|
|
162
|
+
* mt::expect (std::vector<std::string_view>{ "a", "b" }
|
|
163
|
+
* == mt::utility::split<std::string_view> ("a.b", "."))
|
|
164
|
+
* << "a.b splits into [a,b]";
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
124
167
|
template <class T = std::string_view, class Delim_T>
|
|
125
168
|
[[nodiscard]] auto
|
|
126
169
|
split (T input, Delim_T delim) -> std::vector<T>
|