Boost logo

Boost Users :

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


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

Eric Prud'hommeaux <eric_at_[hidden]> spake the secret code
<20140527203520.GX5022_at_[hidden]> thusly:

>* Richard <legalize+jeeves_at_[hidden]> [2014-05-27 19:15+0000]
>>
>> Do you really need to build the test case tree by hand?
>
>Generally, yes. I'm working from standard test suites and it makes
>more sense to read them from the manifest than to write some emacs
>macro to turn the manifest into procedural code.

I see.

>> >. 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)));

The arguments to boost::unit_test::const_string are the char const*
pointer to the string and the number of characters in the string.
(For a C style string literal "foo" this is sizeof("foo")-1 which
evaluates to 3.)

Did you really mean to pass in 1 as the number of characters?

boost::unit_test::const_string takes a C-style string literal and
provides std::string style compatible semantics (i.e. iterators,
length property, etc.).

You can think of BOOST_TEST_CASE as just a more convenient way of
invoking the constructor for boost::unit_test::test_case:
<http://user.xmission.com/~legalize/boost.test/libs/test/doc/html/test/reference/test_classes/test_case.html>

I don't see any reason why you couldn't invoke the constructor
directly.

As for how fragile all of this is -- your guess is as good as mine;
I'm not the implementor of the library.

-- 
"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