commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1476070 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/StringUtils.java test/java/org/apache/commons/lang3/StringUtilsTest.java
Date Fri, 26 Apr 2013 06:51:08 GMT
Author: bayard
Date: Fri Apr 26 06:51:07 2013
New Revision: 1476070

URL: http://svn.apache.org/r1476070
Log:
Applying Joanne's subsequent patch from LANG-875 making appendIfMissing use the same logic
for null as endsWith (by reusing endsWith). 

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1476070&r1=1476069&r2=1476070&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Fri
Apr 26 06:51:07 2013
@@ -7125,7 +7125,7 @@ public class StringUtils {
         }
         if (suffixes != null && suffixes.length > 0) {
             for (final CharSequence s : suffixes) {
-                if (isEmpty(s) || endsWith(str, s, ignoreCase)) {
+                if (endsWith(str, s, ignoreCase)) {
                     return str;
                 }
             }
@@ -7150,6 +7150,7 @@ public class StringUtils {
      * StringUtils.appendIfMissing(null, null, null) = null
      * StringUtils.appendIfMissing("abc", null, null) = "abc"
      * StringUtils.appendIfMissing("", "xyz", null) = "xyz"
+     * StringUtils.appendIfMissing("abc", "xyz", new CharSequence[]{null}) = "abcxyz"
      * StringUtils.appendIfMissing("abc", "xyz", "") = "abc"
      * StringUtils.appendIfMissing("abc", "xyz", "mno") = "abcxyz"
      * StringUtils.appendIfMissing("abcxyz", "xyz", "mno") = "abcxyz"
@@ -7187,7 +7188,8 @@ public class StringUtils {
      * StringUtils.appendIfMissingIgnoreCase(null, null, null) = null
      * StringUtils.appendIfMissingIgnoreCase("abc", null, null) = "abc"
      * StringUtils.appendIfMissingIgnoreCase("", "xyz", null) = "xyz"
-     * StringUtils.appendIfMissingIgnoreCase("abc", "xyz", "") = "a"
+     * StringUtils.appendIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}) = "abcxyz"
+     * StringUtils.appendIfMissingIgnoreCase("abc", "xyz", "") = "abc"
      * StringUtils.appendIfMissingIgnoreCase("abc", "xyz", "mno") = "axyz"
      * StringUtils.appendIfMissingIgnoreCase("abcxyz", "xyz", "mno") = "abcxyz"
      * StringUtils.appendIfMissingIgnoreCase("abcmno", "xyz", "mno") = "abcmno"
@@ -7224,7 +7226,7 @@ public class StringUtils {
         }
         if (prefixes != null && prefixes.length > 0) {
             for (final CharSequence p : prefixes) {
-                if (isEmpty(p) || startsWith(str, p, ignoreCase)) {
+                if (startsWith(str, p, ignoreCase)) {
                     return str;
                 }
             }
@@ -7249,6 +7251,7 @@ public class StringUtils {
      * StringUtils.prependIfMissing(null, null, null) = null
      * StringUtils.prependIfMissing("abc", null, null) = "abc"
      * StringUtils.prependIfMissing("", "xyz", null) = "xyz"
+     * StringUtils.prependIfMissing("abc", "xyz", new CharSequence[]{null}) = "xyzabc"
      * StringUtils.prependIfMissing("abc", "xyz", "") = "abc"
      * StringUtils.prependIfMissing("abc", "xyz", "mno") = "xyzabc"
      * StringUtils.prependIfMissing("xyzabc", "xyz", "mno") = "xyzabc"
@@ -7286,6 +7289,7 @@ public class StringUtils {
      * StringUtils.prependIfMissingIgnoreCase(null, null, null) = null
      * StringUtils.prependIfMissingIgnoreCase("abc", null, null) = "abc"
      * StringUtils.prependIfMissingIgnoreCase("", "xyz", null) = "xyz"
+     * StringUtils.prependIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}) = "xyzabc"
      * StringUtils.prependIfMissingIgnoreCase("abc", "xyz", "") = "abc"
      * StringUtils.prependIfMissingIgnoreCase("abc", "xyz", "mno") = "xyzabc"
      * StringUtils.prependIfMissingIgnoreCase("xyzabc", "xyz", "mno") = "xyzabc"

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1476070&r1=1476069&r2=1476070&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
Fri Apr 26 06:51:07 2013
@@ -2239,6 +2239,7 @@ public class StringUtilsTest {
         assertEquals("appendIfMissing(null,null,null)", null, StringUtils.appendIfMissing(null,null,(CharSequence[])
null));
         assertEquals("appendIfMissing(abc,null,null)", "abc", StringUtils.appendIfMissing("abc",null,(CharSequence[])
null));
         assertEquals("appendIfMissing(\"\",xyz,null))", "xyz", StringUtils.appendIfMissing("","xyz",(CharSequence[])
null));
+        assertEquals("appendIfMissing(abc,xyz,{null})", "abcxyz", StringUtils.appendIfMissing("abc","xyz",new
CharSequence[]{null}));
         assertEquals("appendIfMissing(abc,xyz,\"\")", "abc", StringUtils.appendIfMissing("abc","xyz",""));
         assertEquals("appendIfMissing(abc,xyz,mno)", "abcxyz", StringUtils.appendIfMissing("abc","xyz","mno"));
         assertEquals("appendIfMissing(abcxyz,xyz,mno)", "abcxyz", StringUtils.appendIfMissing("abcxyz","xyz","mno"));
@@ -2262,6 +2263,7 @@ public class StringUtilsTest {
         assertEquals("appendIfMissingIgnoreCase(null,null,null)", null, StringUtils.appendIfMissingIgnoreCase(null,null,(CharSequence[])
null));
         assertEquals("appendIfMissingIgnoreCase(abc,null,null)", "abc", StringUtils.appendIfMissingIgnoreCase("abc",null,(CharSequence[])
null));
         assertEquals("appendIfMissingIgnoreCase(\"\",xyz,null)", "xyz", StringUtils.appendIfMissingIgnoreCase("","xyz",(CharSequence[])
null));
+        assertEquals("appendIfMissingIgnoreCase(abc,xyz,{null})", "abcxyz", StringUtils.appendIfMissingIgnoreCase("abc","xyz",new
CharSequence[]{null}));
         assertEquals("appendIfMissingIgnoreCase(abc,xyz,\"\")", "abc", StringUtils.appendIfMissingIgnoreCase("abc","xyz",""));
         assertEquals("appendIfMissingIgnoreCase(abc,xyz,mno)", "abcxyz", StringUtils.appendIfMissingIgnoreCase("abc","xyz","mno"));
         assertEquals("appendIfMissingIgnoreCase(abcxyz,xyz,mno)", "abcxyz", StringUtils.appendIfMissingIgnoreCase("abcxyz","xyz","mno"));
      
@@ -2285,6 +2287,7 @@ public class StringUtilsTest {
         assertEquals("prependIfMissing(null,null null)", null, StringUtils.prependIfMissing(null,null,(CharSequence[])
null));
         assertEquals("prependIfMissing(abc,null,null)", "abc", StringUtils.prependIfMissing("abc",null,(CharSequence[])
null));
         assertEquals("prependIfMissing(\"\",xyz,null)", "xyz", StringUtils.prependIfMissing("","xyz",(CharSequence[])
null));
+        assertEquals("prependIfMissing(abc,xyz,{null})","xyzabc", StringUtils.prependIfMissing("abc","xyz",new
CharSequence[]{null}));
         assertEquals("prependIfMissing(abc,xyz,\"\")","abc", StringUtils.prependIfMissing("abc","xyz",""));
         assertEquals("prependIfMissing(abc,xyz,mno)","xyzabc", StringUtils.prependIfMissing("abc","xyz","mno"));
         assertEquals("prependIfMissing(xyzabc,xyz,mno)", "xyzabc", StringUtils.prependIfMissing("xyzabc","xyz","mno"));
@@ -2308,6 +2311,7 @@ public class StringUtilsTest {
         assertEquals("prependIfMissingIgnoreCase(null,null null)", null, StringUtils.prependIfMissingIgnoreCase(null,null,(CharSequence[])
null));
         assertEquals("prependIfMissingIgnoreCase(abc,null,null)", "abc", StringUtils.prependIfMissingIgnoreCase("abc",null,(CharSequence[])
null));
         assertEquals("prependIfMissingIgnoreCase(\"\",xyz,null)", "xyz", StringUtils.prependIfMissingIgnoreCase("","xyz",(CharSequence[])
null));
+        assertEquals("prependIfMissingIgnoreCase(abc,xyz,{null})","xyzabc", StringUtils.prependIfMissingIgnoreCase("abc","xyz",new
CharSequence[]{null}));
         assertEquals("prependIfMissingIgnoreCase(abc,xyz,\"\")","abc", StringUtils.prependIfMissingIgnoreCase("abc","xyz",""));
         assertEquals("prependIfMissingIgnoreCase(abc,xyz,mno)","xyzabc", StringUtils.prependIfMissingIgnoreCase("abc","xyz","mno"));
         assertEquals("prependIfMissingIgnoreCase(xyzabc,xyz,mno)", "xyzabc", StringUtils.prependIfMissingIgnoreCase("xyzabc","xyz","mno"));



Mime
View raw message