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 a snapshot of the master branch, built from commit fa33539dff.
PrevUpHomeNext

BOOST_IS_DEFINED

BOOST_IS_DEFINED(symbol);

Unlike the rest of the tools in the toolbox this tool does not perform the logging itself. Its only purpose is to check at runtime whether or not the supplied preprocessor symbol is defined. Use it in combination with BOOST_<level> to perform and log validation. Macros of any arity could be checked. To check the macro definition with non-zero arity specify dummy arguments for it. See below for example.

The only tool's parameter is a preprocessor symbol that gets validated.

Example: BOOST_IS_DEFINED usage

Code

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

BOOST_AUTO_TEST_CASE( test )
{
  BOOST_TEST( BOOST_IS_DEFINED(SYMBOL1) );
  BOOST_TEST( BOOST_IS_DEFINED(SYMBOL2(arg)) );
}

Output

> example
Running 1 test case...
test.cpp(8): error in "test": check ::boost::test_tools::tt_detail::is_defined_impl( "SYMBOL1", "= SYMBOL1" ) failed
test.cpp(9): error in "test": check ::boost::test_tools::tt_detail::is_defined_impl( "SYMBOL2(arg)", "= SYMBOL2(arg)" ) failed

*** 2 failures are detected in test suite "example"

See also:


PrevUpHomeNext