Skip to content

Commit 3d9587c

Browse files
committed
Added option to test which traverses extra if-path
1 parent 4f17a89 commit 3d9587c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/test/java/org/apache/commons/cli/DisablePartialMatchingTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ public void testDisablePartialMatching() throws Exception
3333

3434
options.addOption(new Option("d", "debug", false, "Turn on debug."));
3535
options.addOption(new Option("e", "extract", false, "Turn on extract."));
36+
options.addOption(new Option("o", "option", true, "Turn on option with argument."));
3637

37-
CommandLine line = parser.parse(options, new String[]{"-de"});
38+
CommandLine line = parser.parse(options, new String[]{"-de", "--option=foobar"});
3839

3940
assertTrue("There should be an option debug in any case...", line.hasOption("debug"));
4041
assertTrue("There should be an extract option because partial matching is off", line.hasOption("extract"));
42+
assertTrue("There should be an option option with a argument value", line.hasOption("option"));
4143
}
4244

4345
@Test
@@ -49,10 +51,13 @@ public void testRegularPartialMatching() throws Exception
4951

5052
options.addOption(new Option("d", "debug", false, "Turn on debug."));
5153
options.addOption(new Option("e", "extract", false, "Turn on extract."));
54+
options.addOption(new Option("o", "option", true, "Turn on option with argument."));
5255

53-
CommandLine line = parser.parse(options, new String[]{"-de"});
56+
57+
CommandLine line = parser.parse(options, new String[]{"-de", "--option=foobar"});
5458

5559
assertTrue("There should be an option debug in any case...", line.hasOption("debug"));
5660
assertFalse("There should not be an extract option because partial matching only selects debug", line.hasOption("extract"));
61+
assertTrue("There should be an option option with a argument value", line.hasOption("option"));
5762
}
5863
}

0 commit comments

Comments
 (0)