本文整理汇总了C++中TestOptTable类的典型用法代码示例。如果您正苦于以下问题:C++ TestOptTable类的具体用法?C++ TestOptTable怎么用?C++ TestOptTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestOptTable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(Option, SlurpJoinedOneJoined) {
TestOptTable T;
unsigned MAI, MAC;
const char *MyArgs[] = { "-A", "-slurpjoinedfoo" };
InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);
EXPECT_TRUE(AL.hasArg(OPT_A));
EXPECT_TRUE(AL.hasArg(OPT_SlurpJoined));
EXPECT_EQ(AL.getAllArgValues(OPT_SlurpJoined).size(), 1U);
EXPECT_EQ(AL.getAllArgValues(OPT_SlurpJoined)[0], "foo");
}
开发者ID:Tauril,项目名称:llvm,代码行数:11,代码来源:OptionParsingTest.cpp
示例2: TEST
TEST(Option, AliasArgs) {
TestOptTable T;
unsigned MAI, MAC;
const char *MyArgs[] = { "-J", "-Joo" };
std::unique_ptr<InputArgList> AL(
T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_B));
EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], "foo");
EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");
}
开发者ID:AmesianX,项目名称:dagger,代码行数:11,代码来源:OptionParsingTest.cpp
示例3: TEST
TEST(Option, DashDash) {
TestOptTable T;
unsigned MAI, MAC;
const char *MyArgs[] = { "-A", "--", "-B", "--" };
OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_FALSE(AL->hasArg(OPT_B));
EXPECT_EQ(AL->getAllArgValues(OPT_INPUT).size(), 2U);
EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[0], "-B");
EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[1], "--");
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_llvm,代码行数:12,代码来源:OptionParsingTest.cpp
示例4: printHelp
void TestOptions::printHelp(bool ShowHidden) const {
// Based off of swift/lib/Driver/Driver.cpp, at Driver::printHelp
//FIXME: should we use IncludedFlagsBitmask and ExcludedFlagsBitmask?
// Maybe not for modes such as Interactive, Batch, AutolinkExtract, etc,
// as in Driver.cpp. But could be useful for extra info, like HelpHidden.
TestOptTable Table;
Table.PrintHelp(llvm::outs(), "sourcekitd-test", "SourceKit Testing Tool",
ShowHidden);
}
开发者ID:Nirma,项目名称:swift,代码行数:12,代码来源:TestOptions.cpp
示例5: TEST
TEST(Support, OptionParsing) {
TestOptTable T;
unsigned MAI, MAC;
OwningPtr<InputArgList>
AL(T.ParseArgs(Args,
Args + (sizeof(Args) / sizeof(Args[0])),
MAI,
MAC));
// Check they all exist.
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_TRUE(AL->hasArg(OPT_B));
EXPECT_TRUE(AL->hasArg(OPT_C));
EXPECT_TRUE(AL->hasArg(OPT_D));
EXPECT_TRUE(AL->hasArg(OPT_E));
EXPECT_TRUE(AL->hasArg(OPT_F));
EXPECT_TRUE(AL->hasArg(OPT_G));
// Check the values.
EXPECT_EQ(AL->getLastArgValue(OPT_B), "hi");
EXPECT_EQ(AL->getLastArgValue(OPT_C), "bye");
EXPECT_EQ(AL->getLastArgValue(OPT_D), "adena");
std::vector<std::string> Es = AL->getAllArgValues(OPT_E);
EXPECT_EQ(Es[0], "apple");
EXPECT_EQ(Es[1], "bloom");
EXPECT_EQ(AL->getLastArgValue(OPT_F), "42");
std::vector<std::string> Gs = AL->getAllArgValues(OPT_G);
EXPECT_EQ(Gs[0], "chuu");
EXPECT_EQ(Gs[1], "2");
// Check the help text.
std::string Help;
raw_string_ostream RSO(Help);
T.PrintHelp(RSO, "test", "title!");
EXPECT_NE(Help.find("-A"), std::string::npos);
// Test aliases.
arg_iterator Cs = AL->filtered_begin(OPT_C);
ASSERT_NE(Cs, AL->filtered_end());
EXPECT_EQ(StringRef((*Cs)->getValue()), "desu");
ArgStringList ASL;
(*Cs)->render(*AL, ASL);
ASSERT_EQ(ASL.size(), 2u);
EXPECT_EQ(StringRef(ASL[0]), "-C");
EXPECT_EQ(StringRef(ASL[1]), "desu");
}
开发者ID:Arcterus,项目名称:llvm,代码行数:46,代码来源:OptionParsingTest.cpp
示例6: parseArgs
bool TestOptions::parseArgs(llvm::ArrayRef<const char *> Args) {
if (Args.empty())
return false;
// Parse command line options using Options.td
TestOptTable Table;
unsigned MissingIndex;
unsigned MissingCount;
llvm::opt::InputArgList ParsedArgs =
Table.ParseArgs(Args, MissingIndex, MissingCount);
if (MissingCount) {
llvm::errs() << "error: missing argument value for '"
<< ParsedArgs.getArgString(MissingIndex) << "', expected "
<< MissingCount << " argument(s)\n";
return true;
}
for (auto InputArg : ParsedArgs) {
switch (InputArg->getOption().getID()) {
case OPT_req:
Request = llvm::StringSwitch<SourceKitRequest>(InputArg->getValue())
.Case("version", SourceKitRequest::ProtocolVersion)
.Case("demangle", SourceKitRequest::DemangleNames)
.Case("mangle", SourceKitRequest::MangleSimpleClasses)
.Case("index", SourceKitRequest::Index)
.Case("complete", SourceKitRequest::CodeComplete)
.Case("complete.open", SourceKitRequest::CodeCompleteOpen)
.Case("complete.close", SourceKitRequest::CodeCompleteClose)
.Case("complete.update", SourceKitRequest::CodeCompleteUpdate)
.Case("complete.cache.ondisk", SourceKitRequest::CodeCompleteCacheOnDisk)
.Case("complete.setpopularapi", SourceKitRequest::CodeCompleteSetPopularAPI)
.Case("cursor", SourceKitRequest::CursorInfo)
.Case("related-idents", SourceKitRequest::RelatedIdents)
.Case("syntax-map", SourceKitRequest::SyntaxMap)
.Case("structure", SourceKitRequest::Structure)
.Case("format", SourceKitRequest::Format)
.Case("expand-placeholder", SourceKitRequest::ExpandPlaceholder)
.Case("doc-info", SourceKitRequest::DocInfo)
.Case("sema", SourceKitRequest::SemanticInfo)
.Case("interface-gen", SourceKitRequest::InterfaceGen)
.Case("interface-gen-open", SourceKitRequest::InterfaceGenOpen)
.Case("find-usr", SourceKitRequest::FindUSR)
.Case("find-interface", SourceKitRequest::FindInterfaceDoc)
.Case("open", SourceKitRequest::Open)
.Case("edit", SourceKitRequest::Edit)
.Case("print-annotations", SourceKitRequest::PrintAnnotations)
.Case("print-diags", SourceKitRequest::PrintDiags)
.Case("extract-comment", SourceKitRequest::ExtractComment)
.Case("module-groups", SourceKitRequest::ModuleGroups)
.Default(SourceKitRequest::None);
if (Request == SourceKitRequest::None) {
llvm::errs() << "error: invalid request, expected one of "
<< "version/demangle/mangle/index/complete/cursor/related-idents/syntax-map/structure/"
"format/expand-placeholder/doc-info/sema/interface-gen/interface-gen-open/"
"find-usr/find-interface/open/edit/print-annotations/extract-comment/"
"module-groups\n";
return true;
}
break;
case OPT_offset:
if (StringRef(InputArg->getValue()).getAsInteger(10, Offset)) {
llvm::errs() << "error: expected integer for 'offset'\n";
return true;
}
break;
case OPT_length:
if (StringRef(InputArg->getValue()).getAsInteger(10, Length)) {
llvm::errs() << "error: expected integer for 'length'\n";
return true;
}
break;
case OPT_pos: {
auto linecol = parseLineCol(InputArg->getValue());
Line = linecol.first;
Col = linecol.second;
break;
}
case OPT_line:
if (StringRef(InputArg->getValue()).getAsInteger(10, Line)) {
llvm::errs() << "error: expected integer for 'line'\n";
return true;
}
Col = 1;
break;
case OPT_replace:
ReplaceText = InputArg->getValue();
break;
case OPT_module:
ModuleName = InputArg->getValue();
break;
case OPT_group_name:
ModuleGroupName = InputArg->getValue();
break;
//.........这里部分代码省略.........
开发者ID:hpux735,项目名称:swift,代码行数:101,代码来源:TestOptions.cpp
示例7: parseArgs
bool TestOptions::parseArgs(llvm::ArrayRef<const char *> Args) {
if (Args.empty())
return false;
// Parse command line options using Options.td
TestOptTable Table;
unsigned MissingIndex;
unsigned MissingCount;
llvm::opt::InputArgList ParsedArgs =
Table.ParseArgs(Args, MissingIndex, MissingCount);
if (MissingCount) {
llvm::errs() << "error: missing argument value for '"
<< ParsedArgs.getArgString(MissingIndex) << "', expected "
<< MissingCount << " argument(s)\n";
return true;
}
for (auto InputArg : ParsedArgs) {
switch (InputArg->getOption().getID()) {
case OPT_req:
Request = llvm::StringSwitch<SourceKitRequest>(InputArg->getValue())
.Case("version", SourceKitRequest::ProtocolVersion)
.Case("demangle", SourceKitRequest::DemangleNames)
.Case("mangle", SourceKitRequest::MangleSimpleClasses)
.Case("index", SourceKitRequest::Index)
.Case("complete", SourceKitRequest::CodeComplete)
.Case("complete.open", SourceKitRequest::CodeCompleteOpen)
.Case("complete.close", SourceKitRequest::CodeCompleteClose)
.Case("complete.update", SourceKitRequest::CodeCompleteUpdate)
.Case("complete.cache.ondisk", SourceKitRequest::CodeCompleteCacheOnDisk)
.Case("complete.setpopularapi", SourceKitRequest::CodeCompleteSetPopularAPI)
.Case("cursor", SourceKitRequest::CursorInfo)
.Case("related-idents", SourceKitRequest::RelatedIdents)
.Case("syntax-map", SourceKitRequest::SyntaxMap)
.Case("syntax-tree", SourceKitRequest::SyntaxTree)
.Case("structure", SourceKitRequest::Structure)
.Case("format", SourceKitRequest::Format)
.Case("expand-placeholder", SourceKitRequest::ExpandPlaceholder)
.Case("doc-info", SourceKitRequest::DocInfo)
.Case("sema", SourceKitRequest::SemanticInfo)
.Case("interface-gen", SourceKitRequest::InterfaceGen)
.Case("interface-gen-open", SourceKitRequest::InterfaceGenOpen)
.Case("find-usr", SourceKitRequest::FindUSR)
.Case("find-interface", SourceKitRequest::FindInterfaceDoc)
.Case("open", SourceKitRequest::Open)
.Case("close", SourceKitRequest::Close)
.Case("edit", SourceKitRequest::Edit)
.Case("print-annotations", SourceKitRequest::PrintAnnotations)
.Case("print-diags", SourceKitRequest::PrintDiags)
.Case("extract-comment", SourceKitRequest::ExtractComment)
.Case("module-groups", SourceKitRequest::ModuleGroups)
.Case("range", SourceKitRequest::RangeInfo)
.Case("syntactic-rename", SourceKitRequest::SyntacticRename)
.Case("find-rename-ranges", SourceKitRequest::FindRenameRanges)
.Case("find-local-rename-ranges", SourceKitRequest::FindLocalRenameRanges)
.Case("translate", SourceKitRequest::NameTranslation)
.Case("local-rename", SourceKitRequest::LocalRename)
.Case("extract-expr", SourceKitRequest::ExtractExpr)
.Case("extract-repeated", SourceKitRequest::ExtractRepeatedExpr)
.Case("extract-func", SourceKitRequest::ExtractFunction)
.Case("fill-stub", SourceKitRequest::FillProtocolStub)
.Case("expand-default", SourceKitRequest::ExpandDefault)
.Case("localize-string", SourceKitRequest::LocalizeString)
.Case("markup-xml", SourceKitRequest::MarkupToXML)
.Case("stats", SourceKitRequest::Statistics)
.Case("track-compiles", SourceKitRequest::EnableCompileNotifications)
.Default(SourceKitRequest::None);
if (Request == SourceKitRequest::None) {
llvm::errs() << "error: invalid request '" << InputArg->getValue()
<< "'\nexpected one of "
<< "version/demangle/mangle/index/complete/complete.open/complete.cursor/"
"complete.update/complete.cache.ondisk/complete.cache.setpopularapi/"
"cursor/related-idents/syntax-map/structure/format/expand-placeholder/"
"doc-info/sema/interface-gen/interface-gen-openfind-usr/find-interface/"
"open/close/edit/print-annotations/print-diags/extract-comment/module-groups/"
"range/syntactic-rename/find-rename-ranges/translate/markup-xml/stats/"
"track-compiles\n";
return true;
}
break;
case OPT_help: {
printHelp(false);
return true;
}
case OPT_offset:
if (StringRef(InputArg->getValue()).getAsInteger(10, Offset)) {
llvm::errs() << "error: expected integer for 'offset'\n";
return true;
}
break;
case OPT_length:
if (StringRef(InputArg->getValue()).getAsInteger(10, Length)) {
llvm::errs() << "error: expected integer for 'length'\n";
return true;
}
break;
//.........这里部分代码省略.........
开发者ID:Nirma,项目名称:swift,代码行数:101,代码来源:TestOptions.cpp
注:本文中的TestOptTable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论