X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Fprogram_options%2Ftest%2Frequired_test.cpp;h=1c623cd5c336cd440ab9498e4f5278aa9d826e82;hb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;hp=ee507e4f8dc0ec85af9f562a897ad79ea9b9fba0;hpb=a0324939f9d0e1905d5df8f57442f09dc70af83d;p=ceph.git diff --git a/ceph/src/boost/libs/program_options/test/required_test.cpp b/ceph/src/boost/libs/program_options/test/required_test.cpp index ee507e4f8..1c623cd5c 100644 --- a/ceph/src/boost/libs/program_options/test/required_test.cpp +++ b/ceph/src/boost/libs/program_options/test/required_test.cpp @@ -23,36 +23,36 @@ void required_throw_test() ; variables_map vm; - bool throwed = false; + bool thrown = false; { // This test must throw exception string cmdline = "prg -f file.txt"; vector< string > tokens = split_unix(cmdline); - throwed = false; + thrown = false; try { store(command_line_parser(tokens).options(opts).run(), vm); notify(vm); } catch (required_option& e) { BOOST_CHECK_EQUAL(e.what(), string("the option '--cfgfile' is required but missing")); - throwed = true; + thrown = true; } - BOOST_CHECK(throwed); + BOOST_CHECK(thrown); } { // This test mustn't throw exception string cmdline = "prg -c config.txt"; vector< string > tokens = split_unix(cmdline); - throwed = false; + thrown = false; try { store(command_line_parser(tokens).options(opts).run(), vm); notify(vm); } catch (required_option& e) { - throwed = true; + thrown = true; } - BOOST_CHECK(!throwed); + BOOST_CHECK(!thrown); } } @@ -67,12 +67,12 @@ void simple_required_test(const char* config_file) ; variables_map vm; - bool throwed = false; + bool thrown = false; { // This test must throw exception string cmdline = "prg -f file.txt"; vector< string > tokens = split_unix(cmdline); - throwed = false; + thrown = false; try { // options coming from different sources store(command_line_parser(tokens).options(opts).run(), vm); @@ -80,9 +80,35 @@ void simple_required_test(const char* config_file) notify(vm); } catch (required_option& e) { - throwed = true; + thrown = true; } - BOOST_CHECK(!throwed); + BOOST_CHECK(!thrown); + } +} + +void multiname_required_test() +{ + options_description opts; + opts.add_options() + ("foo,bar", value()->required(), "the foo") + ; + + variables_map vm; + bool thrown = false; + { + // This test must throw exception + string cmdline = "prg --bar file.txt"; + vector< string > tokens = split_unix(cmdline); + thrown = false; + try { + // options coming from different sources + store(command_line_parser(tokens).options(opts).run(), vm); + notify(vm); + } + catch (required_option& e) { + thrown = true; + } + BOOST_CHECK(!thrown); } } @@ -92,6 +118,7 @@ int main(int /*argc*/, char* av[]) { required_throw_test(); simple_required_test(av[1]); + multiname_required_test(); return 0; }