Boost logo

Boost Users :

Subject: Re: [Boost-users] naming a test
From: Richard (legalize+jeeves_at_[hidden])
Date: 2014-05-27 15:15:43


[Please do not mail me a copy of your followup]

boost-users_at_[hidden] spake the secret code
<20140525080836.GI5022_at_[hidden]> thusly:

>boost/libs/test/example/external_main_example_1.cpp provides an
>example of a dynamical test suite tree. The invocation of
> add( BOOST_TEST_CASE(boost::bind(&free_test_function, 1, 1)));
>results in unpleasant names like
> "boost::bind( &free_test_function, 1, 2 )"

Do you really need to build the test case tree by hand?

In your example this could just as easily have been done with
BOOST_AUTO_TEST_CASE.

>. I used the preprocessor output to override the 2nd arg to
>make_test_case with a name of my choosing:
> ts->add(boost::unit_test::make_test_case
> (boost::unit_test::callback0<>
> (boost::bind( &free_test_function, 1, 2)),
> boost::unit_test::const_string( minor, 1)));
>
>This works (pretty names and invocable with the logical run_test) but
>I have no particular confidence that this will survive version changes
>as well as would BOOST_TEST_CASE. Is there a better way to do this?

IMO, while passing a functor to BOOST_TEST_CASE works, it was intended
to be used with a free function that has an intention-revealing name
for the test case. See
<http://user.xmission.com/~legalize/boost.test/libs/test/doc/html/test/reference/test_case/boost_test_case.html>

-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net