c++ - 与 std::cout 等效的 Boost 测试框架是什么?

标签 c++ boost boost-test

我明白在我的单元测试中我应该做

BOOST_TEST_MESSAGE("message");

代替

std::cout << "message";

但是如果函数期望 std::ostream& 呢?

所以而不是

hexdump(std::cout, buffer, length);

我应该用什么替换 std::cout

最佳答案

如果您想测试 hexdump 函数,您可以传入一个 std::ostringstream

Herehere是如何使用它的几个例子。

关于c++ - 与 std::cout 等效的 Boost 测试框架是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9779633/

相关文章:

windows - 使用 mingw 编译器错误 : putenv not declared 在 Windows 上进行增强测试

c++ - 具有多边形裁剪区域的 Liang Barsky 裁线算法

c++ - 简单的二叉搜索树。分段故障

c++ - Fast Delegate (et al) 背后的想法是否已用于优化 std::function?

C++ MySQL 链接器错误

c++ - Boost 单元测试在 Visual Studio 2012 中抛出异常

c++ - 模板解析 - operator<< not found with boost-test

c++ - SDL_mixer 在特定事件上停止播放音乐

c++ - 为什么 M = L + ((R - L)/2) 而不是 M=(L+R)/2 在 C++ 中避免溢出?

c++ - Boost 1.48.0 upgrade_to_unique_lock on Linux : Has something changed since 1. 47 还是我做错了什么?