Go to the source code of this file.
Classes | |
| struct | test_s |
| struct | test_res_s |
Macros | |
| #define | TEST_RES_OK 0 |
| #define | TEST_RES_FAIL -1 |
| #define | TEST_RES_ASSERT -2 |
| #define | ERREXIT() if (get_abort_on_error()) abort(); else inc_error_count() |
| #define | TEST_CHECK(x) |
| #define | TEST_CHECK_EQ(x, y) |
| #define | TEST_CHECK_NEQ(x, y) |
| #define | TEST_CHECK_GT(x, y) |
| #define | TEST_CHECK_LT(x, y) |
| #define | TEST_CHECK_GE(x, y) |
| #define | TEST_CHECK_LE(x, y) |
| #define | TEST_ASSERT(x) |
| #define | DBGT(...) printf(__VA_ARGS__) |
| #define | str(s) #s |
| #define | SUITE(sui) |
| #define | SUITE_TESTS(sui) void _add_suite_tests_##sui(void) { |
| #define | SUITE_END(sui) } |
| #define | ADD_TEST(tf) _add_test(__test_##tf, str(tf), setup, teardown, 0); |
| #define | ADD_TEST_NON_DEFAULT(tf) _add_test(__test_##tf, str(tf), setup, teardown, 1); |
| #define | ADD_SUITE(sui) |
| #define | TEST(tf) static int __test_##tf(struct test_s *t) { do |
| #define | TEST_END |
Typedefs | |
| typedef int(* | test_f) (struct test_s *t) |
| typedef struct test_s | test |
| typedef struct test_res_s | test_res |
Functions | |
| int | set_abort_on_error (int val) |
| int | get_abort_on_error (void) |
| int | get_error_count (void) |
| void | inc_error_count (void) |
| void | add_suites (void) |
| void | test_init (void(*on_stop)(test *t)) |
| int | run_tests (int argc, char **args) |
| void | _add_suite (const char *suite_name) |
| void | _add_test (test_f f, char *name, void(*setup)(test *t), void(*teardown)(test *t), int non_default) |
Macro Definition Documentation
◆ ADD_SUITE
| #define ADD_SUITE | ( | sui | ) |
Value:
extern void _add_suite_tests_##sui(void); \
_add_suite_tests_##sui();
◆ ADD_TEST
◆ ADD_TEST_NON_DEFAULT
◆ DBGT
| #define DBGT | ( | ... | ) | printf(__VA_ARGS__) |
◆ ERREXIT
| #define ERREXIT | ( | ) | if (get_abort_on_error()) abort(); else inc_error_count() |
◆ str
| #define str | ( | s | ) | #s |
◆ SUITE
| #define SUITE | ( | sui | ) |
◆ SUITE_END
| #define SUITE_END | ( | sui | ) | } |
◆ SUITE_TESTS
| #define SUITE_TESTS | ( | sui | ) | void _add_suite_tests_##sui(void) { |
◆ TEST
◆ TEST_ASSERT
| #define TEST_ASSERT | ( | x | ) |
Value:
if (!(x)) { \
printf(" TEST ASSERT %s:%d\n", __FILE__, __LINE__); \
goto __fail_assert; \
}
◆ TEST_CHECK
| #define TEST_CHECK | ( | x | ) |
Value:
if (!(x)) { \
printf(" TEST FAIL %s:%d\n", __FILE__, __LINE__); \
goto __fail_stop; \
}
◆ TEST_CHECK_EQ
| #define TEST_CHECK_EQ | ( | x, | |
| y | |||
| ) |
Value:
if ((x) != (y)) { \
printf(" TEST FAIL %s:%d, %d != %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_CHECK_GE
| #define TEST_CHECK_GE | ( | x, | |
| y | |||
| ) |
Value:
if ((x) < (y)) { \
printf(" TEST FAIL %s:%d, %d < %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_CHECK_GT
| #define TEST_CHECK_GT | ( | x, | |
| y | |||
| ) |
Value:
if ((x) <= (y)) { \
printf(" TEST FAIL %s:%d, %d <= %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_CHECK_LE
| #define TEST_CHECK_LE | ( | x, | |
| y | |||
| ) |
Value:
if ((x) > (y)) { \
printf(" TEST FAIL %s:%d, %d > %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_CHECK_LT
| #define TEST_CHECK_LT | ( | x, | |
| y | |||
| ) |
Value:
if ((x) >= (y)) { \
printf(" TEST FAIL %s:%d, %d >= %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_CHECK_NEQ
| #define TEST_CHECK_NEQ | ( | x, | |
| y | |||
| ) |
Value:
if ((x) == (y)) { \
printf(" TEST FAIL %s:%d, %d == %d\n", __FILE__, __LINE__, (int)(x), (int)(y)); \
goto __fail_stop; \
}
◆ TEST_END
| #define TEST_END |
Value:
◆ TEST_RES_ASSERT
| #define TEST_RES_ASSERT -2 |
◆ TEST_RES_FAIL
| #define TEST_RES_FAIL -1 |
◆ TEST_RES_OK
| #define TEST_RES_OK 0 |
Typedef Documentation
◆ test
◆ test_f
◆ test_res
| typedef struct test_res_s test_res |
Function Documentation
◆ _add_suite()
| void _add_suite | ( | const char * | suite_name | ) |
◆ _add_test()
| void _add_test | ( | test_f | f, |
| char * | name, | ||
| void(*)(test *t) | setup, | ||
| void(*)(test *t) | teardown, | ||
| int | non_default | ||
| ) |
◆ add_suites()
| void add_suites | ( | void | ) |
◆ get_abort_on_error()
| int get_abort_on_error | ( | void | ) |
◆ get_error_count()
| int get_error_count | ( | void | ) |
◆ inc_error_count()
| void inc_error_count | ( | void | ) |
◆ run_tests()
◆ set_abort_on_error()
◆ test_init()
| void test_init | ( | void(*)(test *t) | on_stop | ) |
1.8.17