Boost logo

Boost Users :

Subject: Re: [Boost-users] How to pass additional arguments to a boost test case?
From: Olaf Meeuwissen (olaf.meeuwissen_at_[hidden])
Date: 2011-12-06 18:04:43


Marc Magrans de Abril <marcmagransdeabril_at_[hidden]> writes:

> Dear colleagues,
>
> I would like to pass additional command line arguments to a given boost test. For example, if I
> execute the following from the command line:
> mytest.exe --log_level=all --param1=value1 --param2=value2
>
> then I would like to be able to get param1 and param2 parameters inside the test cases doing:
> BOOST_AUTO_TEST_CASE(read_
> param_from_command_line) {
>    std::cout << "Param1=" << some_function("param1") << std::endl;
>    std::cout << "Param2=" << some_function("param2") << std::endl;
> }
>
> What s the recommended approach in this case?

You can access the test runner's command-line arguments via:

  framework::master_test_suite().argc
  framework::master_test_suite().argv

Hope that helps,

-- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962

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