Revision: 5334
http://jython.svn.sourceforge.net/jython/?rev=5334&view=rev
Author: otmarhumbel
Date: 2008-09-16 07:36:48 +0000 (Tue, 16 Sep 2008)
Log Message:
-----------
now the test should be more platform independent
Modified Paths:
--------------
trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java
Modified: trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java
===================================================================
--- trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java 2008-09-15 23:57:05 UTC (rev 5333)
+++ trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java 2008-09-16 07:36:48 UTC (rev 5334)
@@ -23,8 +23,8 @@
* the setUp above used to print [-a | -b] [-a] [-b]
*/
public void testOptionGroupDuplication() {
- String help = getFormattedHelp();
- String expectedHelp = new String("usage: syntax [-a | -b]\n-a,--Aa option A\n-b,--Bb option B\n");
+ String help = unifyNewLines(getFormattedHelp());
+ String expectedHelp = unifyNewLines(new String("usage: syntax [-a | -b]\n-a,--Aa option A\n-b,--Bb option B\n"));
assertEquals("expected usage to be '" + expectedHelp + "' instead of '" + help + "'",
expectedHelp,
help);
@@ -53,4 +53,30 @@
String usage = baos.toString();
return usage;
}
+
+ /**
+ * replace the windows specific \r\n line endings with java like \n line endings
+ *
+ * @param in
+ * The string to be transformed
+ * @return The string with unified line endings
+ */
+ private String unifyNewLines(String in) {
+ char[] inChars = in.toCharArray();
+ StringBuilder b = new StringBuilder(inChars.length);
+ for (int i = 0; i < inChars.length; i++) {
+ char current = inChars[i];
+ if (current == '\r') {
+ if (i < inChars.length) {
+ char next = inChars[i + 1];
+ if (next == '\n') {
+ i++;
+ current = next;
+ }
+ }
+ }
+ b.append(current);
+ }
+ return b.toString();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|