AUnit
0.5.0
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
src
aunit
MetaAssertMacros.h
Go to the documentation of this file.
1
/*
2
MIT License
3
4
Copyright (c) 2018 Brian T. Park
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
*/
24
25
// Significant portions of the design and implementation of this file came from
26
// https://github.com/mmurdoch/arduinounit/blob/master/src/ArduinoUnit.h
27
35
#ifndef AUNIT_META_ASSERT_MACROS_H
36
#define AUNIT_META_ASSERT_MACROS_H
37
38
// Meta tests, same syntax as ArduinoUnit for compatibility.
39
// The checkTestXxx() macros return a boolean, and execution continues.
40
42
#define checkTestDone(name) (test_##name##_instance.isDone())
43
45
#define checkTestNotDone(name) (test_##name##_instance.isNotDone())
46
48
#define checkTestPass(name) (test_##name##_instance.isPassed())
49
51
#define checkTestNotPass(name) (test_##name##_instance.isNotPassed())
52
54
#define checkTestFail(name) (test_##name##_instance.isFailed())
55
57
#define checkTestNotFail(name) (test_##name##_instance.isNotFailed())
58
60
#define checkTestSkip(name) (test_##name##_instance.isSkipped())
61
63
#define checkTestNotSkip(name) (test_##name##_instance.isNotSkipped())
64
66
#define checkTestExpire(name) (test_##name##_instance.isExpired())
67
69
#define checkTestNotExpire(name) (test_##name##_instance.isNotExpired())
70
71
// If the assertTestXxx() macros fail, they generate an optional output, calls
72
// fail(), and returns from the current test case.
73
75
#define assertTestDone(name) \
76
assertTestStatusInternal(name, isDone, kMessageDone)
77
79
#define assertTestNotDone(name) \
80
assertTestStatusInternal(name, isNotDone, kMessageNotDone)
81
83
#define assertTestPass(name) \
84
assertTestStatusInternal(name, isPassed, kMessagePassed)
85
87
#define assertTestNotPass(name) \
88
assertTestStatusInternal(name, isNotPassed, kMessageNotPassed)
89
91
#define assertTestFail(name) \
92
assertTestStatusInternal(name, isFailed, kMessageFailed)
93
95
#define assertTestNotFail(name) \
96
assertTestStatusInternal(name, isNotFailed, kMessageNotFailed)
97
99
#define assertTestSkip(name) \
100
assertTestStatusInternal(name, isSkipped, kMessageSkipped)
101
103
#define assertTestNotSkip(name) \
104
assertTestStatusInternal(name, isNotSkipped, kMessageNotSkipped)
105
107
#define assertTestExpire(name) \
108
assertTestStatusInternal(name, isExpired, kMessageExpired)
109
111
#define assertTestNotExpire(name) \
112
assertTestStatusInternal(name, isNotExpired, kMessageNotExpired)
113
115
#define assertTestStatusInternal(name,method,message) do {\
116
if (!assertionTestStatus(\
117
__FILE__,__LINE__,#name,FPSTR(message),test_##name##_instance.method()))\
118
return;\
119
} while (false)
120
121
// Meta tests for testF() and testingF() are slightly different because
122
// the name of the fixture class is appended to the instance name.
123
125
#define checkTestDoneF(testClass,name) \
126
(testClass##_##name##_instance.isDone())
127
129
#define checkTestNotDoneF(testClass,name) \
130
(testClass##_##name##_instance.isNotDone())
131
133
#define checkTestPassF(testClass,name) \
134
(testClass##_##name##_instance.isPassed())
135
137
#define checkTestNotPassF(testClass,name) \
138
(testClass##_##name##_instance.isNotPassed())
139
141
#define checkTestFailF(testClass,name) \
142
(testClass##_##name##_instance.isFailed())
143
145
#define checkTestNotFailF(testClass,name) \
146
(testClass##_##name##_instance.isNotFailed())
147
149
#define checkTestSkipF(testClass,name) \
150
(testClass##_##name##_instance.isSkipped())
151
153
#define checkTestNotSkipF(testClass,name) \
154
(testClass##_##name##_instance.isNotSkipped())
155
157
#define checkTestExpireF(testClass,name) \
158
(testClass##_##name##_instance.isExpired())
159
161
#define checkTestNotExpireF(testClass,name) \
162
(testClass##_##name##_instance.isNotExpired())
163
164
// If the assertTestXxx() macros fail, they generate an optional output, calls
165
// fail(), and returns from the current test case.
166
168
#define assertTestDoneF(testClass,name) \
169
assertTestStatusInternalF(testClass, name, isDone, kMessageDone)
170
172
#define assertTestNotDoneF(testClass,name) \
173
assertTestStatusInternalF(testClass, name, isNotDone, kMessageNotDone)
174
176
#define assertTestPassF(testClass,name) \
177
assertTestStatusInternalF(testClass, name, isPassed, kMessagePassed)
178
180
#define assertTestNotPassF(testClass,name) \
181
assertTestStatusInternalF(testClass, name, isNotPassed, kMessageNotPassed)
182
184
#define assertTestFailF(testClass,name) \
185
assertTestStatusInternalF(testClass, name, isFailed, kMessageFailed)
186
188
#define assertTestNotFailF(testClass,name) \
189
assertTestStatusInternalF(testClass, name, isNotFailed, kMessageNotFailed)
190
192
#define assertTestSkipF(testClass,name) \
193
assertTestStatusInternalF(testClass, name, isSkipped, kMessageSkipped)
194
196
#define assertTestNotSkipF(testClass,name) \
197
assertTestStatusInternalF(testClass, name, isNotSkipped, \
198
kMessageNotSkipped)
199
201
#define assertTestExpireF(testClass,name) \
202
assertTestStatusInternalF(testClass, name, isExpired, kMessageExpired)
203
205
#define assertTestNotExpireF(testClass,name) \
206
assertTestStatusInternalF(testClass, name, isNotExpired, \
207
kMessageNotExpired)
208
210
#define assertTestStatusInternalF(testClass,name,method,message) do {\
211
if (!assertionTestStatus(\
212
__FILE__,__LINE__,#name,FPSTR(message),\
213
testClass##_##name##_instance.method()))\
214
return;\
215
} while (false)
216
217
#endif
Generated by
1.8.13