Boost logo

Boost Users :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2005-10-17 05:34:43


How do you access command-line arguments in test cases? According to
http://boost.org/libs/test/doc/components/utf/index.html:

"This function [boost::unit_test::test_suite* init_unit_test_suite ( int
argc, char* argv[] )] should create and initialize top level instance of
the class test_suite. The NULL pointer returned by the function is
treated as a non-initialized test_suite - testing aborted and
boost::exit_test_failure is returned. In other case the framework runs
created instance of the class test_suite. The framework forwards command
line argument specified during test invocation. It's guarantied that any
framework-specific command line arguments are excluded."

I understood this to mean that the command-line arguments are passed to
the test cases ("The framework forwards command line argument specified
during test invocation."), but this doesn't seem to be the case.

So how do you pass and access command-line arguments in the test cases?
I tried passing them explicitly:

    void digitise_graph_test(int argc, char* argv[])
    {
       [...]
    }

    boost::unit_test::test_suite* init_unit_test_suite(int argc, char*
argv[])
    {
        test -> add(BOOST_TEST_CASE(&my_test(argc, argv)));
    }

but this gives a compilation error:

    error C2102: '&' requires l-value

A secondary question, or rather, a polite request:

Could I ask that someone edit the documentation for unit test framework,
please? While is it mainly intelligible, some of it is difficult to
make sense of. Apologies to Gennadiy Rozental: this isn't meant as a
personal criticism nor to sound patronising, but when a developer's
first language is not the language in which the documentation is to be
published, it is preferable to have a speaker of that language write the
documentation or at least edit it.. I can cope with the grammatical or
spelling errors and am not criticising those, but the meaning is
somewhat difficult to derive in some places. Documentation must be
understandable to be useful, and to my mind, it is not at the moment.

Thanks.

Paul Giaccone


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