greatest 介绍
greatest 是一个 C 语言的单元测试系统,只需要一个文件支持。示例代码:
$ cat simple.c #include "greatest.h" TEST x_should_equal_1() { int x = 1; ASSERT_EQ(1, x); /* default message */ ASSERT_EQm("yikes, x doesn't equal 1", 1, x); /* custom message */ PASS(); } SUITE(the_suite) { RUN_TEST(x_should_equal_1); } /* Add deFinitions that need to be in the test runner's main file. */ GREATEST_MAIN_DEFS(); int main(int argc, char **argv) { GREATEST_MAIN_BEGIN(); /* command-line arguments, initialization. */ RUN_SUITE(the_suite); GREATEST_MAIN_END(); /* display results */ } $ make simple && ./simple cc -g -Wall -Werror -pedantic simple.c -o simple * Suite the_suite: . 1 tests - 1 pass, 0 fail, 0 skipped (5 ticks, 0.000 sec) Total: 1 tests (47 ticks, 0.000 sec) Pass: 1, fail: 0, skip: 0.
greatest 官网
https://github.com/silentbicycle/greatest
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。