本文整理汇总了C++中CmdLineParser::has方法的典型用法代码示例。如果您正苦于以下问题:C++ CmdLineParser::has方法的具体用法?C++ CmdLineParser::has怎么用?C++ CmdLineParser::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmdLineParser
的用法示例。
在下文中一共展示了CmdLineParser::has方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* If you have extra command line parameters, you may use this method to start CPUnit
* after you have done your own. You should use {@link #get_cmd_line_parser()} to obtain
* a parser which is already set up to accept the CPUnit specific command line parameters,
* and then use CmdLineParser.add_legal to specify the arguments you expect in addition.
*
* @param parser A parser contaiing the command line arguments, excluding the program name.
* I.e. from main(int& argc,char** args), the parser would be called as
* {@link CmdLineParser#parse(const int, const char**) parser.parse(arcg-1,args+1)}.
* @return 0 if all tests succeed, and >0 elsewise.
*/
int main(const CmdLineParser &parser) {
AutoDisposer ad;
try {
CPUNIT_ITRACE("EntryPoint - Actual arguments:"<<parser.to_string());
std::vector<std::string> patterns = parser.program_input();
if (patterns.size() == 0) {
patterns.push_back("*");
}
if(parser.has_one_of("-h --help")) {
usage();
return 0;
}
if(parser.has_one_of("-L --list")) {
list_tests(patterns);
return 0;
}
if(parser.has_one_of("-V --version")) {
print_version_info();
return 0;
}
const bool verbose = parser.has("-v") || parser.has("--verbose");
const bool robust = parser.has("-a") || parser.has("--all");
const bool conformity = parser.has("--conformity");
CPUNIT_ITRACE("EntryPoint - verbose="<<verbose<<" robust="<<robust<<" conformity="<<conformity);
bool conform = true;
if (conformity) {
std::vector<std::string> conf_patterns = get_conformity_format(parser);
const int num_conformity_breaches = conformity_report(patterns, conf_patterns[0], conf_patterns[1], conf_patterns[2], verbose, std::cout);
std::cout<<"There where "<<num_conformity_breaches<<" conformity breaches."<<std::endl;
conform = num_conformity_breaches == 0;
}
const std::string report_format = parser.value_of<std::string>(error_format_token);
const double max_time = parser.value_of<double>(max_time_token);
const std::vector<cpunit::ExecutionReport> result = cpunit::TestExecutionFacade().execute(patterns, max_time, verbose, robust);
bool all_well = report_result(result, report_format, std::cout);
int exit_value = 0;
if (!all_well) {
exit_value |= 0x1;
}
if(!conform) {
exit_value |= 0x2;
}
return exit_value;
} catch (AssertionException &e) {
std::cout<<"Terminated due to AssertionException: "<<std::endl<<e.what()<<std::endl;
return 1;
}
}