
I have created an example of using the proposed assertion macros, by incorporating them into Boost Unit, and then creating a unit test which was previously not possible to write. With the current Boost Unit, the following unit test can be written: BOOST_AUTO_TEST_CASE(passing_assignment_compatible_units) { BOOST_CHECK_NO_THROW( quantity<length> L = 2.0 * meters; ); } And now, after incorporating BOOST_METATEST_MSG into Boost Unit, it is now possible to write the following unit test: BOOST_AUTO_TEST_CASE(failing_assignment_incompatible_units) { BOOST_CHECK_THROW( quantity<length> L = 2.0 * meters * meters;, metatest_exception ); } The required modification to Boost Unit, was to add the following templated constructor to boost::units::quantity: template <class rhs_type> quantity(const rhs_type& source) : val_() { BOOST_METATEST_MSG(false, INVALID_CONVERSION_BETWEEN_INCOMPATIBLE_UNITS, (this_type, rhs_type)); } In the unmodified library, the lack of this constructor would produce the compiler error, when an incorrect assignment requiring this constructor was made. This makes an interesting point, that I have written additional code to *explicitly* express the intended failure consequence of invoking this constructor, instead of relying *implicitly *on the lack of such a definition. A significant benefit of this change, is that the compiler error message now produced, is now controlled by the BOOST_MPL_ASSERT_MSG macro, instead of a generic compiler specific message. I don't think I need to justify why BOOST_MPL_ASSERT_MSG is preferred to a generic compiler error, with this group. :)) The source for this example has been uploaded to the Metatest git repository at https://github.com/icaretaker/Metatest, in the example_boost_unit subdirectory. Thank you all again in advance for your feedback, Ben Robinson, Ph.D.