dlr         2002/09/27 15:53:31

  Modified:    src/test/org/apache/xmlrpc Base64Test.java
  Log:
  Hrm, when I stopped using byte[].equals (which must've been doing
  memory address comparisons) and swapped in my own byte by byte test
  for equality, I get no test failures.
  
  http://issues.apache.org/bugzilla/show_bug.cgi?id=9931 is starting to
  look fishy.
  
  Revision  Changes    Path
  1.2       +17 -2     xml-rpc/src/test/org/apache/xmlrpc/Base64Test.java
  
  Index: Base64Test.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/test/org/apache/xmlrpc/Base64Test.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- Base64Test.java   27 Sep 2002 22:48:18 -0000      1.1
  +++ Base64Test.java   27 Sep 2002 22:53:31 -0000      1.2
  @@ -117,7 +117,7 @@
                   byte[] raw = TEST_DATA[i].getBytes();
                   byte[] encoded = Base64.encode(raw);
                   byte[] decoded = Base64.decode(encoded);
  -                assertEquals(raw, decoded);
  +                assertTrue(bytesEqual(raw, decoded));
                   assertEquals(TEST_DATA[i], new String(decoded));
               }
           }
  @@ -126,5 +126,20 @@
               e.printStackTrace();
               fail(e.getMessage());
           }
  +    }
  +
  +    /**
  +     * Byte by byte test for equality.
  +     */
  +    private boolean bytesEqual(byte[] a, byte[] b)
  +    {
  +        for (int i = 0; i < a.length; i++)
  +        {
  +            if (a[i] != b[i])
  +            {
  +                return false;
  +            }
  +        }
  +        return true;
       }
   }
  
  
  


Reply via email to