@micro-os-plus/micro-test-plus 2.1.1 → 3.0.2
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 +349 -72
- package/CMakeLists.txt +15 -26
- package/LICENSE-Boost +23 -0
- package/README.md +1036 -256
- package/include/micro-os-plus/detail.h +733 -0
- package/include/micro-os-plus/inlines.h +161 -0
- package/include/micro-os-plus/literals.h +285 -0
- package/include/micro-os-plus/math.h +205 -0
- package/include/micro-os-plus/micro-test-plus.h +490 -103
- package/include/micro-os-plus/reflection.h +134 -0
- package/include/micro-os-plus/test-reporter-inlines.h +231 -0
- package/include/micro-os-plus/test-reporter.h +347 -0
- package/include/micro-os-plus/test-runner.h +132 -0
- package/include/micro-os-plus/test-suite.h +241 -0
- package/include/micro-os-plus/type-traits.h +346 -0
- package/meson.build +35 -11
- package/package.json +243 -147
- package/src/micro-test-plus.cpp +105 -188
- package/src/test-reporter.cpp +423 -0
- package/src/test-runner.cpp +186 -0
- package/src/test-suite.cpp +133 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the µOS++ distribution.
|
|
3
|
+
* (https://github.com/micro-os-plus/)
|
|
4
|
+
* Copyright (c) 2021 Liviu Ionescu.
|
|
5
|
+
*
|
|
6
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
7
|
+
* for any purpose is hereby granted, under the terms of the MIT license.
|
|
8
|
+
*
|
|
9
|
+
* If a copy of the license was not distributed with this file, it can
|
|
10
|
+
* be obtained from <https://opensource.org/licenses/MIT/>.
|
|
11
|
+
*
|
|
12
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
13
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
14
|
+
* which can be obtained from <https://www.boost.org/LICENSE_1_0.txt>.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
20
|
+
#include <micro-os-plus/config.h>
|
|
21
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
22
|
+
|
|
23
|
+
#include <micro-os-plus/micro-test-plus.h>
|
|
24
|
+
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
|
|
27
|
+
// ----------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
#if defined(__clang__)
|
|
30
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
31
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
namespace micro_os_plus::micro_test_plus
|
|
35
|
+
{
|
|
36
|
+
// --------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
test_suite_base::test_suite_base (const char* name)
|
|
39
|
+
{
|
|
40
|
+
#if defined(MICRO_TEST_PLUS_TRACE)
|
|
41
|
+
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
42
|
+
#endif // MICRO_TEST_PLUS_TRACE
|
|
43
|
+
|
|
44
|
+
name_ = name;
|
|
45
|
+
// The default test suite needs no registration.
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
test_suite_base::~test_suite_base ()
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void
|
|
53
|
+
test_suite_base::run ()
|
|
54
|
+
{
|
|
55
|
+
#if defined(MICRO_TEST_PLUS_TRACE)
|
|
56
|
+
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
57
|
+
#endif // MICRO_TEST_PLUS_TRACE
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void
|
|
61
|
+
test_suite_base::begin_test_suite (void)
|
|
62
|
+
{
|
|
63
|
+
process_deferred_begin = false;
|
|
64
|
+
|
|
65
|
+
reporter.begin_test_suite (name_);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void
|
|
69
|
+
test_suite_base::end_test_suite (void)
|
|
70
|
+
{
|
|
71
|
+
if (process_deferred_begin)
|
|
72
|
+
{
|
|
73
|
+
begin_test_suite ();
|
|
74
|
+
}
|
|
75
|
+
reporter.end_test_suite (*this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void
|
|
79
|
+
test_suite_base::begin_test_case (const char* name)
|
|
80
|
+
{
|
|
81
|
+
if (process_deferred_begin)
|
|
82
|
+
{
|
|
83
|
+
begin_test_suite ();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
test_case_name_ = name;
|
|
87
|
+
++test_cases_;
|
|
88
|
+
|
|
89
|
+
current_test_case = {};
|
|
90
|
+
|
|
91
|
+
reporter.begin_test_case (test_case_name_);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void
|
|
95
|
+
test_suite_base::end_test_case (void)
|
|
96
|
+
{
|
|
97
|
+
reporter.end_test_case (test_case_name_);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void
|
|
101
|
+
test_suite_base::increment_successful (void)
|
|
102
|
+
{
|
|
103
|
+
++successful_checks_;
|
|
104
|
+
++current_test_case.successful_checks;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void
|
|
108
|
+
test_suite_base::increment_failed (void)
|
|
109
|
+
{
|
|
110
|
+
++failed_checks_;
|
|
111
|
+
++current_test_case.failed_checks;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ==========================================================================
|
|
115
|
+
|
|
116
|
+
void
|
|
117
|
+
test_suite::run (void)
|
|
118
|
+
{
|
|
119
|
+
// Run the test suite function prepared with std::bin();
|
|
120
|
+
callable_ ();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
test_suite::~test_suite ()
|
|
124
|
+
{
|
|
125
|
+
#if defined(MICRO_TEST_PLUS_TRACE)
|
|
126
|
+
printf ("%s\n", __PRETTY_FUNCTION__);
|
|
127
|
+
#endif // MICRO_TEST_PLUS_TRACE
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --------------------------------------------------------------------------
|
|
131
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
132
|
+
|
|
133
|
+
// ----------------------------------------------------------------------------
|