Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Disabling automatic printing for specific types

Most of the testing tools print values of their arguments to the output stream in some form of log statement. If arguments type does not support

operator<<(std::ostream&, ArgumentType const&);

interface you will get a compilation error. You can either implement above interface or prohibit the testing tools from logging argument values for specified type. To do so, use following statement on file level before first test case that includes statement failing to compile:

BOOST_TEST_DONT_PRINT_LOG_VALUE(ArgumentType)
Example: BOOST_TEST_DONT_PRINT_LOG_VALUE usage

Code

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include <utility>


typedef std::pair<int,float> pair_type;

BOOST_TEST_DONT_PRINT_LOG_VALUE( pair_type )

BOOST_AUTO_TEST_CASE( test_list )
{
  pair_type p1( 2, 5.5f );
  pair_type p2( 2, 5.501f );

  BOOST_CHECK_EQUAL( p1, p2 );
}

Output

Running 1 test case...
test.cpp(16): error in "test_list": check p1 == p2 has failed [ != ]

*** 1 failures is detected in test suite "example"

PrevUpHomeNext