Skip to content

Commit 1cbac2f

Browse files
authored
Restore test
Add test for toSyntaxOptions with iterable of options
1 parent 0c72629 commit 1cbac2f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,21 @@ void testToSyntaxOptionGroupTest() {
426426
assertEquals("", underTest.toSyntaxOptions(new OptionGroup()), "empty group should return empty string");
427427
}
428428

429+
@Test
430+
void testToSyntaxOptionIterableTest() {
431+
final HelpFormatter underTest = HelpFormatter.builder().get();
432+
final List<Option> options = new ArrayList<>();
433+
434+
options.add(Option.builder().option("o").longOpt("one").hasArg().get());
435+
options.add(Option.builder().option("t").longOpt("two").hasArg().required().argName("other").get());
436+
options.add(Option.builder().option("th").longOpt("three").required().argName("other").get());
437+
options.add(Option.builder().option("f").argName("other").get());
438+
options.add(Option.builder().longOpt("five").hasArg().argName("other").get());
439+
options.add(Option.builder().longOpt("six").required().hasArg().argName("other").get());
440+
options.add(Option.builder().option("s").longOpt("sevem").hasArg().get());
441+
assertEquals("[-f] [--five <other>] [-o <arg>] [-s <arg>] --six <other> -t <other> -th", underTest.toSyntaxOptions(options));
442+
443+
}
429444

430445
@Test
431446
void testToSyntaxOptionOptionsTest() {

0 commit comments

Comments
 (0)