commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang StringUtilsTrimEmptyTest.java
Date Fri, 19 Jul 2002 04:04:45 GMT
bayard      2002/07/18 21:04:45

  Modified:    lang/src/java/org/apache/commons/lang StringUtils.java
               lang/src/test/org/apache/commons/lang
                        StringUtilsTrimEmptyTest.java
  Log:
  stripStart and stripEnd methods changed to fulfill their javadoc.
  Passing in strip("-+-+FOO---", "+-") will result in FOO.
  
  Revision  Changes    Path
  1.2       +5 -6      jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringUtils.java	19 Jul 2002 03:35:54 -0000	1.1
  +++ StringUtils.java	19 Jul 2002 04:04:45 -0000	1.2
  @@ -1001,7 +1001,7 @@
       }   
   
       /**
  -     * Strip any of a supplied string (first letter) from the end of a String..
  +     * Strip any of a supplied string from the end of a String..
        * If the strip string is null, whitespace is stripped.
        * 
        * @param str  the string to remove characters from
  @@ -1019,8 +1019,7 @@
                   end--;
               }
           } else {
  -            char chr = strip.charAt(0);
  -            while ((end != 0) && (str.charAt(end - 1) == chr)) {
  +            while ((end != 0) && (strip.indexOf(str.charAt(end - 1)) != -1)) {
                   end--;
               }
           }
  @@ -1028,7 +1027,7 @@
       }
   
       /**
  -     * Strip any of a supplied string (first letter) from the start of a String.
  +     * Strip any of a supplied string from the start of a String.
        * If the strip string is null, whitespace is stripped.
        * 
        * @param str  the string to remove characters from
  @@ -1050,7 +1049,7 @@
               }
           } else {
               char chr = strip.charAt(0);
  -            while ((start != sz) && (str.charAt(start) == chr)) {
  +            while ((start != sz) && (strip.indexOf(str.charAt(start)) != -1)) {
                   start++;
               }
           }
  
  
  
  1.2       +6 -1      jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringUtilsTrimEmptyTest.java	19 Jul 2002 03:35:55 -0000	1.1
  +++ StringUtilsTrimEmptyTest.java	19 Jul 2002 04:04:45 -0000	1.2
  @@ -134,6 +134,7 @@
           String fooRightDots = FOO+".........";
   
           assertEquals("", StringUtils.strip(""));
  +        assertEquals("", StringUtils.strip("        "));
           assertEquals(FOO, StringUtils.strip(foo2Space));
           assertEquals(FOO, StringUtils.strip(foo2Dots, "."));
           assertEquals(FOO, StringUtils.strip(fooRightSpace));
  @@ -156,6 +157,10 @@
           assertEquals(FOO, StringUtils.stripEnd(fooRightDots, "."));
           assertEquals(fooLeftSpace, StringUtils.stripEnd(fooLeftSpace, " "));
           assertEquals(fooLeftDots, StringUtils.stripEnd(fooLeftDots, "."));
  +
  +        assertEquals(FOO, StringUtils.strip(". . . . ."+FOO+". . ", " ."));
  +        assertEquals("-."+FOO, StringUtils.strip(". . . . -."+FOO+". . ", " ."));
  +        assertEquals(FOO, StringUtils.strip("..  .."+FOO+".. ", " ."));
   
           // test stripAll method, merely an array version of the above strip
           String[] empty = new String[0];
  
  
  

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


Mime
View raw message