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

Writing unit tests
PrevUpHomeNext

Once a test case has been declared, the body of this test should be written. A test case is a sequence of operations in which assertions are inserted. Those assertions evaluate statements that implement the expectation being validated, and report failures and/or informations in a uniform manner, depending on the log level.

The Unit Test Framework's supplies a toolbox of assertions to ease the creation and maintenance of test cases and provide a uniform error reporting mechanism. The toolbox supplied is in most part in a form of macro declarations. An (almost) unique interface to all of them implemented by the macro BOOST_TEST.

[Note] Note

All macros arguments are calculated once, so it's safe to pass complex expressions in their place.

All tools automatically supply an error location: a file name and a line number, which can also be overridden.

[Caution] Caution

The testing tools are intended for unit test code rather than library or production code, where throwing exceptions, using assert(), boost::concept_check or BOOST_STATIC_ASSERT() may be more suitable ways to detect and report errors.

For a list of all supplied testing tools and usage examples, see the summary or the reference.


PrevUpHomeNext