|
|
#define | VA_NARG(args...) VA_NARG_(0, ##args, VA_RSEQ_N()) |
| |
|
#define | VA_NARG_(args...) VA_ARG_N(args) |
| |
|
#define | VA_ARG_N(_0, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, N, ...) N |
| |
|
#define | VA_RSEQ_N() 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 |
| |
|
#define | VA_FIRST(args...) VA_FIRST_(args) |
| |
|
#define | VA_FIRST_(F, ...) F |
| |
|
#define | VA_FIRST_STR(args...) VA_FIRST_STR_(args) |
| |
|
#define | VA_FIRST_STR_(F, ...) #F |
| |
|
#define | VA_REST_(F, args...) args |
| |
|
#define | VA_REST(args...) VA_REST_(args) |
| |
|
#define | UT_FAIL "FAIL" |
| |
|
#define | UT_PASS "PASS" |
| |
|
#define | ut_set_quiet(num) ut.quiet = num; |
| |
|
#define | ut_assert(test...) |
| |
|
#define | ut_dec_test(testname) int testname##_test() |
| |
| #define | ut_def_test(testname, ...) |
| |
|
#define | ut_run_test(testname) |
| |
| #define | ut_print_test() |
| |
单元测试头文件
- 作者
- lancer (lance.nosp@m.rsta.nosp@m.dium@.nosp@m.163..nosp@m.com)
- 版本
- 0.1
- 日期
- 2023-12-28
- 版权所有
- Copyright (c) 2023
- 注解
- 参考项目:Gitee | MiniUnit
A small unit test framework for C/C++.
Origin author: Bo Zhuang sdzhu.nosp@m.angb.nosp@m.o@hot.nosp@m.mail.nosp@m..com Features:
ut_assert(expr) assertion fail if expr false
ut_assert(expr, message) assertion with message
ut_assert(expr, message, args...) assertion with message and args
ut_run_test(test) to run a test function in form int f() return 0 if passed
ut_test_results() to display the test results
#define MU_NOCOLOR if ANSI escape code not supported
For example,
int test_one() {
ut_assert(2 + 2 == 4);
return 0;
}
int test_two() {
int a = 3, b = 5;
ut_assert(a == 3);
ut_assert(b == 5, "b is 5");
ut_assert(a + b == 7, "should be %d", a + b);
return 0;
}
{
ut_run_test(test_one);
ut_run_test(test_two);
ut_test_results();
return 0;
}
int main(int argc, char *argv[], char *envp[])
主函数
Definition cemu.c:30