Home | Libraries | People | FAQ | More |
This section explains some of the design and implementation choices.
The general idea behind the library design is to be able to write tests quickly and easily as well as to get the best possible diagnostic upon error (both compile and runtime errors).
The chainable syntax has been chosen in order to be as intuitive as possible, with the most simple form covering the most general use cases.
Several design choices follow the same motivation :
At the same time customizing any aspect of the library should require minimum effort, for instance :
By design the exceptions thrown upon error should not inherit from std::exception, for instance consider the following test case based on the example from the motivation section :
BOOST_AUTO_TEST_CASE( overflow_throws ) { mock_view v; calculator c( v ); BOOST_CHECK_THROW( c.add( std::numeric_limits< int >::max(), 1 ), std::exception ); }
Any call to 'v' will be unexpected and yield an exception, which if it were an std::exception would erroneously make the test succeed whereas it is supposed to pass only if the operation overflows (thus not triggering 'v').
Despite being often considered harmful they also provide a number of advantages :
Variadic macros are available for fairly recent compilers and provide a smoother user interface :
An alternate more portable set of macros is provided for maximum portability if needed.