Boost logo

Boost :

Subject: [boost] metatest interface update, better Boost.Test integration
From: Ábel Sinkovics (abel_at_[hidden])
Date: 2011-09-24 06:17:27


Thank you for the feedback about my library so far.

I've done changes to the interface of the metatest library (currently
part of mpllibs - The purpose of
the changes was to improve compatibility with Boost.Test. They make it
easy to embed assertions of compile-time predicates in runtime test

The result and pretty-printed reason of a compile-time predicate is
represented by an object of type test_result
( at runtime.
These objects can be built using a template function,
test_result::build. It evaluates the predicate and does the

operator<< is overloaded for test_result, thus one can easily display
these objects in output streams. This is useful for passing the results
of compile-time tests to runtime unit testing frameworks.

I've implemented the metaprogramming equivalent of the BOOST_<level>()
macros as template functions (meta_<level>). One can use them the
following way:

  equal_to<int_<13>, metafunction_to_test<int, char> >

  equal_to<int_<13>, metafunction_to_test<int, char> >
>(MPLLIBS_HERE, "Some message");

// ...

I've used a template function instead of a macro to improve the error
messages about syntax errors in the predicates. The template function
takes a location
( object as
argument and metatest provides a macro, MPLLIBS_HERE, that constructs a
location object with the current filename:line values.

The template functions call BOOST_<level>_MESSAGE. A disadvantage of
this solution is that the error reports contain two filename:line
locations: the location of BOOST_<level>_MESSAGE in the integration
function and the location of MPLLIBS_HERE (which is the one the user
will be interested in).

I've added a new example demonstrating these integration functions. You
can find it in libs/metatest/example/boost_test_assertion in the source

I've tested the new interface with the same three compilers I've been
testing the libraries with (gcc 4.5, clang 2.8, Visual C++ 10).

I'm happy to receive feedback about the new interface. I'm interested if
people find it useful.


Boost list run by bdawes at, gregod at, cpdaniel at, john at