Question

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?

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top