简体   繁体   English

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

[英]What's the Boost test framework's equivalence of std::cout?

I understand that in my unit test I should do我明白在我的单元测试中我应该做

BOOST_TEST_MESSAGE("message");

instead of代替

std::cout << "message";

but what if for a function that's expecting std::ostream& ?但是如果对于一个期待std::ostream&的函数呢?

so instead of所以而不是

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

what should I replace std::cout with?我应该用什么替换std::cout

If you want to test the hexdump function you can pass in a std::ostringstream instead.如果要测试hexdump函数,可以改为传入std::ostringstream

Here and here are a few more examples of how to use it.此处此处是有关如何使用它的更多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM