Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort method
  • Loading branch information
garydgregory committed Nov 5, 2025
commit 13c57f3a42717c8b2934d36fdf1a0944e4e24c19
26 changes: 13 additions & 13 deletions src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ void testPrintHelp() throws IOException {
assertEquals(0, sb.length(), "Should not write to output");
}

/**
* Tests example from the mailing list that caused an infinite loop.
*
* @see <a href="https://issues.apache.org/jira/browse/CLI-351">[CLI-351] Multiple traililng BREAK_CHAR_SET characters cause infinite loop in
* HelpFormatter</a>
*/
@Test
void testPrintHelpHeader() throws IOException {
HelpFormatter.builder().get().printHelp("CL syntax", "Header", Collections.emptyList(), "Footer", true);
HelpFormatter.builder().get().printHelp("CL syntax", "Header\n\n", // This makes printHelp enter into an infinite loop
Collections.emptyList(), "Footer", true);
}

@Test
public void testPrintHelpWithIterableOptions() throws IOException {
final StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -226,19 +239,6 @@ public void testPrintHelpWithIterableOptions() throws IOException {
assertEquals(0, sb.length(), "Should not write to output");
}

/**
* Tests example from the mailing list that caused an infinite loop.
*
* @see <a href="https://issues.apache.org/jira/browse/CLI-351">[CLI-351] Multiple traililng BREAK_CHAR_SET characters cause infinite loop in
* HelpFormatter</a>
*/
@Test
void testPrintHelpHeader() throws IOException {
HelpFormatter.builder().get().printHelp("CL syntax", "Header", Collections.emptyList(), "Footer", true);
HelpFormatter.builder().get().printHelp("CL syntax", "Header\n\n", // This makes printHelp enter into an infinite loop
Collections.emptyList(), "Footer", true);
}

@Test
void testPrintHelpXML() throws IOException {
final StringBuilder sb = new StringBuilder();
Expand Down