Revision: 7169
Author: [email protected]
Date: Tue Nov 24 15:29:15 2009
Log: Merge trunk r7168 into this branch

Fix Arrays.equals(Object[], Object[]) to handle nulls.

     svn merge --ignore-ancestry -c7168 \
       https://google-web-toolkit.googlecode.com/svn/trunk/ .


http://code.google.com/p/google-web-toolkit/source/detail?r=7169

Modified:
  /releases/2.0/branch-info.txt
  /releases/2.0/user/super/com/google/gwt/emul/java/util/Arrays.java
  /releases/2.0/user/test/com/google/gwt/emultest/java/util/ArraysTest.java

=======================================
--- /releases/2.0/branch-info.txt       Tue Nov 24 15:15:57 2009
+++ /releases/2.0/branch-info.txt       Tue Nov 24 15:29:15 2009
@@ -1048,3 +1048,8 @@
   Disable flaky HtmlUnit test.
      svn merge --ignore-ancestry -c7164 \
        https://google-web-toolkit.googlecode.com/svn/trunk/ .
+
+tr...@7168 was merged into this branch
+ Fix Arrays.equals(Object[], Object[]) to handle nulls.
+    svn merge --ignore-ancestry -c7168 \
+      https://google-web-toolkit.googlecode.com/svn/trunk/ .
=======================================
--- /releases/2.0/user/super/com/google/gwt/emul/java/util/Arrays.java  Mon  
Nov 23 12:44:09 2009
+++ /releases/2.0/user/super/com/google/gwt/emul/java/util/Arrays.java  Tue  
Nov 24 15:29:15 2009
@@ -680,7 +680,7 @@
      for (int i = 0; i < array1.length; ++i) {
        Object val1 = array1[i];
        Object val2 = array2[i];
-      if (!val1.equals(val2)) {
+      if (!Utility.equalsWithNullCheck(val1, val2)) {
          return false;
        }
      }
=======================================
---  
/releases/2.0/user/test/com/google/gwt/emultest/java/util/ArraysTest.java       
 
Mon Nov 23 12:44:09 2009
+++  
/releases/2.0/user/test/com/google/gwt/emultest/java/util/ArraysTest.java       
 
Tue Nov 24 15:29:15 2009
@@ -70,6 +70,40 @@
      String[] a = new String[] { "foo", null, "bar", "baz" };
      Arrays.hashCode(a);
    }
+
+  public void testArraysEqualsWithEmptyArrays() {
+    assertTrue(Arrays.equals(new String[0], new String[0]));
+  }
+
+  public void testArraysEqualsWithoutNullElementsEqual() {
+    assertTrue(Arrays.equals(
+        new String[] { "foo" }, new String[]{ "foo" }));
+  }
+
+  public void testArraysEqualsWithoutNullElementsNotEqual() {
+    assertFalse(Arrays.equals(
+        new String[] { "foo" }, new String[]{ "bar" }));
+  }
+
+  public void testArraysEqualsWithNullElementsEqual() {
+    assertTrue(Arrays.equals(new String[2], new String[2]));
+  }
+
+  public void testArraysEqualsWithNullElementsNotEqual() {
+    assertFalse(Arrays.equals(new String[2], new String[1]));
+  }
+
+  public void testArraysEqualsWithNullAndNonNullElementsEqual() {
+    assertTrue(Arrays.equals(
+        new String[]{ null, "foo", null, "bar" },
+        new String[]{ null, "foo", null, "bar" }));
+  }
+
+  public void testArraysEqualsWithNullAndNonNullElementsNotEqual() {
+    assertFalse(Arrays.equals(
+        new String[]{ null, "bar", null, "foo" },
+        new String[]{ null, "foo", null, "foo" }));
+  }

    /**
     * Tests {...@link Arrays#asList(Object[])}.
@@ -606,7 +640,7 @@
     * Advance the permutation to the next value. It leaves the first index  
set to
     * -1 if the range has been exceeded.
     *
-   * @param permutation array of indices -- see {...@link getPermutation} for
+   * @param permutation array of indices -- see {...@link #getPermutation} for
     *          details.
     */
    private void nextPermutation(int[] permutation) {
@@ -621,7 +655,7 @@

    /**
     * Checks to see if this permutation is valid; ie, if all of the indices  
are
-   * between 0 and n-i (see {...@link getPermutation} for details).
+   * between 0 and n-i (see {...@link #getPermutation} for details).
     *
     * @param permutations array of indices
     * @param n length of source array.

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to