doctest
doctest是一个基于C++的测试框架,与现有其它框架相比在编译时间及运行时间上有极大的改善。
该框架使用方法简单,仅需包含头文件doctest.h及#define指定的Macro即可使用(编译器需要支持C++11 feature),下面测试项目主页描述简单demo
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; }
TEST_CASE("testing the factorial function") {
CHECK(factorial(1) == 1);
CHECK(factorial(2) == 2);
CHECK(factorial(3) == 6);
CHECK(factorial(10) == 3628800);
}
编译及运行结果如下
g++ -std=c++11 test.cpp -o test
pi@raspberrypi:~/Codes/doctest $ ./test
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases: 1 | 1 passed | 0 failed | 0 skipped
[doctest] assertions: 4 | 4 passed | 0 failed |
[doctest] Status: SUCCESS!
详细描述github项目主页都有描述,此处不赘述及翻译。
github项目:https://github.com/doctest/doctest
Release(v2.4.11): https://github.com/doctest/doctest/releases/tag/v2.4.11