@micro-os-plus/micro-test-plus 4.0.0 → 4.1.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 +82 -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 +231 -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 +19 -67
- 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
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
|
|
55
55
|
// ----------------------------------------------------------------------------
|
|
56
56
|
|
|
57
|
-
#include "math.h"
|
|
58
57
|
#include <string_view>
|
|
59
58
|
#include <type_traits>
|
|
60
59
|
|
|
60
|
+
#include "math.h"
|
|
61
|
+
|
|
61
62
|
// ----------------------------------------------------------------------------
|
|
62
63
|
|
|
63
64
|
#if defined(__GNUC__)
|
|
@@ -517,23 +518,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
517
518
|
*
|
|
518
519
|
* @param v The value to be stored.
|
|
519
520
|
*/
|
|
520
|
-
constexpr explicit value_base_ (const T& v) noexcept
|
|
521
|
-
{
|
|
522
|
-
}
|
|
521
|
+
constexpr explicit value_base_ (const T& v) noexcept;
|
|
523
522
|
|
|
524
523
|
/**
|
|
525
524
|
* @brief Explicit conversion operator to the underlying value type.
|
|
526
525
|
*
|
|
527
526
|
* @return The stored value as type `T`.
|
|
528
|
-
*
|
|
529
|
-
* @details
|
|
530
|
-
* Allows explicit conversion to the encapsulated value.
|
|
531
527
|
*/
|
|
532
528
|
[[nodiscard]] constexpr explicit
|
|
533
|
-
operator T () const noexcept
|
|
534
|
-
{
|
|
535
|
-
return value_;
|
|
536
|
-
}
|
|
529
|
+
operator T () const noexcept;
|
|
537
530
|
|
|
538
531
|
/**
|
|
539
532
|
* @brief Getter for the stored value.
|
|
@@ -541,15 +534,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
541
534
|
* @par Parameters
|
|
542
535
|
* None.
|
|
543
536
|
* @return The stored value.
|
|
544
|
-
*
|
|
545
|
-
* @details
|
|
546
|
-
* Returns the stored value by value.
|
|
547
537
|
*/
|
|
548
538
|
[[nodiscard]] constexpr T
|
|
549
|
-
get (void) const noexcept
|
|
550
|
-
{
|
|
551
|
-
return value_;
|
|
552
|
-
}
|
|
539
|
+
get (void) const noexcept;
|
|
553
540
|
|
|
554
541
|
/**
|
|
555
542
|
* @brief The stored value.
|
|
@@ -586,24 +573,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
586
573
|
/**
|
|
587
574
|
* @brief Default constructor. Initialises the base with `N`.
|
|
588
575
|
*/
|
|
589
|
-
constexpr integral_constant () noexcept
|
|
590
|
-
{
|
|
591
|
-
}
|
|
576
|
+
constexpr integral_constant () noexcept;
|
|
592
577
|
|
|
593
578
|
/**
|
|
594
579
|
* @brief Unary minus operator.
|
|
595
580
|
*
|
|
596
581
|
* @return An `integral_constant` with value `-N`.
|
|
597
|
-
*
|
|
598
|
-
* @details
|
|
599
|
-
* Returns a new `integral_constant` instance representing the negative
|
|
600
|
-
* of the current value.
|
|
601
582
|
*/
|
|
602
583
|
[[nodiscard]] constexpr auto
|
|
603
|
-
operator- () const noexcept
|
|
604
|
-
{
|
|
605
|
-
return integral_constant<-N>{};
|
|
606
|
-
}
|
|
584
|
+
operator- () const noexcept;
|
|
607
585
|
};
|
|
608
586
|
|
|
609
587
|
/**
|
|
@@ -668,10 +646,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
668
646
|
* @return The compile-time constant as type `T`.
|
|
669
647
|
*/
|
|
670
648
|
[[nodiscard]] constexpr explicit
|
|
671
|
-
operator T () const noexcept
|
|
672
|
-
{
|
|
673
|
-
return value;
|
|
674
|
-
}
|
|
649
|
+
operator T () const noexcept;
|
|
675
650
|
|
|
676
651
|
/**
|
|
677
652
|
* @brief Getter for the compile-time constant value.
|
|
@@ -681,25 +656,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
681
656
|
* @return The compile-time constant as type `T`.
|
|
682
657
|
*/
|
|
683
658
|
[[nodiscard]] constexpr T
|
|
684
|
-
get (void) const noexcept
|
|
685
|
-
{
|
|
686
|
-
return value;
|
|
687
|
-
}
|
|
659
|
+
get (void) const noexcept;
|
|
688
660
|
|
|
689
661
|
/**
|
|
690
662
|
* @brief Unary minus operator.
|
|
691
663
|
*
|
|
692
664
|
* @return A `floating_point_constant` with negated sign parameter.
|
|
693
|
-
*
|
|
694
|
-
* @details
|
|
695
|
-
* Returns a new `floating_point_constant` instance representing the
|
|
696
|
-
* negative of the current value by flipping the sign parameter `P`.
|
|
697
665
|
*/
|
|
698
666
|
[[nodiscard]] constexpr auto
|
|
699
|
-
operator- () const noexcept
|
|
700
|
-
{
|
|
701
|
-
return floating_point_constant<T, N, D, Size, -P>{};
|
|
702
|
-
}
|
|
667
|
+
operator- () const noexcept;
|
|
703
668
|
};
|
|
704
669
|
|
|
705
670
|
/**
|
|
@@ -722,10 +687,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
722
687
|
*
|
|
723
688
|
* @param _value The integral value to be stored.
|
|
724
689
|
*/
|
|
725
|
-
constexpr genuine_integral_value (const T& _value) noexcept
|
|
726
|
-
: value_base_<T>{ _value }
|
|
727
|
-
{
|
|
728
|
-
}
|
|
690
|
+
constexpr genuine_integral_value (const T& _value) noexcept;
|
|
729
691
|
};
|
|
730
692
|
|
|
731
693
|
/**
|
|
@@ -749,9 +711,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
749
711
|
*
|
|
750
712
|
* @param _value The value to be stored.
|
|
751
713
|
*/
|
|
752
|
-
constexpr value (const T& _value) noexcept
|
|
753
|
-
{
|
|
754
|
-
}
|
|
714
|
+
constexpr value (const T& _value) noexcept;
|
|
755
715
|
};
|
|
756
716
|
|
|
757
717
|
/**
|
|
@@ -798,27 +758,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
798
758
|
* @param _value The floating-point value to be stored.
|
|
799
759
|
* @param precision The epsilon value to be used for comparisons.
|
|
800
760
|
*/
|
|
801
|
-
constexpr value (const T& _value, const T precision) noexcept
|
|
802
|
-
: value_base_<T>{ _value }, epsilon{ precision }
|
|
803
|
-
{
|
|
804
|
-
}
|
|
761
|
+
constexpr value (const T& _value, const T precision) noexcept;
|
|
805
762
|
|
|
806
763
|
/**
|
|
807
764
|
* @brief Constructs a floating point value with default precision.
|
|
808
765
|
*
|
|
809
766
|
* @param val The floating point value to be stored.
|
|
810
|
-
*
|
|
811
|
-
* @details
|
|
812
|
-
* The epsilon is computed as 1 divided by 10 raised to the number of
|
|
813
|
-
* decimal digits in the value.
|
|
814
767
|
*/
|
|
815
|
-
constexpr value (const T& val)
|
|
816
|
-
: value{ val,
|
|
817
|
-
T (1)
|
|
818
|
-
/ math::pow (T (10),
|
|
819
|
-
math::den_size<unsigned long long> (val)) }
|
|
820
|
-
{
|
|
821
|
-
}
|
|
768
|
+
constexpr value (const T& val);
|
|
822
769
|
};
|
|
823
770
|
|
|
824
771
|
// ------------------------------------------------------------------------
|
|
@@ -835,6 +782,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
835
782
|
|
|
836
783
|
#endif // __cplusplus
|
|
837
784
|
|
|
785
|
+
// ============================================================================
|
|
786
|
+
// Templates & constexpr implementations.
|
|
787
|
+
|
|
788
|
+
#include "inlines/type-traits-inlines.h"
|
|
789
|
+
|
|
838
790
|
// ----------------------------------------------------------------------------
|
|
839
791
|
|
|
840
792
|
#endif // MICRO_TEST_PLUS_TYPE_TRAITS_H_
|
|
@@ -34,10 +34,6 @@
|
|
|
34
34
|
|
|
35
35
|
// ----------------------------------------------------------------------------
|
|
36
36
|
|
|
37
|
-
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
38
|
-
#include <micro-os-plus/config.h>
|
|
39
|
-
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
40
|
-
|
|
41
37
|
#include <string_view>
|
|
42
38
|
#include <vector>
|
|
43
39
|
|
|
@@ -128,6 +124,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
128
124
|
|
|
129
125
|
#endif // __cplusplus
|
|
130
126
|
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Templates & constexpr implementations.
|
|
129
|
+
|
|
130
|
+
#include "inlines/utility-inlines.h"
|
|
131
|
+
|
|
131
132
|
// ----------------------------------------------------------------------------
|
|
132
133
|
|
|
133
134
|
#endif // MICRO_TEST_PLUS_UTILITY_H_
|
|
@@ -63,29 +63,58 @@
|
|
|
63
63
|
#include <micro-os-plus/config.h>
|
|
64
64
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
65
65
|
|
|
66
|
+
// No deps.
|
|
67
|
+
#include "micro-test-plus/math.h"
|
|
68
|
+
|
|
69
|
+
// Requires math.h.
|
|
66
70
|
#include "micro-test-plus/type-traits.h"
|
|
71
|
+
|
|
72
|
+
// No deps.
|
|
67
73
|
#include "micro-test-plus/reflection.h"
|
|
68
74
|
|
|
75
|
+
// Requires type-traits.h, reflection.h.
|
|
69
76
|
#include "micro-test-plus/detail.h"
|
|
70
77
|
|
|
71
|
-
|
|
78
|
+
// Requires type-traits.h, math.h.
|
|
72
79
|
#include "micro-test-plus/literals.h"
|
|
80
|
+
|
|
81
|
+
// No deps.
|
|
73
82
|
#include "micro-test-plus/function-comparators.h"
|
|
83
|
+
|
|
84
|
+
// No deps.
|
|
74
85
|
#include "micro-test-plus/exceptions.h"
|
|
86
|
+
|
|
87
|
+
// Requires type-traits.h + detail.h,
|
|
75
88
|
#include "micro-test-plus/operators.h"
|
|
76
89
|
|
|
90
|
+
// Requires type-traits.h, detail.h + reflection.h.
|
|
91
|
+
#include "micro-test-plus/expression-formatter.h"
|
|
92
|
+
|
|
93
|
+
// Requires type-traits.h, detail.h, expression-formatter.h, reflection.h.
|
|
94
|
+
#include "micro-test-plus/reporter.h"
|
|
95
|
+
|
|
96
|
+
// Requires type-traits.h, reflection.h, expression-formatter.h.
|
|
77
97
|
#include "micro-test-plus/deferred-reporter.h"
|
|
78
|
-
#include "micro-test-plus/test.h"
|
|
79
98
|
|
|
80
|
-
|
|
99
|
+
// No deps.
|
|
81
100
|
#include "micro-test-plus/runner-totals.h"
|
|
82
101
|
|
|
83
|
-
|
|
102
|
+
// Requires reporter.h, reflection.h.
|
|
84
103
|
#include "micro-test-plus/reporter-human.h"
|
|
104
|
+
|
|
105
|
+
// Requires reporter.h, reflection.h.
|
|
85
106
|
#include "micro-test-plus/reporter-tap.h"
|
|
86
107
|
|
|
108
|
+
// No deps.
|
|
87
109
|
#include "micro-test-plus/utility.h"
|
|
88
110
|
|
|
111
|
+
// Requires reporter.h, runner-totals.h, reflection.h, type-traits.h and
|
|
112
|
+
// timings.h + deferred-reporter.h, reporter.h.
|
|
113
|
+
#include "micro-test-plus/test.h"
|
|
114
|
+
|
|
115
|
+
// Requires timings.h, test.h (detail::test_node, top_suite), reflection.h.
|
|
116
|
+
#include "micro-test-plus/runner.h"
|
|
117
|
+
|
|
89
118
|
// ----------------------------------------------------------------------------
|
|
90
119
|
|
|
91
120
|
/**
|
|
@@ -113,26 +142,6 @@
|
|
|
113
142
|
* straightforward integration with the wider µOS++ ecosystem.
|
|
114
143
|
*/
|
|
115
144
|
|
|
116
|
-
// ============================================================================
|
|
117
|
-
// Templates & constexpr implementations.
|
|
118
|
-
|
|
119
|
-
#include <micro-os-plus/diag/trace.h>
|
|
120
|
-
|
|
121
|
-
// All inlines are included **after** all declarations.
|
|
122
|
-
#include "micro-test-plus/inlines/literals-inlines.h"
|
|
123
|
-
#include "micro-test-plus/inlines/math-inlines.h"
|
|
124
|
-
|
|
125
|
-
#include "micro-test-plus/inlines/reflection-inlines.h"
|
|
126
|
-
|
|
127
|
-
#include "micro-test-plus/inlines/deferred-reporter-inlines.h"
|
|
128
|
-
#include "micro-test-plus/inlines/reporter-inlines.h"
|
|
129
|
-
|
|
130
|
-
#include "micro-test-plus/inlines/function-comparators-inlines.h"
|
|
131
|
-
#include "micro-test-plus/inlines/runner-inlines.h"
|
|
132
|
-
#include "micro-test-plus/inlines/test-inlines.h"
|
|
133
|
-
|
|
134
|
-
#include "micro-test-plus/inlines/utility-inlines.h"
|
|
135
|
-
|
|
136
145
|
// ----------------------------------------------------------------------------
|
|
137
146
|
|
|
138
147
|
#endif // __cplusplus
|
package/meson.build
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-os-plus/micro-test-plus",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A source code library with µTest++, a lightweight testing framework for embedded platforms",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,12 +50,20 @@
|
|
|
50
50
|
"postversion": "git push origin --all && git push origin --tags"
|
|
51
51
|
},
|
|
52
52
|
"xpack": {
|
|
53
|
-
"minimumXpmRequired": "0.20.8"
|
|
53
|
+
"minimumXpmRequired": "0.20.8",
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@xpack-dev-tools/clang": "21.1.8-1.1"
|
|
56
|
+
},
|
|
57
|
+
"actions": {
|
|
58
|
+
"clang-format": "bash scripts/clang-format.sh",
|
|
59
|
+
"cmake-format": "bash scripts/cmake-format.sh"
|
|
60
|
+
}
|
|
54
61
|
},
|
|
55
62
|
"topConfig": {
|
|
56
63
|
"descriptiveName": "µTest++ Testing Framework",
|
|
57
64
|
"permalinkName": "micro-test-plus",
|
|
58
|
-
"useDoxygen": "true"
|
|
65
|
+
"useDoxygen": "true",
|
|
66
|
+
"hasObjectLibrary": "true"
|
|
59
67
|
},
|
|
60
68
|
"engines": {
|
|
61
69
|
"node": ">=20.0"
|
|
@@ -40,8 +40,12 @@
|
|
|
40
40
|
#include <micro-os-plus/config.h>
|
|
41
41
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
42
42
|
|
|
43
|
-
#
|
|
43
|
+
#if defined(MICRO_OS_PLUS_TRACE)
|
|
44
44
|
#include <micro-os-plus/diag/trace.h>
|
|
45
|
+
#endif // MICRO_OS_PLUS_TRACE
|
|
46
|
+
|
|
47
|
+
#include "micro-os-plus/micro-test-plus/deferred-reporter.h"
|
|
48
|
+
#include "micro-os-plus/micro-test-plus/test.h"
|
|
45
49
|
|
|
46
50
|
// ----------------------------------------------------------------------------
|
|
47
51
|
|
|
@@ -80,6 +84,16 @@ namespace micro_os_plus::micro_test_plus
|
|
|
80
84
|
|
|
81
85
|
/**
|
|
82
86
|
* @details
|
|
87
|
+
* The destructor finalises the deferred reporting process for a test
|
|
88
|
+
* expression. If the evaluated expression is true, the reporter records a
|
|
89
|
+
* successful outcome along with any accumulated message. If the expression
|
|
90
|
+
* is false, the reporter records a failure, including the abort status,
|
|
91
|
+
* message, and source location for comprehensive reporting.
|
|
92
|
+
*
|
|
93
|
+
* This mechanism ensures that all relevant information about the test
|
|
94
|
+
* outcome is captured and reported accurately when the deferred reporter
|
|
95
|
+
* goes out of scope.
|
|
96
|
+
*
|
|
83
97
|
* The destructor ensures that if an abort condition is set and the test
|
|
84
98
|
* expression has failed, the test output is flushed and the process is
|
|
85
99
|
* terminated. This mechanism guarantees immediate feedback and halts
|
|
@@ -93,12 +107,18 @@ namespace micro_os_plus::micro_test_plus
|
|
|
93
107
|
trace::printf ("%s\n", __PRETTY_FUNCTION__);
|
|
94
108
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
95
109
|
|
|
110
|
+
auto& expression_str = subtest_.reporter ().expression ().str ();
|
|
111
|
+
|
|
96
112
|
if (value_) [[likely]]
|
|
97
113
|
{
|
|
114
|
+
subtest_.reporter ().pass (deferred_output_, expression_str,
|
|
115
|
+
subtest_);
|
|
98
116
|
subtest_.totals ().increment_successful_checks ();
|
|
99
117
|
}
|
|
100
118
|
else
|
|
101
119
|
{
|
|
120
|
+
subtest_.reporter ().fail (abort_, deferred_output_, expression_str,
|
|
121
|
+
has_expression_, location_, subtest_);
|
|
102
122
|
subtest_.totals ().increment_failed_checks ();
|
|
103
123
|
}
|
|
104
124
|
|
|
@@ -109,7 +129,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
109
129
|
subtest_.abort (location_);
|
|
110
130
|
}
|
|
111
131
|
}
|
|
112
|
-
|
|
113
132
|
} // namespace detail
|
|
114
133
|
|
|
115
134
|
// ==========================================================================
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
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
|
+
*
|
|
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
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
13
|
+
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* @brief C++ source file with non-template implementations for the µTest++
|
|
21
|
+
* expression formatter.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This source file contains the non-template `operator<<` overloads of
|
|
25
|
+
* `expression_formatter` for all standard arithmetic, character, string,
|
|
26
|
+
* boolean, and null-pointer types. Each overload appends the formatted
|
|
27
|
+
* value — together with an appropriate type suffix where applicable — to
|
|
28
|
+
* the internal string buffer.
|
|
29
|
+
*
|
|
30
|
+
* All definitions reside within the
|
|
31
|
+
* `micro_os_plus::micro_test_plus` namespace.
|
|
32
|
+
*
|
|
33
|
+
* This file must be included when building the µTest++ library.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// ----------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
39
|
+
#include <micro-os-plus/config.h>
|
|
40
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
41
|
+
|
|
42
|
+
#include "micro-os-plus/micro-test-plus/expression-formatter.h"
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#if defined(__GNUC__)
|
|
47
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
48
|
+
#if defined(__clang__)
|
|
49
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
50
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
51
|
+
#endif
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
namespace micro_os_plus::micro_test_plus::detail
|
|
57
|
+
{
|
|
58
|
+
// --------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @details
|
|
62
|
+
* Appends the contents of the `std::string_view` directly to the
|
|
63
|
+
* internal buffer using `buffer_.append(sv)`.
|
|
64
|
+
*/
|
|
65
|
+
expression_formatter&
|
|
66
|
+
expression_formatter::operator<< (std::string_view sv)
|
|
67
|
+
{
|
|
68
|
+
buffer_.append (sv);
|
|
69
|
+
return *this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @details
|
|
74
|
+
* Appends the single character @p c to the internal buffer using
|
|
75
|
+
* `buffer_.append(1, c)`.
|
|
76
|
+
*/
|
|
77
|
+
expression_formatter&
|
|
78
|
+
expression_formatter::operator<< (char c)
|
|
79
|
+
{
|
|
80
|
+
buffer_.append (1, c);
|
|
81
|
+
return *this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @details
|
|
86
|
+
* Appends the null-terminated C string @p s to the internal buffer
|
|
87
|
+
* using `buffer_.append(s)`.
|
|
88
|
+
*/
|
|
89
|
+
expression_formatter&
|
|
90
|
+
expression_formatter::operator<< (const char* s)
|
|
91
|
+
{
|
|
92
|
+
buffer_.append (s);
|
|
93
|
+
return *this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @details
|
|
98
|
+
* Appends the string `"true"` or `"false"` to the internal buffer
|
|
99
|
+
* based on the value of @p v.
|
|
100
|
+
*/
|
|
101
|
+
expression_formatter&
|
|
102
|
+
expression_formatter::operator<< (bool v)
|
|
103
|
+
{
|
|
104
|
+
buffer_.append (v ? "true" : "false");
|
|
105
|
+
return *this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @details
|
|
110
|
+
* Appends the string `"nullptr"` to the internal buffer.
|
|
111
|
+
*/
|
|
112
|
+
expression_formatter&
|
|
113
|
+
expression_formatter::operator<< (std::nullptr_t)
|
|
114
|
+
{
|
|
115
|
+
buffer_.append ("nullptr");
|
|
116
|
+
return *this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @details
|
|
121
|
+
* Converts @p c to its decimal string representation via
|
|
122
|
+
* `append_number_()` and appends the type suffix `"c"`.
|
|
123
|
+
*/
|
|
124
|
+
expression_formatter&
|
|
125
|
+
expression_formatter::operator<< (signed char c)
|
|
126
|
+
{
|
|
127
|
+
detail::append_number_ (buffer_, c);
|
|
128
|
+
buffer_.append ("c");
|
|
129
|
+
return *this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @details
|
|
134
|
+
* Converts @p c to its decimal string representation via
|
|
135
|
+
* `append_number_()` and appends the type suffix `"uc"`.
|
|
136
|
+
*/
|
|
137
|
+
expression_formatter&
|
|
138
|
+
expression_formatter::operator<< (unsigned char c)
|
|
139
|
+
{
|
|
140
|
+
detail::append_number_ (buffer_, c);
|
|
141
|
+
buffer_.append ("uc");
|
|
142
|
+
return *this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @details
|
|
147
|
+
* Converts @p v to its decimal string representation via
|
|
148
|
+
* `append_number_()` and appends the type suffix `"s"`.
|
|
149
|
+
*/
|
|
150
|
+
expression_formatter&
|
|
151
|
+
expression_formatter::operator<< (signed short v)
|
|
152
|
+
{
|
|
153
|
+
detail::append_number_ (buffer_, v);
|
|
154
|
+
buffer_.append ("s");
|
|
155
|
+
return *this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @details
|
|
160
|
+
* Converts @p v to its decimal string representation via
|
|
161
|
+
* `append_number_()` and appends the type suffix `"us"`.
|
|
162
|
+
*/
|
|
163
|
+
expression_formatter&
|
|
164
|
+
expression_formatter::operator<< (unsigned short v)
|
|
165
|
+
{
|
|
166
|
+
detail::append_number_ (buffer_, v);
|
|
167
|
+
buffer_.append ("us");
|
|
168
|
+
return *this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @details
|
|
173
|
+
* Converts @p v to its decimal string representation via
|
|
174
|
+
* `append_number_()` without a type suffix.
|
|
175
|
+
*/
|
|
176
|
+
expression_formatter&
|
|
177
|
+
expression_formatter::operator<< (signed int v)
|
|
178
|
+
{
|
|
179
|
+
detail::append_number_ (buffer_, v);
|
|
180
|
+
return *this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @details
|
|
185
|
+
* Converts @p v to its decimal string representation via
|
|
186
|
+
* `append_number_()` and appends the type suffix `"u"`.
|
|
187
|
+
*/
|
|
188
|
+
expression_formatter&
|
|
189
|
+
expression_formatter::operator<< (unsigned int v)
|
|
190
|
+
{
|
|
191
|
+
detail::append_number_ (buffer_, v);
|
|
192
|
+
buffer_.append ("u");
|
|
193
|
+
return *this;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @details
|
|
198
|
+
* Converts @p v to its decimal string representation via
|
|
199
|
+
* `append_number_()` and appends the type suffix `"l"`.
|
|
200
|
+
*/
|
|
201
|
+
expression_formatter&
|
|
202
|
+
expression_formatter::operator<< (signed long v)
|
|
203
|
+
{
|
|
204
|
+
detail::append_number_ (buffer_, v);
|
|
205
|
+
buffer_.append ("l");
|
|
206
|
+
return *this;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @details
|
|
211
|
+
* Converts @p v to its decimal string representation via
|
|
212
|
+
* `append_number_()` and appends the type suffix `"ul"`.
|
|
213
|
+
*/
|
|
214
|
+
expression_formatter&
|
|
215
|
+
expression_formatter::operator<< (unsigned long v)
|
|
216
|
+
{
|
|
217
|
+
detail::append_number_ (buffer_, v);
|
|
218
|
+
buffer_.append ("ul");
|
|
219
|
+
return *this;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @details
|
|
224
|
+
* Converts @p v to its decimal string representation via
|
|
225
|
+
* `append_number_()` and appends the type suffix `"ll"`.
|
|
226
|
+
*/
|
|
227
|
+
expression_formatter&
|
|
228
|
+
expression_formatter::operator<< (signed long long v)
|
|
229
|
+
{
|
|
230
|
+
detail::append_number_ (buffer_, v);
|
|
231
|
+
buffer_.append ("ll");
|
|
232
|
+
return *this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @details
|
|
237
|
+
* Converts @p v to its decimal string representation via
|
|
238
|
+
* `append_number_()` and appends the type suffix `"ull"`.
|
|
239
|
+
*/
|
|
240
|
+
expression_formatter&
|
|
241
|
+
expression_formatter::operator<< (unsigned long long v)
|
|
242
|
+
{
|
|
243
|
+
detail::append_number_ (buffer_, v);
|
|
244
|
+
buffer_.append ("ull");
|
|
245
|
+
return *this;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @details
|
|
250
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
251
|
+
* and appends the type suffix `"f"`.
|
|
252
|
+
*/
|
|
253
|
+
expression_formatter&
|
|
254
|
+
expression_formatter::operator<< (float v)
|
|
255
|
+
{
|
|
256
|
+
detail::append_number_ (buffer_, v);
|
|
257
|
+
buffer_.append ("f");
|
|
258
|
+
return *this;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @details
|
|
263
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
264
|
+
* without a type suffix.
|
|
265
|
+
*/
|
|
266
|
+
expression_formatter&
|
|
267
|
+
expression_formatter::operator<< (double v)
|
|
268
|
+
{
|
|
269
|
+
detail::append_number_ (buffer_, v);
|
|
270
|
+
return *this;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @details
|
|
275
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
276
|
+
* and appends the type suffix `"l"`.
|
|
277
|
+
*/
|
|
278
|
+
expression_formatter&
|
|
279
|
+
expression_formatter::operator<< (long double v)
|
|
280
|
+
{
|
|
281
|
+
detail::append_number_ (buffer_, v);
|
|
282
|
+
buffer_.append ("l");
|
|
283
|
+
return *this;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// --------------------------------------------------------------------------
|
|
287
|
+
} // namespace micro_os_plus::micro_test_plus::detail
|
|
288
|
+
|
|
289
|
+
// ----------------------------------------------------------------------------
|
package/src/reflection.cpp
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
// ----------------------------------------------------------------------------
|
|
35
35
|
|
|
36
|
+
#include <cstring>
|
|
37
|
+
|
|
36
38
|
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
37
39
|
#include <micro-os-plus/config.h>
|
|
38
40
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
39
41
|
|
|
40
|
-
#include
|
|
42
|
+
#include "micro-os-plus/micro-test-plus/reflection.h"
|
|
41
43
|
|
|
42
44
|
// ----------------------------------------------------------------------------
|
|
43
45
|
|