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
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@655246 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
04f767b393
commit
4342bd5d69
|
@ -611,6 +611,11 @@ public class WordUtils {
|
|||
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()) {
|
||||
|
|
|
@ -387,6 +387,7 @@ public class WordUtilsTest extends TestCase {
|
|||
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));
|
||||
|
|
Loading…
Reference in New Issue