commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java
Date Mon, 20 Jan 2003 22:15:13 GMT
dlr         2003/01/20 14:15:13

  Modified:    lang/src/test/org/apache/commons/lang StringUtilsTest.java
               lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  * src/test/org/apache/commons/lang/StringUtilsTest.java
    testCaseFunctions(): Added single character string tests for
    capitalise() and uncapitalise() methods.
  
  * src/java/org/apache/commons/lang/StringUtils.java
    capitalise(), uncapitalise(): Clarified code path -- no functional
    change.
  
  Revision  Changes    Path
  1.13      +5 -1      jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -u -r1.12 -r1.13
  --- StringUtilsTest.java	19 Jan 2003 18:15:38 -0000	1.12
  +++ StringUtilsTest.java	20 Jan 2003 22:15:13 -0000	1.13
  @@ -113,6 +113,8 @@
                        CAP_FOO, StringUtils.capitalise(FOO) );
           assertEquals("capitalise(empty-string) failed",
                        "", StringUtils.capitalise("") );
  +        assertEquals("capitalise(single-char-string) failed",
  +                     "X", StringUtils.capitalise("x") );
           assertEquals("capitaliseAllWords(String) failed",
                        "Foo Bar Baz", StringUtils.capitaliseAllWords(SENTENCE) );
           assertEquals("capitaliseAllWords(empty-string) failed",
  @@ -121,6 +123,8 @@
                        FOO, StringUtils.uncapitalise(CAP_FOO) );
           assertEquals("uncapitalise(empty-string) failed",
                        "", StringUtils.uncapitalise("") );
  +        assertEquals("uncapitalise(single-char-string) failed",
  +                     "x", StringUtils.uncapitalise("X") );
           assertEquals("uncapitaliseAllWords(String) failed",
                        SENTENCE, StringUtils.uncapitaliseAllWords("Foo Bar Baz") );
           assertEquals("uncapitaliseAllWords(empty-string) failed",
  
  
  
  1.32      +15 -11    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.31
  retrieving revision 1.32
  diff -u -u -r1.31 -r1.32
  --- StringUtils.java	19 Jan 2003 18:15:38 -0000	1.31
  +++ StringUtils.java	20 Jan 2003 22:15:13 -0000	1.32
  @@ -1277,13 +1277,15 @@
           if (str == null) {
               return null;
           }
  -        if (str.length() == 0) {
  +        else if (str.length() == 0) {
               return "";
           }
  -        return new StringBuffer(str.length())
  -            .append(Character.toLowerCase(str.charAt(0)))
  -            .append(str.substring(1))
  -            .toString();
  +        else {
  +            return new StringBuffer(str.length())
  +                .append(Character.toLowerCase(str.charAt(0)))
  +                .append(str.substring(1))
  +                .toString();
  +        }
       }
   
       /**
  @@ -1299,13 +1301,15 @@
           if (str == null) {
               return null;
           }
  -        if (str.length() == 0) {
  +        else if (str.length() == 0) {
               return "";
           }
  -        return new StringBuffer(str.length())
  -            .append(Character.toTitleCase(str.charAt(0)))
  -            .append(str.substring(1))
  -            .toString();
  +        else {
  +            return new StringBuffer(str.length())
  +                .append(Character.toTitleCase(str.charAt(0)))
  +                .append(str.substring(1))
  +                .toString();
  +        }
       }
   
       /**
  
  
  

--
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