问题标签 [boost-unit-test-framework]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
850 浏览

c++ - 带有 boost::test 的谷歌模拟导致内存泄漏

我正在尝试使用 boost::test 和 google mock 创建单元测试。添加对 InitGoogleMock 的调用会导致 boost 发出一些内存泄漏的信号。我搜索了某种“DeInitGoogleMock”,但没有找到。

为什么会出现这种内存泄漏?如何修复?

主.cpp:

输出:

取消注释 InitGoogleMock 行后的输出:

0 投票
2 回答
261 浏览

c++ - 测试完成后如何强制 boost::unit_test 暂停?

从 Visual Studio 运行控制台程序时,控制台显示、程序运行,然后控制台消失,您没有机会看到它。

一般来说,我在mainreturn 语句之前添加这些行:

当程序使用boost::unit_test框架编译时,我该如何做类似的事情?由于它main是库的直接一部分,因此boost我无法修改它(我想避免boost为此重新编译)。

0 投票
0 回答
1008 浏览

cmake - 为什么 CMake 找不到 Boost?

我尝试使用 Boost 单元测试框架来测试我的静态库,但 CMake 无法找到 Boost,尽管BOOST_ROOT, CMAKE_INCLUDE_PATH, CMAKE_LIBRARY_PATH在调用find_package. 实际上,我已经根据类似问题的答案尝试了很多选择,但仍然没有成功。

cmake版本:3.6.1

升压版本:1.60.0

这是我在 GitHub 上的项目的链接

这是 TravisCI 的日志输出

CMakeLists.txt:

主.cpp:

SomeClass_test.cpp:

0 投票
1 回答
200 浏览

c++ - 我可以访问 BOOST_LOG_TRIVIAL 使用的流实例吗?

是否可以访问 BOOST_LOG_TRIVIAL 使用的底层流实例?

我正在尝试使用 BOOST_LOG_TRIVIAL 让 BOOST 单元测试框架写入输出(我已将其配置为写入文件和 std::clog)

自动& log_stream = ??? // BOOST_LOG_TRIVIAL 流实例 boost::unit_test::unit_test_log.instance().set_stream(log_stream);

0 投票
2 回答
749 浏览

boost - 使用 clang-tidy 处理大量与 boost 单元测试相关的警告

我正在建立一个项目。我使用 boost 单元测试进行了骨架测试。不幸的是,宏扩展会产生大量警告。有没有办法禁用这些,而不必指定单独的行号?

即使我有 // NOLINT,也会发生这种情况。

一个例子:

0 投票
0 回答
148 浏览

c++ - 如何为 boost 单元测试创​​建自定义输出/报告格式?

如何为 boost 单元测试创​​建自定义报告格式?

我正在查看文档,并且只能找到零碎的部分,尚不清楚它们是如何组合在一起的。我想我想要一个unit_test_log_formatter,但不知道如何添加它。或者也许我想要一个test_observer,但不知道如何添加它们。

我真的只想在测试输出结束时总结错误。正常报告中有太多输出,我正在寻找输出中的错误。

0 投票
1 回答
982 浏览

c++ - 使用夹具时提升单元测试过滤器

我需要指定一个特定的单元测试来运行。当然,我在查看文档后查看了 Stack Overflow Answers,但都没有使用固定装置。

如果我有以下情况,如何指定要运行的测试用例:

如果我通过--run_test=add_remove了,该过程返回一条消息测试设置错误:没有测试用例匹配过滤器或所有测试用例都被禁用。

我看过: http: //www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/runtime_config/test_unit_filtering.html

是否可以只运行 Boost 单元测试模块的子集?

如何设置要运行的 Boost 单元测试

0 投票
1 回答
334 浏览

c++ - Issue with BOOST unit_test_framework / Google Test on macOS Mojave

During a build process (unit tests) there are a bunch of errors like:
"error: no member named 'xxx' in the global namespace using::xxx;" ('xxx' is a type, e.g. uint8_t).

DETAILS:

  • in case if I include only <boost/test/unit_test.hpp>, the source of error is in the file /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint
  • in case if I include <boost/cstdint.hpp> before , the source of error is in the file /usr/local/include/boost/cstdint.hpp

ENVIRONMENT:

  • macOS Mojave
  • compiler: clang
  • CXX_STANDARD: 11 / 14
  • boost v.1.67.0_1 (installed using homebrew to default location - usr/local/Cellar/)

UPD: The same issue (with cstdint) happens with using Google Test (1.8.1)

0 投票
1 回答
97 浏览

c++ - Boost 1.64 单元测试编译失败

我开始阅读此处介绍的 boost 单元测试教程。

使用我的初始代码:

当我编译它时,我收到以下错误:

我自己编译了 boost,由于其他依赖限制,我使用的是 1.64 版。我也在使用 Visual Studio 2017 社区。

请问我该如何解决这个问题?

提前致谢。

0 投票
0 回答
141 浏览

c++ - 如何在 std::string 或 char* 中与 BOOST 框架进行比较(使用 boost/test/unit_test.hpp)

如何使用 BOOST 单元测试框架(使用)将std::string或* 与 liternal 字符串进行比较,charboost/test/unit_test.hpp

BOOST_CHECK并且BOOST_TEST不适用于字符串。