Search code examples
c++boostboost-test

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& ?

so instead of

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

what should I replace std::cout with?


Solution

  • If you want to test the hexdump function you can pass in a std::ostringstream instead.

    Here and here are a few more examples of how to use it.