Skip to content

Commit 4141904

Browse files
committed
Adding another test
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x@745762 13f79535-47bb-0310-9956-ffa450edef68
1 parent b0c92c0 commit 4141904

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/test/org/apache/commons/cli/bug/BugCLI162Test.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package org.apache.commons.cli.bug;
2020

2121
import java.io.IOException;
22+
import java.io.StringWriter;
23+
import java.io.PrintWriter;
2224
import java.sql.ParameterMetaData;
2325
import java.sql.Types;
2426

@@ -227,4 +229,36 @@ public void testPrintHelpLongLines() throws ParseException, IOException {
227229
new HelpFormatter().printHelp(this.getClass().getName(), commandLineOptions);
228230
}
229231

232+
public void testLongLineChunking() throws ParseException, IOException {
233+
Options options = new Options();
234+
options.addOption("x", "extralongarg", false,
235+
"This description has ReallyLongValuesThatAreLongerThanTheWidthOfTheColumns " +
236+
"and also other ReallyLongValuesThatAreHugerAndBiggerThanTheWidthOfTheColumnsBob, " +
237+
"yes. ");
238+
HelpFormatter formatter = new HelpFormatter();
239+
StringWriter sw = new StringWriter();
240+
formatter.printHelp(new PrintWriter(sw), 35, this.getClass().getName(), "Header", options, 0, 5, "Footer");
241+
String expected = "usage:\n" +
242+
" org.apache.commons.cli.bug.B\n" +
243+
" ugCLI162Test\n" +
244+
"Header\n" +
245+
"-x,--extralongarg This\n" +
246+
" description\n" +
247+
" has\n" +
248+
" ReallyLongVal\n" +
249+
" uesThatAreLon\n" +
250+
" gerThanTheWid\n" +
251+
" thOfTheColumn\n" +
252+
" s and also\n" +
253+
" other\n" +
254+
" ReallyLongVal\n" +
255+
" uesThatAreHug\n" +
256+
" erAndBiggerTh\n" +
257+
" anTheWidthOfT\n" +
258+
" heColumnsBob,\n" +
259+
" yes.\n" +
260+
"Footer\n";
261+
assertEquals( "Long arguments did not split as expected", expected, sw.toString() );
262+
}
263+
230264
}

0 commit comments

Comments
 (0)