Re: [Boost-users] boost program options
With reference to boost 1.59 and program options.
The following test passes on boost 1.53, but fails on boost 1.59.
I need to able to handle.
--arg1 10 and
--arg1=10
boost 1.59 now fails on '--arg1 10', with test below with option value
being empty.
#include <string>
#include <iostream>
#include <fstream>
#include
On 21 December 2015 at 17:22, avib369 .
With reference to boost 1.59 and program options. The following test passes on boost 1.53, but fails on boost 1.59.
You might want to create a ticket: https://svn.boost.org
I need to able to handle. --arg1 10 and --arg1=10
boost 1.59 now fails on '--arg1 10', with test below with option value being empty.
#include <string> #include <iostream> #include <fstream>
#include
#include #include using namespace std; namespace po = boost::program_options;
BOOST_AUTO_TEST_SUITE( BaseTestSuite )
BOOST_AUTO_TEST_CASE( test_program_options_implicit_value ) { cout << "Base:: ...test_program_options_implicit_value\n";
// Declare the supported options. po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") ("arg1", po::value<string>()->implicit_value( string("") ), "optional arg1 description") ;
{ char* argv[] = { const_cast
("test_program_options_implicit_value"), const_cast ("--help"), const_cast ("--arg1") }; po::variables_map vm; po::store(po::parse_command_line(3, argv, desc), vm); po::notify(vm);
BOOST_CHECK_MESSAGE(vm.count("help"), "Expected help"); BOOST_CHECK_MESSAGE(vm.count("arg1"), "Expected arg1"); BOOST_CHECK_MESSAGE(vm["arg1"].as<string>() == "", "Expected arg1 to be empty"); } { // ****** This fails on boost 1.59 bit passes in boost 1.53 ******* char* argv[] = { const_cast
("test_program_options_implicit_value"), const_cast ("--arg1"), const_cast ("10") }; po::variables_map vm; po::store(po::command_line_parser(3, argv, desc), vm); po::notify(vm);
BOOST_CHECK_MESSAGE(vm.count("arg1"), "Expected arg1"); BOOST_CHECK_MESSAGE(vm["arg1"].as<string>() == "10", "Expected arg1 with value of 10 but found '" << vm["arg1"].as<string>() << "'"); } { char* argv[] = { const_cast
("test_program_options_implicit_value"), const_cast ("--arg1=11") }; po::variables_map vm; po::store(po::parse_command_line(2, argv, desc), vm); po::notify(vm);
BOOST_CHECK_MESSAGE(vm.count("arg1"), "Expected arg1"); BOOST_CHECK_MESSAGE(vm["arg1"].as<string>() == "11", "Expected arg1 with value of 11 but found " << vm["arg1"].as<string>()); } }
Ta, Avi
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
avib369 .
-
Klaim - Joël Lamotte