Boost logo

Boost Users :

From: Paul Giaccone (paulg_at_[hidden])
Date: 2005-10-17 06:46:57


Paul Giaccone wrote:

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

Just to clarify this:

* For "digitise_graph_test" read "my_test"
* The compilation error is at the line "test -> add(BOOST_TEST_CASE(&my_test(argc, argv)));"

I should have re-read my posting before hitting Send :)

Paul


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