commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [03/14] [text] Merge branch 'master' into TEXT-41
Date Fri, 05 May 2017 11:51:19 GMT
Merge branch 'master' into TEXT-41

Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/5eba72cb
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/5eba72cb
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/5eba72cb

Branch: refs/heads/master
Commit: 5eba72cbfc7e5a3d14da8ab08d1e55a322d6d232
Parents: 0d38c1b d4890a8
Author: Amey Jadiye <ameyjadiye@gmail.com>
Authored: Thu May 4 19:25:48 2017 +0530
Committer: GitHub <noreply@github.com>
Committed: Thu May 4 19:25:48 2017 +0530

----------------------------------------------------------------------
 checkstyle-suppressions.xml                     |  2 ++
 .../apache/commons/text/AlphabetConverter.java  |  7 +---
 .../org/apache/commons/text/StrBuilder.java     | 35 ++------------------
 .../org/apache/commons/text/StrSubstitutor.java | 22 ++++++------
 .../java/org/apache/commons/text/WordUtils.java | 33 +++++++++---------
 .../org/apache/commons/text/WordUtilsTest.java  |  8 +++++
 6 files changed, 40 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/5eba72cb/src/main/java/org/apache/commons/text/WordUtils.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/commons-text/blob/5eba72cb/src/test/java/org/apache/commons/text/WordUtilsTest.java
----------------------------------------------------------------------
diff --cc src/test/java/org/apache/commons/text/WordUtilsTest.java
index dbe315e,ced2716..e236e7c
--- a/src/test/java/org/apache/commons/text/WordUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/WordUtilsTest.java
@@@ -418,53 -417,12 +418,61 @@@ public class WordUtilsTest 
          assertEquals(expect, WordUtils.swapCase(test));
      }
  
 +    // -----------------------------------------------------------------------
 +    @Test
 +    public void testAbbreviateForNullAndEmptyString() {
 +        assertEquals(null, (WordUtils.abbreviate(null, 1,-1,"")));
 +        assertEquals(StringUtils.EMPTY, WordUtils.abbreviate("", 1,-1,""));
 +
 +        assertEquals("", WordUtils.abbreviate("0123456790", 0,0,""));
 +        assertEquals("", WordUtils.abbreviate(" 0123456790", 0,-1,""));
 +    }
 +
 +    // -----------------------------------------------------------------------
 +    @Test
 +    public void testAbbreviateForUpperLimit() {
 +        assertEquals("01234", WordUtils.abbreviate("0123456789", 0,5,""));
 +        assertEquals("01234", WordUtils.abbreviate("0123456789", 5, 2,""));
 +        assertEquals("012", WordUtils.abbreviate("012 3456789", 2, 5,""));
 +        assertEquals("012 3", WordUtils.abbreviate("012 3456789", 5, 2,""));
 +        assertEquals("0123456789", WordUtils.abbreviate("0123456789", 0,-1,""));
 +    }
 +
 +    // -----------------------------------------------------------------------
 +    @Test
 +    public void testAbbreviateForUpperLimitAndAppendedString() {
 +        assertEquals("01234-", WordUtils.abbreviate("0123456789", 0,5,"-"));
 +        assertEquals("01234-", WordUtils.abbreviate("0123456789", 5, 2,"-"));
 +        assertEquals("012", WordUtils.abbreviate("012 3456789", 2, 5, null));
 +        assertEquals("012 3", WordUtils.abbreviate("012 3456789", 5, 2,""));
 +        assertEquals("0123456789", WordUtils.abbreviate("0123456789", 0,-1,""));
 +    }
 +
 +    // -----------------------------------------------------------------------
 +    @Test
 +    public void testAbbreviateForLowerValue() {
 +        assertEquals("012", WordUtils.abbreviate("012 3456789", 0,5, null));
 +        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
 +    public void testAbbreviateForLowerValueAndAppendedString() {
 +        assertEquals("012", WordUtils.abbreviate("012 3456789", 0,5, null));
 +        assertEquals("01234-", WordUtils.abbreviate("01234 56789", 5, 10, "-"));
 +        assertEquals("01 23 45 67abc", WordUtils.abbreviate("01 23 45 67 89", 9, -1, "abc"));
 +        assertEquals("01 23 45 6", WordUtils.abbreviate("01 23 45 67 89", 9, 10, ""));
++
+     @Test
+     public void testLANG1292() throws Exception {
+         // Prior to fix, this was throwing StringIndexOutOfBoundsException
+         WordUtils.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+                 + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+                 + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",70);
++
      }
  
  }


Mime
View raw message