MCPcopy Create free account
hub / github.com/Kitware/CMake / testArgumentParserDynamic

Function testArgumentParserDynamic

Tests/CMakeLib/testArgumentParser.cxx:325–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325bool testArgumentParserDynamic()
326{
327 Result result;
328 result.Sub = Result::SubResult();
329
330 std::vector<std::string> unparsedArguments;
331
332 std::function<ArgumentParser::Continue(cm::string_view, cm::string_view)>
333 func4 = [&result](cm::string_view key,
334 cm::string_view arg) -> ArgumentParser::Continue {
335 return result.Func4(key, arg);
336 };
337
338 cmArgumentParser<void> parserDynamic;
339 parserDynamic.Bind("OPTION_1"_s, result.Option1);
340 ASSERT_TRUE(parserDynamic.HasKeyword("OPTION_1"_s));
341 ASSERT_TRUE(!parserDynamic.HasKeyword("NOT_AN_OPTION"_s));
342
343 auto subParser = cmArgumentParser<void>{}
344 .Bind("SUB_CMD"_s, result.Sub->SubCommand)
345 .Bind("SUB_OPTION"_s, result.Sub->SubOption)
346 .Bind("SUB_STRING"_s, result.Sub->SubString)
347 .Bind("SUB_LIST"_s, result.Sub->SubList)
348 .BindParsedKeywords(result.Sub->ParsedKeywords);
349
350 static_cast<ArgumentParser::ParseResult&>(result) =
351 cmArgumentParser<void>{}
352 .Bind(0, result.Pos0)
353 .Bind(1, result.Pos1)
354 .Bind(2, result.Pos2)
355 .BindTrailingArgs(result.TrailingPos)
356 .Bind("OPTION_1"_s, result.Option1)
357 .Bind("OPTION_2"_s, result.Option2)
358 .Bind("STRING_1"_s, result.String1)
359 .Bind("STRING_2"_s, result.String2)
360 .Bind("STRING_3"_s, result.String3)
361 .Bind("STRING_4"_s, result.String4)
362 .Bind("STRING_5"_s, result.String5)
363 .Bind("STRING_6"_s, result.String6)
364 .Bind("LIST_1"_s, result.List1)
365 .Bind("LIST_2"_s, result.List2)
366 .Bind("LIST_3"_s, result.List3)
367 .Bind("LIST_4"_s, result.List4)
368 .Bind("LIST_5"_s, result.List5)
369 .Bind("LIST_6"_s, result.List6)
370 .Bind("MULTI_1"_s, result.Multi1)
371 .Bind("MULTI_2"_s, result.Multi2)
372 .Bind("MULTI_3"_s, result.Multi3)
373 .Bind("MULTI_4"_s, result.Multi4)
374 .Bind("FUNC_0"_s,
375 [&result](cm::string_view arg) -> ArgumentParser::Continue {
376 return result.Func0(arg);
377 })
378 .Bind("FUNC_1"_s,
379 [&result](cm::string_view arg) -> ArgumentParser::Continue {
380 return result.Func1(arg);
381 })
382 .Bind("FUNC_2a"_s,

Callers 1

testArgumentParserFunction · 0.85

Calls 12

SubResultClass · 0.85
verifyResultFunction · 0.85
Func4Method · 0.80
BindTrailingArgsMethod · 0.80
Func0Method · 0.80
Func1Method · 0.80
Func2Method · 0.80
Func3Method · 0.80
BindMethod · 0.45
HasKeywordMethod · 0.45
ParseMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…