
Hi Gennadiy, The new interface looks very attractive. Below I enclose two suggestions that are orthogonal (I think) to your changes, but I thought it was a good time to suggest them. 2012/11/4 Gennadiy Rozental <rogeeff@gmail.com>
2. BOOST_CHECK_CLOSE, BOOST_CHECK_CLOSE_FRACTION, BOOST_CHECK_SMALL
We can deal with these by introducing couple special tags:
BOOST_TEST(a == 1.5, unit_test::tolerance(1e-6) ); BOOST_TEST(a == 0.003, unit_test::percent_tolerance(1e-6) ); BOOST_TEST(a, unit_test::small(1e-3) );
On a plus side we'll be able to use these in new previously unavailable way: BOOST_TEST(a > 1.1, unit_test::tolerance(1e-6) );
This would test that value of a either > 1.1 or within a fraction tolerance of it.
In my job, we are using Boost.Test in a commercial app. We are doing (and testing) some basic computations on physical quantities. It turned out that for around 95% of the checks on floating-point values we need the very same (percent) tolerance. And it is inconvenient to have to type the same constant time and again. It would be nice if there was a way to define (as an option) a "default tolerance". With the solution you propose above, having to type this tag "unit_test::percent_tolerance" would incur even more "syntactic noise" in cases where the tolerance is "obvious" to the reader. Here, the concept of default tolerance would be even more useful. Although I am not sure if this is doable. But perhaps it is: if I am able to configure the framework so that when it sees a check on floating-point numbers it assumes we check with tolerance: default one. What do you think? 4. BOOST_CHECK_EQUAL_COLLECTIONS
I think using overloading of equality comparisons we should be able to support this directly:
BOOST_TEST( expr == std::vector<int>{1,2,3,4});
Will that work? I.e., in case of any two ranges, not necessarily containers? If there is some even more clever (than my idea) suggestion to do it it is even better. What I was missing from Boost.Test for quite a while was some additional check that would accept as input two ranges rather than four iterators. "Range" R in this sense is any object for which expressions begin(R) and end(R) are valid: a container, an array, a pair of iterators. I often wanted to compare a vector returned by value from one expression with an array of values, and could not do it without introducing unnecessary additional variables: I had to write: int reference[] = {1, 2, 4}; auto&& answer = FindAnswer(); BOOST_CHECK_EQUAL_COLLECTIONS(begin(reference), end(reference), begin(answer), end(answer)); I would like to write: int reference[] = {1, 2, 4}; BOOST_CHECK_EQUAL_COLLECTIONS(reference, FindAnswer()); Or (if this is doable): BOOST_CHECK_EQUAL_COLLECTIONS(FindAnswer(), {1, 2, 4}); Regards, &rzej