59 #ifndef BSP430_UTILITY_UNITTEST_H
60 #define BSP430_UTILITY_UNITTEST_H
74 #ifndef configBSP430_UNITTEST
75 #define configBSP430_UNITTEST 0
85 #define BSP430_UNITTEST (configBSP430_UNITTEST - 0)
87 #if defined(BSP430_DOXYGEN) || (defined(BSP430_LED_GREEN) && defined(BSP430_LED_RED))
92 #define BSP430_UNITTEST_LED_FAILED BSP430_LED_RED
98 #define BSP430_UNITTEST_LED_PASSED BSP430_LED_GREEN
100 #define BSP430_UNITTEST_LED_FAILED 0
101 #define BSP430_UNITTEST_LED_PASSED 1
114 #ifndef configBSP430_UNITTEST_FAILFAST
115 #define configBSP430_UNITTEST_FAILFAST 0
158 #define BSP430_UNITTEST_FAIL(msg_) do { \
159 vBSP430unittestResult_(__LINE__, 0, msg_); \
163 #define BSP430_UNITTEST_ASSERT_TRUE(expr_) do { \
164 static const char * expr_str_ = #expr_; \
165 vBSP430unittestResult_(__LINE__, !!(expr_), expr_str_); \
169 #define BSP430_UNITTEST_ASSERT_FALSE(expr_) do { \
170 static const char * expr_str_ = #expr_; \
171 vBSP430unittestResult_(__LINE__, !(expr_), "NOT %s", expr_str_); \
175 #define BSP430_UNITTEST_ASSERT_EQUAL(v1_,v2_) do { \
176 static const char * expr_str_ = #v1_ "==" #v2_; \
177 vBSP430unittestResult_(__LINE__, (v1_) == (v2_), expr_str_); \
181 #define BSP430_UNITTEST_ASSERT_EQUAL_ASCIIZ(v1_,v2_) do { \
182 static const char * expr_str_ = #v1_ "==" #v2_; \
183 const char * v1v_ = (v1_); \
184 const char * v2v_ = (v2_); \
185 vBSP430unittestResult_(__LINE__, 0 == strcmp(v1v_, v2v_), expr_str_); \
200 #define BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,type_,pri_) do { \
201 static const char * expr_str_ = #v1_ "==" #v2_; \
202 type_ v1v_ = (v1_); \
203 type_ v2v_ = (v2_); \
204 if (v1v_ == v2v_) { \
205 vBSP430unittestResult_(__LINE__, 1, "%s", expr_str_); \
207 vBSP430unittestResult_(__LINE__, 0, "%s: " pri_ " != " pri_, expr_str_, v1v_, v2v_); \
216 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTd(v1_,v2_) \
217 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,int,"%" PRId16)
223 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTu(v1_,v2_) \
224 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned int,"%" PRIu16)
230 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTx(v1_,v2_) \
231 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned int,"%#" PRIx16)
237 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTld(v1_,v2_) \
238 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,long,"%" PRId32)
245 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTlld(v1_,v2_) \
246 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,long long,"%" PRId64)
253 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTlu(v1_,v2_) \
254 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long,"%" PRIu32)
261 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTllu(v1_,v2_) \
262 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long long,"%" PRIu64)
269 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTlx(v1_,v2_) \
270 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long, "%#" PRIx32)
277 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTllx(v1_,v2_) \
278 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long long, "%#" PRIx64)
284 #define BSP430_UNITTEST_ASSERT_EQUAL_FMTp(v1_,v2_) \
285 BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,const void *,"%p")
void vBSP430unittestInitialize(void)
Common header included by all BSP430 leaf headers.
void vBSP430unittestResult_(int line, int passp, const char *format,...)
void vBSP430unittestFinalize(void)