commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject svn commit: r161579 - in jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/util/HelpFormatter.java test/org/apache/commons/cli2/util/HelpFormatterTest.java
Date Sat, 16 Apr 2005 15:40:34 GMT
Author: roxspring
Date: Sat Apr 16 08:40:32 2005
New Revision: 161579

URL: http://svn.apache.org/viewcvs?view=rev&rev=161579
Log:
Long descriptions with newlines are now correctly formatted

Modified:
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java?view=diff&r1=161578&r2=161579
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
Sat Apr 16 08:40:32 2005
@@ -362,10 +362,10 @@
 
         while (left < chars.length) {
             int right = left;
-            while (right < chars.length && chars[right] != '\n') {
+            while (right < chars.length && chars[right] != '\n' && right<left+width+1)
{
                 right++;
             }
-            if (right < chars.length) {
+            if (right<chars.length && chars[right] == '\n') {
                 final String line = new String(chars, left, right - left);
                 lines.add(line);
                 left = right + 1;

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java?view=diff&r1=161578&r2=161579
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
Sat Apr 16 08:40:32 2005
@@ -21,6 +21,7 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -343,6 +344,23 @@
         assertEquals("", i.next());
         assertEquals("Apache Software Foundation", i.next());
         assertEquals("", i.next());
+        assertFalse(i.hasNext());
+    }
+
+    public void testWrap_NewLine2() {
+        List wrapped = HelpFormatter.wrap("A really quite long general description of the
option with specific alternatives documented:\n"+
+                    "  Indented special case\n"+
+                    "  Alternative scenario", 30);
+        
+        final Iterator i =
+            wrapped.iterator();
+        
+        assertEquals("A really quite long general", i.next());
+        assertEquals("description of the option", i.next());
+        assertEquals("with specific alternatives", i.next());
+        assertEquals("documented:", i.next());
+        assertEquals("  Indented special case", i.next());
+        assertEquals("  Alternative scenario", i.next());
         assertFalse(i.hasNext());
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message