File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,20 @@ public void testAmbiguousLongWithoutEqualSingleDash() throws Exception {
7575 assertEquals ("bar" , cl .getOptionValue ("foo" ));
7676 }
7777
78+ public void testAmbiguousLongWithoutEqualSingleDash2 () throws Exception {
79+ final String [] args = {"-b" , "-foobar" };
80+
81+ final Options options = new Options ();
82+ options .addOption (Option .builder ().option ("f" ).longOpt ("foo" ).optionalArg (true ).build ());
83+ options .addOption (Option .builder ().option ("b" ).longOpt ("bar" ).optionalArg (false ).build ());
84+
85+ final CommandLine cl = parser .parse (options , args );
86+
87+ assertTrue (cl .hasOption ("b" ));
88+ assertTrue (cl .hasOption ("f" ));
89+ assertEquals ("bar" , cl .getOptionValue ("foo" ));
90+ }
91+
7892 @ Test
7993 public void testAmbiguousPartialLongOption1 () throws Exception {
8094 final String [] args = {"--ver" };
@@ -471,7 +485,7 @@ public void testOptionAndRequiredOption() throws Exception {
471485 assertEquals ("Confirm arg of -b" , "file" , cl .getOptionValue ("b" ));
472486 assertTrue ("Confirm NO of extra args" , cl .getArgList ().isEmpty ());
473487 }
474-
488+
475489 @ Test
476490 public void testOptionGroup () throws Exception {
477491 final OptionGroup group = new OptionGroup ();
You can’t perform that action at this time.
0 commit comments