Catch2和Boost.Test为编写单元测试提供了类似的功能。对于某个项目,我必须使用 Boost.Test 而不是 Catch2。我遇到的问题是两者都使用不同的格式输出。
例如,Catch2 会说 the was a fail in
test.cpp:9
(见下面的例子)。但是 Boost.Test 会说
test.cpp(9): error in ...
.
这种格式不允许我的编辑器将输出识别为源位置。
有没有办法让 Boost.Test 输出源位置file.ext:lineno
而不是file.ext(lineno)
?
这是 Catch2 的典型输出
----------------------------------------------
Testing Binary Search
----------------------------------------------
test.cpp:9
..............................................test.cpp:18: FAILED:
REQUIRE( binary_search(arr, 176) == 0 )
with expansion:
-1 == 0==============================================
test cases: 1 | 1 failed
assertions: 5 | 4 passed | 1 failed
这是 Boost.Test 的典型输出
Running 7 test cases...
./layout.hpp(764): error: in "layout_to_offset_1d_nontrivial": check L[3] == &B[3] - base(B) has failed [3 != 6]
Running 7 test cases...
./.././detail/layout.hpp(764): error: in "layout_to_offset_1d_nontrivial": check L[3] == &B[3] - base(B) has failed [3 != 6]
*** 1 failure is detected in the test module "C++ Unit Tests for Multi layout"