commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r655246 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/WordUtils.java test/org/apache/commons/lang/WordUtilsTest.java
Date Sun, 11 May 2008 05:18:02 GMT
Author: bayard
Date: Sat May 10 22:18:02 2008
New Revision: 655246

URL: http://svn.apache.org/viewvc?rev=655246&view=rev
Log:
Applying Vincent Behar's second patch for LANG-419 - fixing a bug in abbreviate such that
lower limits greater than the length of the string weren't working correctly

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/WordUtilsTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java?rev=655246&r1=655245&r2=655246&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java Sat May 10 22:18:02
2008
@@ -611,6 +611,11 @@
             return StringUtils.EMPTY;
         }
 
+        // if the lower value is greater than the length of the string,
+        // set to the length of the string
+        if (lower > str.length()) {
+            lower = str.length();    
+        }
         // if the upper value is -1 (i.e. no limit) or is greater
         // than the length of the string, set to the length of the string
         if (upper == -1 || upper > str.length()) {

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/WordUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/WordUtilsTest.java?rev=655246&r1=655245&r2=655246&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/WordUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/WordUtilsTest.java Sat May
10 22:18:02 2008
@@ -387,6 +387,7 @@
         assertEquals("01234", WordUtils.abbreviate("01234 56789", 5, 10, null));
         assertEquals("01 23 45 67", WordUtils.abbreviate("01 23 45 67 89", 9, -1, null));
         assertEquals("01 23 45 6", WordUtils.abbreviate("01 23 45 67 89", 9, 10, null));
+        assertEquals("0123456789", WordUtils.abbreviate("0123456789", 15, 20, null));
 
         // test lower value + append
         assertEquals("012", WordUtils.abbreviate("012 3456789", 0,5, null));



Mime
View raw message