推荐一个单元测试库

idealities 2019-08-14

require 单元测试 github

https://github.com/catchorg/Catch2

写起来也很简单:


#define CATCH_CONFIG_MAIN
#include "catch.hpp"

unsigned int factorial( unsigned int n ) {
    return n <= 1 ? n : Factorial(n-1) * n;
}

TEST_CASE("Factorials are computed", "[factorial]" ) {
    REQUIRE( factorial(1) == 1 );
    REQUIRE( factorial(2) == 2 );
    REQUIRE( factorial(3) == 6 );
    REQUIRE( factorial(10) == 3628800 );
}
登录 后评论
下一篇
我是你爱豆
621人浏览
2019-08-22
相关推荐
推荐一个单元测试库
116人浏览
2019-08-19 15:53:10
当当网Docker应用实践
1035人浏览
2017-10-11 10:33:00
推荐一个单元测试库
126人浏览
2019-08-19 15:57:42
1
0
0
24980