|
Boost : |
Subject: Re: [boost] [Boost.Test] access to boost::unit_test::framework::master_test_suite().{argc, argv} outside from BOOST_TEST
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2017-04-01 06:19:55
> my test program uses boost.test datasets. I've wrote a filesystem
> loader for the input and expected data. Now I run into the problem,
> that boost::unit_test::framework::master_test_suite().{argc, argv} is
> only setup inside the tests self. My loader isn't a test case ... I
> can check it by using a simple mock, like
>
> struct app_mock
> {
> app_mock();
>
> int const argc;
> char** const argv;
> };
>
> app_mock::app_mock()
> : argc(boost::unit_test::framework::master_test_suite().argc)
> , argv(boost::unit_test::framework::master_test_suite().argv)
> { }
>
> BOOST_AUTO_TEST_CASE( app_mocker )
> {
> app_mock app;
> std::cout << "Count = " << app.argc << '\n';
> for(int i = 0; i != app.argc; i++)
> std::cout << "Arg = " << app.argv[i] << '\n';
> }
BOOST_GLOBAL_FIXTURE(app_mock);
also important here.
>
>
> $ my_test -- my_args
>
> Count = 2
>
> path/to/exe
>
> my_args
>
>
> these works, but as mentioned:
>
> dataset_loader::dataset_loader(fs::path const& path)
> {
> app_mock app;
>
> std::cout << "ARGC = " <<
> boost::unit_test::framework::master_test_suite().argc << '\n';
> read_files(path);
> }
>
> is always zero.
>
>
> How can I read the argc/argv values?
>
>
> Thanks,
>
> Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk