Skip to content

Commit 27cf61e

Browse files
committed
Appling Oliver Heger's patch from CLI-175 to fix the build on Windows
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x@748927 13f79535-47bb-0310-9956-ffa450edef68
1 parent e66e2de commit 27cf61e

1 file changed

Lines changed: 38 additions & 36 deletions

File tree

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

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* The ASF licenses this file to You under the Apache License, Version 2.0
66
* (the "License"); you may not use this file except in compliance with
77
* the License. You may obtain a copy of the License at
8-
*
8+
*
99
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
10+
*
1111
* Unless required by applicable law or agreed to in writing, software
1212
* distributed under the License is distributed on an "AS IS" BASIS,
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,8 +19,8 @@
1919
package org.apache.commons.cli.bug;
2020

2121
import java.io.IOException;
22-
import java.io.StringWriter;
2322
import java.io.PrintWriter;
23+
import java.io.StringWriter;
2424
import java.sql.ParameterMetaData;
2525
import java.sql.Types;
2626

@@ -33,6 +33,8 @@
3333
import org.apache.commons.cli.ParseException;
3434

3535
public class BugCLI162Test extends TestCase {
36+
/** Constant for the line separator.*/
37+
private static final String CR = System.getProperty("line.separator");
3638

3739
public void testInfiniteLoop() {
3840
Options options = new Options();
@@ -105,17 +107,17 @@ public void testPrintHelpLongLines() throws ParseException, IOException {
105107
final String OPT_USER = "u";
106108

107109
final String OPT_WRITE_TO_FILE = "w";
108-
110+
109111
final String _PMODE_IN = "IN";
110112

111113
final String _PMODE_INOUT = "INOUT";
112114

113115
final String _PMODE_OUT = "OUT";
114-
116+
115117
final String _PMODE_UNK = "Unknown";
116-
118+
117119
final String PMODES = _PMODE_IN + ", " + _PMODE_INOUT + ", " + _PMODE_OUT + ", " + _PMODE_UNK;
118-
120+
119121
// Options build
120122
Options commandLineOptions;
121123
commandLineOptions = new Options();
@@ -238,26 +240,26 @@ public void testLongLineChunking() throws ParseException, IOException {
238240
HelpFormatter formatter = new HelpFormatter();
239241
StringWriter sw = new StringWriter();
240242
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";
243+
String expected = "usage:" + CR +
244+
" org.apache.commons.cli.bug.B" + CR +
245+
" ugCLI162Test" + CR +
246+
"Header" + CR +
247+
"-x,--extralongarg This" + CR +
248+
" description" + CR +
249+
" has" + CR +
250+
" ReallyLongVal" + CR +
251+
" uesThatAreLon" + CR +
252+
" gerThanTheWid" + CR +
253+
" thOfTheColumn" + CR +
254+
" s and also" + CR +
255+
" other" + CR +
256+
" ReallyLongVal" + CR +
257+
" uesThatAreHug" + CR +
258+
" erAndBiggerTh" + CR +
259+
" anTheWidthOfT" + CR +
260+
" heColumnsBob," + CR +
261+
" yes." + CR +
262+
"Footer" + CR;
261263
assertEquals( "Long arguments did not split as expected", expected, sw.toString() );
262264
}
263265

@@ -268,15 +270,15 @@ public void testLongLineChunkingIndentIgnored() throws ParseException, IOExcepti
268270
StringWriter sw = new StringWriter();
269271
formatter.printHelp(new PrintWriter(sw), 22, this.getClass().getName(), "Header", options, 0, 5, "Footer");
270272
System.err.println(sw.toString());
271-
String expected = "usage:\n" +
272-
" org.apache.comm\n" +
273-
" ons.cli.bug.Bug\n" +
274-
" CLI162Test\n" +
275-
"Header\n" +
276-
"-x,--extralongarg\n" +
277-
" This description is\n" +
278-
" Long.\n" +
279-
"Footer\n";
273+
String expected = "usage:" + CR +
274+
" org.apache.comm" + CR +
275+
" ons.cli.bug.Bug" + CR +
276+
" CLI162Test" + CR +
277+
"Header" + CR +
278+
"-x,--extralongarg" + CR +
279+
" This description is" + CR +
280+
" Long." + CR +
281+
"Footer" + CR;
280282
assertEquals( "Long arguments did not split as expected", expected, sw.toString() );
281283
}
282284

0 commit comments

Comments
 (0)