harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r426982 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/String.java test/java/tests/api/java/lang/StringTest.java
Date Sun, 30 Jul 2006 23:04:14 GMT
Author: ndbeyer
Date: Sun Jul 30 16:04:14 2006
New Revision: 426982

URL: http://svn.apache.org/viewvc?rev=426982&view=rev
Log:
Apply modified patch/fix for HARMONY-719: [classlib][lang]String.contentEquals((CharSequence)"")
always return

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java?rev=426982&r1=426981&r2=426982&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
Sun Jul 30 16:04:14 2006
@@ -1728,13 +1728,21 @@
      * @since 1.5
      */
     public boolean contentEquals(CharSequence cs) {
-        if (cs == null)
+        if (cs == null) {
             throw new NullPointerException();
-        if (cs instanceof StringBuffer)
-            return contentEquals((StringBuffer)cs);
-        else {
-            return regionMatches(0, cs.toString(), 0, cs.length());
         }
+
+        int len = cs.length();
+
+        if (len != count) {
+            return false;
+        }
+
+        if (len == 0 && count == 0) {
+            return true; // since both are empty strings
+        }
+
+        return regionMatches(0, cs.toString(), 0, len);
     }
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java?rev=426982&r1=426981&r2=426982&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java
Sun Jul 30 16:04:14 2006
@@ -887,6 +887,14 @@
 	}
 
 	/**
+	 * @tests java.lang.String#contentEquals(CharSequence cs)
+	 */
+	public void test_contentEqualsLjava_lang_CharSequence() {
+		// Test for method java.lang.String java.lang.String.contentEquals(CharSequence cs)
+		assertFalse("Incorrect result of compare", "qwerty".contentEquals(""));
+	}
+
+	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.
 	 */



Mime
View raw message