dlr 2003/02/13 14:05:48
Modified: src/test/org/apache/xmlrpc Base64Test.java
Log:
* src/test/org/apache/xmlrpc/Base64Test.java
assertEquals(byte[], byte[]): Wrapped long lines. No functional
change.
fail(String msg, byte[], byte[]): New method which produces an
assertion failure using the two supplied byte arrays formatted into
the error message.
writeToBuffer(StringBuffer, byte[]): A new method which writes the
supplied array to the target buffer.
Ain't sharing code cool?
Revision Changes Path
1.11 +34 -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.10
retrieving revision 1.11
diff -u -u -r1.10 -r1.11
--- Base64Test.java 13 Feb 2003 21:24:57 -0000 1.10
+++ Base64Test.java 13 Feb 2003 22:05:47 -0000 1.11
@@ -54,6 +54,7 @@
* <http://www.apache.org/>.
*/
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -151,15 +152,46 @@
if (a.length != b.length)
{
fail("Byte arrays have different lengths (" + a.length + " != " +
- b.length + ")");
+ b.length + ")", a, b);
}
for (int i = 0; i < a.length; i++)
{
if (a[i] != b[i])
{
fail("Byte arrays not equal (" + a[i] + " != " + b[i] +
- " at position + " + i + ")");
+ " at position + " + i + ")", a, b);
}
}
+ }
+
+ /**
+ * Throws an <code>AssertionFailedError</code> using the two
+ * supplied byte arrays formatted into the error message.
+ */
+ private void fail(String msg, byte[] a, byte[] b)
+ throws AssertionFailedError
+ {
+ StringBuffer buf = new StringBuffer();
+ writeToBuffer(buf, a);
+ buf.append(" not equal to ");
+ writeToBuffer(buf, b);
+ fail(msg + ": " + buf);
+ }
+
+ /**
+ * Writes <code>array</code> to <code>buf</code>.
+ */
+ private void writeToBuffer(StringBuffer buf, byte[] array)
+ {
+ buf.append("{ ");
+ for (int i = 0; i < array.length; i++)
+ {
+ if (i > 0)
+ {
+ buf.append(", ");
+ }
+ buf.append(array[i]);
+ }
+ buf.append(" }");
}
}