Author: toad
Date: 2008-09-05 11:55:10 +0000 (Fri, 05 Sep 2008)
New Revision: 22444

Modified:
   trunk/freenet/src/freenet/support/Fields.java
   trunk/freenet/test/freenet/support/FieldsTest.java
Log:
intsToBytes() needs 4 bytes per integer, not 8.
Make sure the length is the same at the beginning and end of 
doRoundTripBytesArrayTo{Int,Long}


Modified: trunk/freenet/src/freenet/support/Fields.java
===================================================================
--- trunk/freenet/src/freenet/support/Fields.java       2008-09-05 11:52:34 UTC 
(rev 22443)
+++ trunk/freenet/src/freenet/support/Fields.java       2008-09-05 11:55:10 UTC 
(rev 22444)
@@ -560,7 +560,7 @@
        }

        public static byte[] intsToBytes(int[] ints) {
-               byte[] buf = new byte[ints.length * 8];
+               byte[] buf = new byte[ints.length * 4];
                for(int i = 0; i < ints.length; i++) {
                        long x = ints[i];
                        for(int j = 0; j < 4; j++) {

Modified: trunk/freenet/test/freenet/support/FieldsTest.java
===================================================================
--- trunk/freenet/test/freenet/support/FieldsTest.java  2008-09-05 11:52:34 UTC 
(rev 22443)
+++ trunk/freenet/test/freenet/support/FieldsTest.java  2008-09-05 11:55:10 UTC 
(rev 22444)
@@ -306,6 +306,7 @@
                for(int i = 0; i < inBytes.length; i++) {
                        assertEquals(outBytes[i], inBytes[i]);
                }
+               assertEquals(outBytes.length, inBytes.length);
        }

        public void testLongsToBytes() {
@@ -373,6 +374,7 @@
                for(int i = 0; i < inBytes.length; i++) {
                        assertEquals(outBytes[i], inBytes[i]);
                }
+               assertEquals(outBytes.length, inBytes.length);
        }

 }


Reply via email to