@micro-os-plus/micro-test-plus 2.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 +145 -0
- package/CMakeLists.txt +98 -0
- package/LICENSE +21 -0
- package/README.md +456 -0
- package/include/micro-os-plus/micro-test-plus.h +152 -0
- package/meson.build +44 -0
- package/package.json +826 -0
- package/src/micro-test-plus.cpp +252 -0
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
|
|
10
|
+
#ifndef MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
|
|
11
|
+
#define MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
|
|
12
|
+
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
#ifdef __cplusplus
|
|
16
|
+
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
#if defined(__GNUC__)
|
|
20
|
+
#pragma GCC diagnostic push
|
|
21
|
+
#if defined(__clang__)
|
|
22
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
23
|
+
#endif
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace micro_os_plus
|
|
27
|
+
{
|
|
28
|
+
namespace micro_test_plus // `micro-test-plus` is shortened to `mtp`.
|
|
29
|
+
{
|
|
30
|
+
|
|
31
|
+
#if defined(__GNUC__)
|
|
32
|
+
#pragma GCC diagnostic push
|
|
33
|
+
#pragma GCC diagnostic ignored "-Wpadded"
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
class session
|
|
37
|
+
{
|
|
38
|
+
public:
|
|
39
|
+
session ();
|
|
40
|
+
|
|
41
|
+
session (int argc, char* argv[]);
|
|
42
|
+
|
|
43
|
+
session (const session&) = delete;
|
|
44
|
+
session (session&&) = delete;
|
|
45
|
+
session&
|
|
46
|
+
operator= (const session&)
|
|
47
|
+
= delete;
|
|
48
|
+
session&
|
|
49
|
+
operator= (session&&)
|
|
50
|
+
= delete;
|
|
51
|
+
|
|
52
|
+
~session () = default;
|
|
53
|
+
|
|
54
|
+
void
|
|
55
|
+
init (int argc, char* argv[]);
|
|
56
|
+
|
|
57
|
+
void
|
|
58
|
+
start_suite (const char* name);
|
|
59
|
+
|
|
60
|
+
void
|
|
61
|
+
run_test_case (void (*f) (session&), const char* name);
|
|
62
|
+
|
|
63
|
+
void
|
|
64
|
+
pass (const char* message, const char* file = nullptr, int line = 0);
|
|
65
|
+
|
|
66
|
+
void
|
|
67
|
+
fail (const char* message, const char* file = nullptr, int line = 0);
|
|
68
|
+
|
|
69
|
+
void
|
|
70
|
+
expect_true (bool condition, const char* message,
|
|
71
|
+
const char* file = nullptr, int line = 0);
|
|
72
|
+
|
|
73
|
+
void
|
|
74
|
+
expect_eq (int actual, int expected, const char* message,
|
|
75
|
+
const char* file = nullptr, int line = 0);
|
|
76
|
+
|
|
77
|
+
void
|
|
78
|
+
expect_eq (long actual, long expected, const char* message,
|
|
79
|
+
const char* file = nullptr, int line = 0);
|
|
80
|
+
|
|
81
|
+
void
|
|
82
|
+
expect_eq (const char* actual, const char* expected, const char* message,
|
|
83
|
+
const char* file = nullptr, int line = 0);
|
|
84
|
+
|
|
85
|
+
int
|
|
86
|
+
result (void);
|
|
87
|
+
|
|
88
|
+
inline int
|
|
89
|
+
passed (void)
|
|
90
|
+
{
|
|
91
|
+
return passed_;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
inline int
|
|
95
|
+
failed (void)
|
|
96
|
+
{
|
|
97
|
+
return failed_;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
inline int
|
|
101
|
+
test_cases (void)
|
|
102
|
+
{
|
|
103
|
+
return test_cases_;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
protected:
|
|
107
|
+
void
|
|
108
|
+
print_where_ (const char* format, const char* file, int line);
|
|
109
|
+
|
|
110
|
+
protected:
|
|
111
|
+
int argc_;
|
|
112
|
+
char** argv_;
|
|
113
|
+
|
|
114
|
+
const char* name_;
|
|
115
|
+
|
|
116
|
+
int passed_;
|
|
117
|
+
int failed_;
|
|
118
|
+
int test_cases_;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
#if defined(__GNUC__)
|
|
122
|
+
#pragma GCC diagnostic pop
|
|
123
|
+
#endif
|
|
124
|
+
|
|
125
|
+
} // namespace micro_test_plus
|
|
126
|
+
} // namespace micro_os_plus
|
|
127
|
+
|
|
128
|
+
#if defined(__GNUC__)
|
|
129
|
+
#pragma GCC diagnostic pop
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
// ----------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
// Macros are only a convenience to pass the file name and line number,
|
|
135
|
+
// otherwise the direct methods can be used as well.
|
|
136
|
+
#define MTP_EXPECT_EQ(t, actual, expected, message) \
|
|
137
|
+
t.expect_eq (actual, expected, message, __FILE__, __LINE__)
|
|
138
|
+
#define MTP_EXPECT_TRUE(t, condition, message) \
|
|
139
|
+
t.expect_true (condition, message, __FILE__, __LINE__)
|
|
140
|
+
|
|
141
|
+
#define MTP_PASS(t, message) t.pass (message, __FILE__, __LINE__)
|
|
142
|
+
#define MTP_FAIL(t, message) t.fail (message, __FILE__, __LINE__)
|
|
143
|
+
|
|
144
|
+
// ----------------------------------------------------------------------------
|
|
145
|
+
|
|
146
|
+
#endif // __cplusplus
|
|
147
|
+
|
|
148
|
+
// ----------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
#endif // MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
|
|
151
|
+
|
|
152
|
+
// ----------------------------------------------------------------------------
|
package/meson.build
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
#
|
|
3
|
+
# This file is part of the µOS++ distribution.
|
|
4
|
+
# (https://github.com/micro-os-plus)
|
|
5
|
+
# Copyright (c) 2022 Liviu Ionescu
|
|
6
|
+
#
|
|
7
|
+
# Permission to use, copy, modify, and/or distribute this software
|
|
8
|
+
# for any purpose is hereby granted, under the terms of the MIT license.
|
|
9
|
+
#
|
|
10
|
+
# If a copy of the license was not distributed with this file, it can
|
|
11
|
+
# be obtained from https://opensource.org/licenses/MIT/.
|
|
12
|
+
#
|
|
13
|
+
# -----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
# This file is intended to be consumed by applications with:
|
|
16
|
+
#
|
|
17
|
+
# `subdir('xpacks/micro-os-plus-micro-test-plus')`
|
|
18
|
+
#
|
|
19
|
+
# The result is a dependency that can be refered as:
|
|
20
|
+
#
|
|
21
|
+
# `dependencies: [micro_os_plus_micro_test_plus_dependency],`
|
|
22
|
+
|
|
23
|
+
# Note: the meson configuration is provided only as a proof of concept,
|
|
24
|
+
# for production it might need some refinements.
|
|
25
|
+
|
|
26
|
+
# -----------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
message('Processing xPack @micro-os-plus/micro-test-plus...')
|
|
29
|
+
|
|
30
|
+
# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency
|
|
31
|
+
micro_os_plus_micro_test_plus_dependency = declare_dependency(
|
|
32
|
+
include_directories: include_directories(
|
|
33
|
+
'include',
|
|
34
|
+
),
|
|
35
|
+
sources: files(
|
|
36
|
+
'src/micro-test-plus.cpp',
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
message('+ -I include')
|
|
41
|
+
message('+ src/micro-test-plus.cpp')
|
|
42
|
+
message('> micro_os_plus_micro_test_plus_dependency')
|
|
43
|
+
|
|
44
|
+
# -----------------------------------------------------------------------------
|