diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:44:32 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-05-27 18:44:32 +0000 |
commit | 5a5ac124e1efaf208671f01c46edb15f29ed2a0b (patch) | |
tree | a6140557876943cdd800ee997c9317283394b22c /unittests/Option | |
parent | f03b5bed27d0d2eafd68562ce14f8b5e3f1f0801 (diff) |
Diffstat (limited to 'unittests/Option')
-rw-r--r-- | unittests/Option/OptionParsingTest.cpp | 14 | ||||
-rw-r--r-- | unittests/Option/Opts.td | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/unittests/Option/OptionParsingTest.cpp b/unittests/Option/OptionParsingTest.cpp index aa32da3a595fd..521009a9e663f 100644 --- a/unittests/Option/OptionParsingTest.cpp +++ b/unittests/Option/OptionParsingTest.cpp @@ -209,3 +209,17 @@ TEST(Option, Slurp) { EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[1], "--"); EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[2], "foo"); } + +TEST(Option, FlagAliasToJoined) { + TestOptTable T; + unsigned MAI, MAC; + + // Check that a flag alias provides an empty argument to a joined option. + const char *MyArgs[] = { "-K" }; + std::unique_ptr<InputArgList> AL( + T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC)); + EXPECT_EQ(AL->size(), 1U); + EXPECT_TRUE(AL->hasArg(OPT_B)); + EXPECT_EQ(AL->getAllArgValues(OPT_B).size(), 1U); + EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], ""); +} diff --git a/unittests/Option/Opts.td b/unittests/Option/Opts.td index aaed6b2101e00..c96774a68e0b0 100644 --- a/unittests/Option/Opts.td +++ b/unittests/Option/Opts.td @@ -23,4 +23,6 @@ def I : Flag<["-"], "I">, Alias<H>, Group<my_group>; def J : Flag<["-"], "J">, Alias<B>, AliasArgs<["foo"]>; def Joo : Flag<["-"], "Joo">, Alias<B>, AliasArgs<["bar"]>; +def K : Flag<["-"], "K">, Alias<B>; + def Slurp : Option<["-"], "slurp", KIND_REMAINING_ARGS>; |