Skip to content

Commit eed2561

Browse files
author
Oliver Heger
committed
CLI-6: Added an additional test case to verify that unknown short options cause an exception.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@679516 13f79535-47bb-0310-9956-ffa450edef68
1 parent a931391 commit eed2561

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/test/org/apache/commons/cli2/commandline/ParserTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ public void testParse_WithUnexpectedOption() {
8282
}
8383
}
8484

85+
public void testParse_WithUnexpectedShortOption() {
86+
try {
87+
parser.parse(new String[]{"-vx"});
88+
fail("OptionException");
89+
}
90+
catch(OptionException e) {
91+
assertEquals(options,e.getOption());
92+
assertEquals("Unexpected -x while processing --help|--verbose",e.getMessage());
93+
}
94+
}
95+
8596
public void testParseAndHelp_Successful() throws IOException {
8697
final CommandLine cl = parser.parseAndHelp(new String[]{"-v"});
8798

0 commit comments

Comments
 (0)