AUnit
1.1
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
#include "
Flash.h
"
39
40
// Meta tests, same syntax as ArduinoUnit for compatibility.
41
// The checkTestXxx() macros return a boolean, and execution continues.
42
44
#define checkTestDone(name) (test_##name##_instance.isDone())
45
47
#define checkTestNotDone(name) (test_##name##_instance.isNotDone())
48
50
#define checkTestPass(name) (test_##name##_instance.isPassed())
51
53
#define checkTestNotPass(name) (test_##name##_instance.isNotPassed())
54
56
#define checkTestFail(name) (test_##name##_instance.isFailed())
57
59
#define checkTestNotFail(name) (test_##name##_instance.isNotFailed())
60
62
#define checkTestSkip(name) (test_##name##_instance.isSkipped())
63
65
#define checkTestNotSkip(name) (test_##name##_instance.isNotSkipped())
66
68
#define checkTestExpire(name) (test_##name##_instance.isExpired())
69
71
#define checkTestNotExpire(name) (test_##name##_instance.isNotExpired())
72
73
// If the assertTestXxx() macros fail, they generate an optional output, calls
74
// fail(), and returns from the current test case.
75
77
#define assertTestDone(name) \
78
assertTestStatusInternal(name, isDone, kMessageDone)
79
81
#define assertTestNotDone(name) \
82
assertTestStatusInternal(name, isNotDone, kMessageNotDone)
83
85
#define assertTestPass(name) \
86
assertTestStatusInternal(name, isPassed, kMessagePassed)
87
89
#define assertTestNotPass(name) \
90
assertTestStatusInternal(name, isNotPassed, kMessageNotPassed)
91
93
#define assertTestFail(name) \
94
assertTestStatusInternal(name, isFailed, kMessageFailed)
95
97
#define assertTestNotFail(name) \
98
assertTestStatusInternal(name, isNotFailed, kMessageNotFailed)
99
101
#define assertTestSkip(name) \
102
assertTestStatusInternal(name, isSkipped, kMessageSkipped)
103
105
#define assertTestNotSkip(name) \
106
assertTestStatusInternal(name, isNotSkipped, kMessageNotSkipped)
107
109
#define assertTestExpire(name) \
110
assertTestStatusInternal(name, isExpired, kMessageExpired)
111
113
#define assertTestNotExpire(name) \
114
assertTestStatusInternal(name, isNotExpired, kMessageNotExpired)
115
117
#define assertTestStatusInternal(name,method,message) do {\
118
if (!assertionTestStatus(\
119
__FILE__,__LINE__,#name,AUNIT_FPSTR(message),test_##name##_instance.method()))\
120
return;\
121
} while (false)
122
123
// Meta tests for testF() and testingF() are slightly different because
124
// the name of the fixture class is appended to the instance name.
125
127
#define checkTestDoneF(testClass,name) \
128
(testClass##_##name##_instance.isDone())
129
131
#define checkTestNotDoneF(testClass,name) \
132
(testClass##_##name##_instance.isNotDone())
133
135
#define checkTestPassF(testClass,name) \
136
(testClass##_##name##_instance.isPassed())
137
139
#define checkTestNotPassF(testClass,name) \
140
(testClass##_##name##_instance.isNotPassed())
141
143
#define checkTestFailF(testClass,name) \
144
(testClass##_##name##_instance.isFailed())
145
147
#define checkTestNotFailF(testClass,name) \
148
(testClass##_##name##_instance.isNotFailed())
149
151
#define checkTestSkipF(testClass,name) \
152
(testClass##_##name##_instance.isSkipped())
153
155
#define checkTestNotSkipF(testClass,name) \
156
(testClass##_##name##_instance.isNotSkipped())
157
159
#define checkTestExpireF(testClass,name) \
160
(testClass##_##name##_instance.isExpired())
161
163
#define checkTestNotExpireF(testClass,name) \
164
(testClass##_##name##_instance.isNotExpired())
165
166
// If the assertTestXxx() macros fail, they generate an optional output, calls
167
// fail(), and returns from the current test case.
168
170
#define assertTestDoneF(testClass,name) \
171
assertTestStatusInternalF(testClass, name, isDone, kMessageDone)
172
174
#define assertTestNotDoneF(testClass,name) \
175
assertTestStatusInternalF(testClass, name, isNotDone, kMessageNotDone)
176
178
#define assertTestPassF(testClass,name) \
179
assertTestStatusInternalF(testClass, name, isPassed, kMessagePassed)
180
182
#define assertTestNotPassF(testClass,name) \
183
assertTestStatusInternalF(testClass, name, isNotPassed, kMessageNotPassed)
184
186
#define assertTestFailF(testClass,name) \
187
assertTestStatusInternalF(testClass, name, isFailed, kMessageFailed)
188
190
#define assertTestNotFailF(testClass,name) \
191
assertTestStatusInternalF(testClass, name, isNotFailed, kMessageNotFailed)
192
194
#define assertTestSkipF(testClass,name) \
195
assertTestStatusInternalF(testClass, name, isSkipped, kMessageSkipped)
196
198
#define assertTestNotSkipF(testClass,name) \
199
assertTestStatusInternalF(testClass, name, isNotSkipped, \
200
kMessageNotSkipped)
201
203
#define assertTestExpireF(testClass,name) \
204
assertTestStatusInternalF(testClass, name, isExpired, kMessageExpired)
205
207
#define assertTestNotExpireF(testClass,name) \
208
assertTestStatusInternalF(testClass, name, isNotExpired, \
209
kMessageNotExpired)
210
212
#define assertTestStatusInternalF(testClass,name,method,message) do {\
213
if (!assertionTestStatus(__FILE__, __LINE__, #name, AUNIT_FPSTR(message),\
214
testClass##_##name##_instance.method()))\
215
return;\
216
} while (false)
217
218
// Methods that sets the status of the current test, prints a message, and
219
// exits immediately.
220
225
#define failTestNow() do {\
226
setStatusNow(__FILE__, __LINE__, kStatusFailed, AUNIT_FPSTR(kMessageFailed));\
227
return;\
228
} while (false)
229
234
#define passTestNow() do {\
235
setStatusNow(__FILE__, __LINE__, kStatusPassed, AUNIT_FPSTR(kMessagePassed));\
236
return;\
237
} while (false)
238
243
#define skipTestNow() do {\
244
setStatusNow(__FILE__, __LINE__, kStatusSkipped,\
245
AUNIT_FPSTR(kMessageSkipped));\
246
return;\
247
} while (false)
248
253
#define expireTestNow() do {\
254
setStatusNow(__FILE__, __LINE__, kStatusExpired,\
255
AUNIT_FPSTR(kMessageExpired));\
256
return;\
257
} while (false)
258
259
#endif
Flash.h
Various macros to smooth over the differences among the various platforms with regards to their suppo...
Generated by
1.8.13