123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef CH_TEST_H
- #define CH_TEST_H
- #if !defined(TEST_MAX_TOKENS) || defined(__DOXYGEN__)
- #define TEST_MAX_TOKENS 16
- #endif
- #if !defined(TEST_DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__)
- #define TEST_DELAY_BETWEEN_TESTS 200
- #endif
- #if !defined(TEST_SHOW_SEQUENCES) || defined(__DOXYGEN__)
- #define TEST_SHOW_SEQUENCES TRUE
- #endif
- typedef struct {
- const char *name;
- void (*setup)(void);
- void (*teardown)(void);
- void (*execute)(void);
- } testcase_t;
- typedef struct {
- const char *name;
- const testcase_t * const * cases;
- } testsequence_t;
- typedef struct {
- const char *name;
- const testsequence_t * const * sequences;
- } testsuite_t;
- #define test_set_step(step) test_step = (step)
- #define test_fail(msg) { \
- _test_fail(msg); \
- return; \
- }
- #define test_assert(condition, msg) { \
- if (_test_assert(condition, msg)) \
- return; \
- }
- #define test_assert_lock(condition, msg) { \
- osalSysLock(); \
- if (_test_assert(condition, msg)) { \
- osalSysUnlock(); \
- return; \
- } \
- osalSysUnlock(); \
- }
- #define test_assert_sequence(expected, msg) { \
- if (_test_assert_sequence(expected, msg)) \
- return; \
- }
- #define test_assert_time_window(start, end, msg) { \
- if (_test_assert_time_window(start, end, msg)) \
- return; \
- }
- #if !defined(__DOXYGEN__)
- extern unsigned test_step;
- extern bool test_global_fail;
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- bool _test_fail(const char *message);
- bool _test_assert(bool condition, const char *msg);
- bool _test_assert_sequence(char *expected, const char *msg);
- bool _test_assert_time_window(systime_t start,
- systime_t end,
- const char *msg);
- void test_printn(uint32_t n);
- void test_print(const char *msgp);
- void test_println(const char *msgp);
- void test_emit_token(char token);
- void test_emit_token_i(char token);
- msg_t test_execute(BaseSequentialStream *stream, const testsuite_t *tsp);
- #ifdef __cplusplus
- }
- #endif
- #endif
|