c++ - Integrating 'google test' and 'boost program options' -
i have program uses google test, , boost program options library parsing options. problem google test has it's own option parsers, need filter out before giving options google test.
for example, when run hello use follows
hello --option1=x --gtest_filter=footest.*
--option1 option use before passing --gtest_filter option google test.
when run following code, got exception --gtest_filter
not option use boost program options. how can combine options boost program options doesn't recognize give gtest's input?
#include <boost/program_options.hpp> namespace po = boost::program_options; #include <iostream> #include <fstream> #include <iterator> using namespace std; #include <gtest/gtest.h> int main(int argc, char **argv) { // filter out options google related options survive try { int opt; string config_file; po::options_description generic("generic options"); generic.add_options() ("option1,o", "print version string") ; ... } catch(exception& e) // ***************** { cout << e.what() << "\n"; return 1; } testing::initgoogletest(&argc, argv); return run_all_tests(); }
i found option ignore unknown options in page - http://www.boost.org/doc/libs/1_45_0/doc/html/program_options/howto.html#id2075428
store(po::command_line_parser(argc, argv). options(cmdline_options).positional(p).allow_unregistered().run(), vm);
Comments
Post a Comment